0
0
C++programming~20 mins

Increment and decrement operators in C++ - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Increment-Decrement Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of mixed pre and post increment
What is the output of this C++ code snippet?
C++
int x = 5;
int y = x++ + ++x;
std::cout << y << std::endl;
A13
B11
C10
D12
Attempts:
2 left
💡 Hint
Remember that post-increment returns the value before incrementing, pre-increment increments first.
Predict Output
intermediate
2:00remaining
Effect of multiple increments in one expression
What is the output of this C++ code?
C++
int a = 3;
int b = ++a + a++ + ++a;
std::cout << b << std::endl;
A14
B15
C12
D13
Attempts:
2 left
💡 Hint
Evaluate increments from left to right, updating 'a' after each operation.
Predict Output
advanced
2:00remaining
Output with decrement operators in complex expression
What is the output of this C++ code?
C++
int i = 4;
int j = i-- - --i + i--;
std::cout << j << std::endl;
A4
B3
C2
D5
Attempts:
2 left
💡 Hint
Remember post-decrement returns value before decrement, pre-decrement decrements first.
Predict Output
advanced
2:00remaining
Value of variable after increments and decrements
What is the value of 'x' after running this code?
C++
int x = 10;
x = ++x + x++ - --x + x--;
std::cout << x << std::endl;
A20
B22
C19
D21
Attempts:
2 left
💡 Hint
Track the value of x carefully after each increment or decrement.
Predict Output
expert
3:00remaining
Output of complex expression with increments and decrements
What is the output of this C++ code snippet?
C++
int n = 5;
int result = n++ + ++n - --n + n-- + n;
std::cout << result << std::endl;
A27
B28
C17
D30
Attempts:
2 left
💡 Hint
Evaluate each increment/decrement carefully and update 'n' after each operation.