Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

C | Operators | Question 5

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

C




#include <stdio.h>
int main()
{
    int i = 3;
    printf(\"%d\", (++i)++);
    return 0;
}

What is the output of the above program?
 

(A)

3
 

(B)

4
 

(C)

5
 

(D)

Compile-time error
 


Answer: (D)

Explanation:

In C, prefix and postfix operators need l-value to perform operation and return r-value. The expression (++i)++ when executed increments the value of variable i(i is a l-value) and returns r-value. The compiler generates the error(l-value required) when it tries to post-incremeny the value of a r-value.
 


Quiz of this Question
Please comment below if you find anything wrong in the above post

My Personal Notes arrow_drop_up
Last Updated : 16 Sep, 2021
Like Article
Save Article
Similar Reads