C | Functions | Question 11
Output of following program?
#include <stdio.h> int main() { int i = 5; printf("%d %d %d", i++, i++, i++); return 0; } |
chevron_right
filter_none
(A) 7 6 5
(B) 5 6 7
(C) 7 7 7
(D) Compiler Dependent
Answer: (D)
Explanation: When parameters are passed to a function, the value of every parameter is evaluated before being passed to the function.
What is the order of evaluation of parameters – left-to-right or right-to-left?
If evaluation order is left-to-right, then output should be 5 6 7 and if the evaluation order is right-to-left, then output should be 7 6 5. Unfortunately, there is no fixed order defined by C standard. A compiler may choose to evaluate either from left-to-right.
So the output is compiler dependent.
Quiz of this Question
Recommended Posts:
- C | Functions | Question 10
- C | Functions | Question 4
- C | Functions | Question 8
- C | Functions | Question 11
- C | Functions | Question 6
- C | Functions | Question 7
- C | Functions | Question 5
- C | Functions | Question 2
- C | Functions | Question 9
- C | Functions | Question 3
- Java | Functions | Question 11
- Python | Functions | Question 5
- Java | Functions | Question 10
- Python | Functions | Question 6
- C++ | Virtual Functions | Question 14



