C Programming - Expressions - Discussion
Discussion Forum : Expressions - Find Output of Program (Q.No. 12)
12.
What will be the output of the program?
#include<stdio.h>
int main()
{
int i=2;
printf("%d, %d\n", ++i, ++i);
return 0;
}
Answer: Option
Explanation:
The order of evaluation of arguments passed to a function call is unspecified.
Anyhow, we consider ++i, ++i are Right-to-Left associativity. The output of the program is 4, 3.
In TurboC, the output will be 4, 3.
In GCC, the output will be 4, 4.
Discussion:
43 comments Page 4 of 5.
Rachit said:
1 decade ago
Will the basic rule chan of post/pre increment/decrement in GCC ?
Deepanshu said:
1 decade ago
@Neethu:
The output in turbo C compiler is :
39 38 38 36 36.
The output in turbo C compiler is :
39 38 38 36 36.
Suri said:
1 decade ago
Can anyone please explain in a correct way, bit confusing?
Usha said:
3 years ago
But its prints the latest value 4, 4 only. Am I right?
Gaurav said:
1 decade ago
The output varies from compiler to compiler.
Piyush Watmode said:
4 years ago
Actully, the output in gcc compiler is 4, 4.
(1)
Rahul said:
1 decade ago
Why GCC compiler give the different output?
Pooja said:
1 decade ago
Please explain it clearly with examples.
Pavani said:
10 years ago
Sorry displayed in right to left order.
Ganesh said:
7 years ago
I am not getting it. Please explain me.
(1)
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers