#include<stdio.h>
main()
{
int i=0; // value of i assigned
printf(“the value of i is %d\n”,i); // value of i printed
printf(“the ++i %d ++i %d \n”,++i ,++i); // prefix operations are
printf(“the i++ %d i++ %d \n”,i++ ,i++); // postfix operations are
return 0;
} /* predicted results
* the value of i is 0
* the ++i 2 ++i 2
*/ the i++ 2 i++ 3
BUT OUT PUT IS
/* the value of i is 0
* the ++i 2 ++i 2
*/ the i++ 3 i++ 2
CAN ANY ONE TELL ME THAT WHY IS “PRINTF” NOT SHOWING VALUE IN SEQUENCE RESPECTIVELY
hi..
printf uses a stack internally. the rightmost value is stored very firstly. In the last printf statement value of i was 2 initially. so , first 2 was inserted into the the stack and than it was incremented. then 3 was inserted into the stack, and then printing starts from top of the stack, and 3,2 is being printed…
..
++i stores the final updated value of the i into the stack at every place.