- 1

Problems with Increment Operator

How would we predict the following outputs: #include <iostream> int main() { int a = 1; std::cout << ++a + ++a + ++a << "\n"; a = 1; std::cout << ++a + a++ + a++ << "\n"; a = 1; std::cout << a++ + ++a + ++a; return 0; } Can you please explain why and when each increment takes place.

21st Aug 2016, 5:46 PM
Mohit Jain
Mohit Jain - avatar
2 odpowiedzi
+ 2
value will assign from left to right.
21st Aug 2016, 6:22 PM
Shree Ram
Shree Ram - avatar
- 1
9 7 8
21st Aug 2016, 6:16 PM
Shree Ram
Shree Ram - avatar