Question 2770 – TCP/IP-Layers
November 19, 2023
Question 7811 – Computer-Networks
November 19, 2023
Question 2770 – TCP/IP-Layers
November 19, 2023
Question 7811 – Computer-Networks
November 19, 2023

Question 11430 – Operator

What is the output of the following C program

#include
int main()
{
int i=5;
printf("%d%d%d", i++, i ,++i);
return 0;
} 

Correct Answer: C

Question 2 Explanation: 
int i=5;
printf(“%d%d%d”, i++, i ,++i);
In printf() the firstly the calculation is done from right to left and then printing is done from left to right.
So first ++i will increase the value of i by 1 and make it 6. Now the i will be read simply for second calculation.And now i++ will be calculated which will increment the value of i by 1 and make it 7, but since it is post increment so first 6 will be printed and then increment will be done and then for rest two 7 and 7 will be printed .Hence the output will be 6,7,7.
A
7 6 6
B
6 7 8
C
6 7 7
D
5 6 7
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
error: Alert: Content selection is disabled!!