What will be output if you will execute following c code?
- 5 5
- 3 5
- 4 5
- 5 4
- Error
Correct answer
Explanation:
x = ++a, ++a, a++
x = 3, ++a, a++ // a = 2 + 1
x = 3, ++a, a++ // = operator has higher precedence than comma operator
x = 3, ++a, a++ // a = 3 + 1
x = 3, 4, a++
x = 3, 4, 4 // a = 4 + 1
x = 3 // a = 5
x = 3, ++a, a++ // a = 2 + 1
x = 3, ++a, a++ // = operator has higher precedence than comma operator
x = 3, ++a, a++ // a = 3 + 1
x = 3, 4, a++
x = 3, 4, 4 // a = 4 + 1
x = 3 // a = 5
0 comments:
Post a Comment