main()
{
int i=5;
printf("%d%d%d%d%d%d",i++,i--,++i,--i,i);
}
Answers were Sorted based on User's Feedback
Answer / abdul ahad
45545
because the expiration will executed from right to left and will print from left to right.
at the execution time from right i=5,--i=4,++i=5,i--=5 then decremented to4,now i++=4 ,then incremented to 5.
So the output will be left to right 45545
Is This Answer Correct ? | 105 Yes | 60 No |
Answer / prashant nair
Ans: It really much more depend on compiler.
The logic/rules made should take us to the answer 45545 but compiler does also give answer as 45555 :O
source:
http://code.hackerearth.com/bddbb9e
http://ideone.com/t5fbbd
Is This Answer Correct ? | 45 Yes | 9 No |
Answer / susie
Answer :
45545
Explanation:
The arguments in a function call are pushed into
the stack from left to right. The evaluation is by popping
out from the stack. and the evaluation is from right to
left, hence the result.
Is This Answer Correct ? | 21 Yes | 11 No |
Answer / rishit
And will be
4 5 5 4 5 and 1 garbage value as there are
6 %d in printf statement
Is This Answer Correct ? | 7 Yes | 2 No |
Answer / moschops
This is UNSPECIFIED BEHAVIOUR. It's possible to work out exactly what your particular compiler decided to do this one particular time, but other compilers are free to do it differently (and probably will). Put the code into some different compilers and you'll see different results. The order that parameters are evaluated is unspecified and left up to the compiler.
If you can explain what the compiler happens to do this one particular time, that's nice but completely useless, but anyone who actually wrote code like this should be fired.
Is This Answer Correct ? | 10 Yes | 6 No |
Answer / dharmendra
(i++,i--,++i,--i,i)
(4 , 5, 5 , 4 ,5)
explanation:
executed from right to left
and
print left to right.
Is This Answer Correct ? | 11 Yes | 7 No |
how to swap 3 nos without using temporary variable
Cluster head selection in Wireless Sensor Network using C programming language.
main() { static int a[3][3]={1,2,3,4,5,6,7,8,9}; int i,j; static *p[]={a,a+1,a+2}; for(i=0;i<3;i++) { for(j=0;j<3;j++) printf("%d\t%d\t%d\t%d\n",*(*(p+i)+j), *(*(j+p)+i),*(*(i+p)+j),*(*(p+j)+i)); } }
In the following pgm add a stmt in the function fun such that the address of 'a' gets stored in 'j'. main(){ int * j; void fun(int **); fun(&j); } void fun(int **k) { int a =0; /* add a stmt here*/ }
Who could write how to find a prime number in dynamic array?
How to palindrom string in c language?
main( ) { char *q; int j; for (j=0; j<3; j++) scanf(“%s” ,(q+j)); for (j=0; j<3; j++) printf(“%c” ,*(q+j)); for (j=0; j<3; j++) printf(“%s” ,(q+j)); }
what is the code of the output of print the 10 fibonacci number series
void main () { int x = 10; printf ("x = %d, y = %d", x,--x++); } a. 10, 10 b. 10, 9 c. 10, 11 d. none of the above
How do you create a really large matrix (i.e. 3500x3500) in C without having the program crash? I can only reach up to 2500. It must have something to do with lack of memory. Please help!
main() { int i=3; switch(i) { default:printf("zero"); case 1: printf("one"); break; case 2:printf("two"); break; case 3: printf("three"); break; } }
main() { int c[ ]={2.8,3.4,4,6.7,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) { printf(" %d ",*c); ++q; } for(j=0;j<5;j++){ printf(" %d ",*p); ++p; } }