in Programming
331 views
0 votes
0 votes
#include <stdio.h>

int main()
{
    int a=9;
   printf("%d %d %d",++a,a++,++a);

    return 0;
}

what is the output?

According to me it should be     12 10 10
in Programming
331 views

4 Comments

In argument list, "," is not acting as comma operator but only as a separator (operator overloading) and is not forming a sequence point.
0
0
Yes, output is correct

As we know that In c the execution of a function is done from "Right to left "
and print from from "left to Right"
0
0

@Magma

read the comments clearly.

 

0
0

2 Answers

2 votes
2 votes
The program exhibits undefined behaviour. Don't solve such questions for GATE.
0 votes
0 votes
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?  Unfortunately, there is no fixed order defined by the C standard. A compiler may choose to evaluate either from left-to-right. So the output is compiler dependent.

Related questions