#include <stdio.h> int main() { int i = 3; printf("%d", (++i)++); return 0; } |
chevron_right
filter_none
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.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
Recommended Posts:
- Operators in C | Set 1 (Arithmetic Operators)
- Operators in C | Set 2 (Relational and Logical Operators)
- C | Operators | Question 1
- Python | Operators | Question 1
- Python | Operators | Question 2
- Python | Operators | Question 3
- Python | Operators | Question 4
- C | Operators | Question 2
- C | Operators | Question 3
- C | Operators | Question 4
- C | Operators | Question 6
- C | Operators | Question 7
- C | Operators | Question 8
- C | Operators | Question 9
- C | Operators | Question 10
- C | Operators | Question 11
- C | Operators | Question 12
- C | Operators | Question 13
- C | Operators | Question 27
- C | Operators | Question 15

