Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App

Related Articles

C | Functions | Question 11

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Output of following program?

#include <stdio.h>
int main()
    int i = 5;
    printf("%d %d %d", i++, i++, i++);
    return 0;

(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

My Personal Notes arrow_drop_up
Last Updated : 28 Jun, 2021
Like Article
Save Article
Similar Reads