main()
{ int i;
printf("%d",((i=1)*i-- - --i*(i=-3)*i++ + ++i));
}
ans is 24 bt how?pls tell smbody............
Answer Posted / 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 |
Post New Answer View All Answers
program for reversing a selected line word by word when multiple lines are given without using strrev
An organised method of depicting the use of an area of computer memory used to signify the uses for different parts of the memory a) swap b) extended memory c) memory map d) all of the above
How can a process change an environment variable in its caller?
Why doesnt that code work?
What is a ternary operator in c?
Why we use int main and void main?
explain what are pointers?
what are the facialities provided by you after the selection of the student.
What is the -> in c?
Explain the advantages of using macro in c language?
What does dm mean sexually?
What are integer variable, floating-point variable and character variable?
What are the types of unary operators?
How can I get random integers in a certain range?
What is sizeof array in c?