ExamVeda
Login
Home
This question belongs to C Program C Miscellaneous
C Miscellaneous
?

Determine Output:
void main()
{
      int i=5;
      printf("%d%d%d%d%d", i++, i--, ++i, --i, i);
}

Answer & Solution
Correct Answer: Option A
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. See the picture below
C Miscellaneous mcq solution image
Examveda
Question posted by Examveda
Community

Join the Discussion

7 Comments
Golam Sarowar
Golam Sarowar 4 months ago
there is another catch, when we compiler gets prefix operator , it gives persistent memory address . thats why all prefix expression will change with the final value of i=5. the answer should be 4 5 5 5 5
Fazle Rabbi
Fazle Rabbi 6 years ago
I am getting 45555. link: https://ideone.com/MXJt1K
Youn Diny
Youn Diny 9 years ago
we are compile this question but answer is change and not given in options
the answer we get 55555
Pavan Kalyan
Pavan Kalyan 9 years ago
You are not using stack ,i am getting 45555 answer please respond
Sajid Khan
Sajid Khan 9 years ago
Ok the stack fact
Shubh Tripathi
Shubh Tripathi 9 years ago
exactly how a could be the answer
Sneha Arora
Sneha Arora 10 years ago
how option A is the answer?