C Programming - Expressions - Discussion

Discussion Forum : Expressions - Find Output of Program (Q.No. 9)
9.
What will be the output of the program?
#include<stdio.h>
int main()
{
    int i=3;
    i = i++;
    printf("%d\n", i);
    return 0;
}
3
4
5
6
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
70 comments Page 2 of 7.

Gunjan said:   5 years ago
3 is the correct answer.
As x=++i i.e. y=++i
At the place of x, any other variable can be there.

Priyanka said:   5 years ago
The answer is 3 because post-increment.
(1)

Nagamani said:   6 years ago
No, the actual answer is 3 because it is the dependent expression the value of I will assigned to the left side and than value incremented.

Rupali said:   6 years ago
The answer will be 3 because first the value is assigned to i then it is postdecremented.So i will be 3.

Neha said:   6 years ago
No, The correct answer is 3 because it is i-- (post-increment).

Meghna Anam said:   6 years ago
I have compiled this program and I get output 3.

So, the correct answer is 3.

MAG said:   6 years ago
On running the same code in code blocks, it is giving 3 as a output, because it is a post-processor.

Please, someone, explain the correct answer.

Jyoti said:   7 years ago
As I compiled, I am getting 3 as an output.

Nilesh said:   7 years ago
How answer came 4? It's post-increment operator we 1st assign the value 3 then value will increase

Anand Sharma said:   7 years ago
As I get the output as 3. I compiled using GCC compiler.


Post your comments here:

Your comments will be displayed after verification.