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
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 |
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 |
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 |
hi folks i m approching for h1 b interview on monday 8th of august at montreal and i m having little problem in my approval notice abt my bithdate my employer has made a mistake while applying it is 12th january and istead of that he had done 18 the of january do any body have any solution for that if yes how can i prove my visa officer abt my real birthdate it urgent please let me know guys thaks dipesh patel
Can two or more operators such as and be combined in a single line of program code?
What is the difference between mpi and openmp?
the data type used for unlimited value in c and how to do this program
void main() { int s[4][2]={ {1234,56},{1212,33},{1434,80},{1312,78} }; int (*p)[2]; int i,j,*pint; for(i=0;i<=3;i++) { p=&s[i]; pint=p; printf("\n"); for(j=0;j<=1;j++) printf("%d",*(pint+j)); } } while running this program it shows a warning-suspicious pointer conversion ie pint=p; my que is why should we assign the value of p to pint again.why cant we use it directly as *(p+j)..but if i use like tat the o/p is garbage value..
Which header file should you include if you are to develop a function which can accept variable number of arguments?
Write a program using two-dimensional array that lists the odd numbers and even numbers separately in a 12 input values.
Can you explain the four storage classes in C?
how to build a exercise findig min number of e heap with list imlemented?
main() { int *ptr=(int*)malloc(sizeof(int)); *ptr=4; printf("%d",(*ptr)+++*ptr++); }
Can a pointer be volatile in c?
what is difference between ANSI structure and C99 Structure?