Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


main()
{ int i;
printf("%d",((i=1)*i-- - --i*(i=-3)*i++ + ++i));

}

ans is 24 bt how?pls tell smbody............

Answers were Sorted based on User's Feedback



main() { int i; printf("%d",((i=1)*i-- - --i*(i=-3)*i++ + ++i)); } ans is 2..

Answer / gorgeousgirl

Answer: 34
confirm the answer with http://codepad.org/PudiZIaS
Explanation:
by order of precedence, parenthesis hav highest priority
so
(i=1)*i-- - --i*(i=-3)*i++ + ++i
i=1 i=-3
now, i=-3
after assignment operations the expr becomes,
>(i)*i-- - --i*(i)*i++ + ++i
next higher priority is for auto-in/decrement
omitting post in/decrement(as they hav effect only after
this line of code), we get,
> i*i - --i*i*i + ++i
the associativity for printf statement is from right to left
so ++i is executed first before --i where i=-3
> i*i - --i*i*i + -2
now i=-2
> i*i - -3*i*i + -2
now i =-3
next precedence is for multiplication
> -3*-3
-
-3*-3*-3
+
-2
> 9 - -27 + -2
> 9 + 27 -2
> 9 + 25
> 34

Is This Answer Correct ?    3 Yes 0 No

main() { int i; printf("%d",((i=1)*i-- - --i*(i=-3)*i++ + ++i)); } ans is 2..

Answer / sureshb

value is 26 and i value is -2.

Intiallay i=1 is assiged.

((i=1)*i--) 1st expression = 1 postfix decrement evaluates at the end.
now i=1
--i => 0. 2nd expression

i=-3 assigned new value 3rd expression.

-3*-3 => 9 *(-3) => -27

++ post increment done at the end

-(-27) = 27.

1+ 27 =>28
now i is -3.
++i => -2;
28-2= 26.

i=-2;
post increment and decrement happens. finaaly i = -2.

Is This Answer Correct ?    5 Yes 3 No

main() { int i; printf("%d",((i=1)*i-- - --i*(i=-3)*i++ + ++i)); } ans is 2..

Answer / rama krishna sidhartha

Actually answer is not 24 it is -7567. When i executed this
in the turbo c compiler i got the answer like that.

Is This Answer Correct ?    0 Yes 2 No

Post New Answer

More C Interview Questions

c language interview questions & answer

0 Answers  


whether itis a structured language?

1 Answers   Microsoft,


which of the function operator cannot be over loaded a) <= b)?: c)== d)*

10 Answers   Cisco, CTS, Google, HCL, HP,


52.write a “Hello World” program in “c” without using a semicolon? 53.Give a method to count the number of ones in a 32 bit number? 54.write a program that print itself even if the source file is deleted? 55.Given an unsigned integer, find if the number is power of 2?

25 Answers   Datamatics, Solartis, TCS, ThinkBox, Trine,


How can I split up a string into whitespace-separated fields?

0 Answers  


How is a macro different from a function?

0 Answers   Tech Mahindra,


What are c preprocessors?

0 Answers  


write a program in c language that uses function to locate and return the smallest and largest integers in an array,number and their position in the array. it should also find and return the range of the numbers , that is , the difference between the largest number and the smallest.

1 Answers  


What is the size of a union variable?

0 Answers  


Is c still relevant?

0 Answers  


hello friends what do u mean by BUS ERROR i got this error while i am doing my program in DATA STRUCTURES

2 Answers   Wipro,


what will be the output off the following program? #include<stdio.h> int main() { int a; a=015+0*71+5; printf("%d,a"); return0; }

9 Answers   HCL,


Categories