1,545 views
0 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

2 Answers

0 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.
Position:
Show:

Related questions

1 1 vote
1 1 answer
220
220 views
khanshahima4 asked Sep 24
220 views
1. If precedence tells me which operator has priority, and associativity tells me how to handle operators at the same level, then why do I need a separate concept called ...
14 14 votes
1 1 answer
1.3k
1.3k views
GO Classes asked Jul 2
1,302 views
Assume:$\texttt{short = 2 bytes}$, $\texttt{int = 4 bytes}$, $\texttt{char = 1 byte}$$\texttt{int}$ needs $4$-byte alignment and the final structure size is rounded to a ...
17 17 votes
2 2 answers
706
706 views
GO Classes asked Jul 2
706 views
Assume:struct Student { double gpa; }; struct Student alice; struct Student *sptr = &alice;Which of the following correctly assigns $\texttt{4.0}$ to $\texttt{alice.gpa}$...
10 10 votes
1 1 answer
534
534 views
GO Classes asked Jul 2
534 views
Consider the following code idea from the source:typedef struct { double x, y; } Point; void reset(Point p) { p.x = p.y = 0; } int main() { Point a = {12.0, 42.0}; Point ...