ExamVeda
Login
Home
Operators and Expressions
?

What is the output of the following statements?
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.
Examveda
Question posted by Examveda
Community

Join the Discussion

11 Comments
Mounota Hossain
Mounota Hossain 4 years ago
int i = 5;
printf("%d %d", --i, i++)
Parag Mardhekar
Parag Mardhekar 4 years ago
it will print 0 na first
Amit Tiwari
Amit Tiwari 8 years ago
okay you have used stack property but how is 0 increemented before the completion of the statement?
Adff Ss
Adff Ss 9 years ago
but parenthesis associativity is left to right.
Examveda
Examveda 9 years ago
Umang! explanation already clear enough to understand. please read it and understand it. and run the above code to be sure about the answer.
Umang Mahant
Umang Mahant 9 years ago
if it prints 0 before 1 then ans should be A... how can u say B? Please Explain!!!
Umang Mahant
Umang Mahant 9 years ago
how?? is it wrong?
Examveda
Examveda 9 years ago
Answer updated. Please review for better clarification.
Agnes Pious
Agnes Pious 9 years ago
how??
Arun Kumar
Arun Kumar 10 years ago
i cant understand clearly...
please explain with each step...
Riti Thakur
Riti Thakur 11 years ago
I THINK IT MAY BE 1,1 IF EVALUATION FROM RIGHT TO LEFT