?
What is the output of the following statements?
What is the output of the following statements?
int i = 0;
printf("%d %d", i, i++);
int i = 0;
printf("%d %d", i, i++);
Answer & Solution
Correct Answer:
Option
B
Since the evaluation is from right to left.
So when the print statement execute value of i = 0
Since its execute from right to left when i++ will be execute first and print value 0 (since its post increment ) and after printing 0 value of i become 1.
So it its prints for 1 for next i.
So when the print statement execute value of i = 0
Since its execute from right to left when i++ will be execute first and print value 0 (since its post increment ) and after printing 0 value of i become 1.
So it its prints for 1 for next i.
Join the Discussion
Login to post a comment or share your explanation.
Loginprintf("%d %d", --i, i++)
please explain with each step...