0
0
Cprogramming~20 mins

Increment and decrement operators - 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 increment operators
What is the output of the following C code?
C
int main() {
    int a = 5;
    int b = a++ + ++a;
    printf("%d\n", b);
    return 0;
}
A10
B11
C12
D13
Attempts:
2 left
💡 Hint
Remember that a++ uses the value before increment, ++a increments before use.
Predict Output
intermediate
2:00remaining
Value of variable after increments
What is the value of variable x after executing this code?
C
int main() {
    int x = 3;
    x = ++x + x++ + ++x;
    printf("%d\n", x);
    return 0;
}
A14
B13
C12
D15
Attempts:
2 left
💡 Hint
Evaluate each increment carefully and track x's value step by step.
🔧 Debug
advanced
2:00remaining
Identify the error in increment usage
Which option will cause a compilation error in C?
C
int main() {
    int a = 5;
    int b = /* expression */;
    printf("%d\n", b);
    return 0;
}
Ab = ++a + a++;
Bb = a+++++a;
Cb = a++ + ++a;
Db = a++ + a++ + ++a;
Attempts:
2 left
💡 Hint
Look carefully at the operator sequences and how C parses them.
Predict Output
advanced
2:00remaining
Output of complex increment and decrement
What is the output of this C program?
C
int main() {
    int i = 2;
    int j = i++ + --i + i-- + ++i;
    printf("%d\n", j);
    return 0;
}
A8
B9
C10
D11
Attempts:
2 left
💡 Hint
Track the value of i carefully after each increment or decrement.
Predict Output
expert
3:00remaining
Final value after chained increments and decrements
What is the value of variable x after this code runs?
C
int main() {
    int x = 1;
    x = x++ + ++x + --x + x--;
    printf("%d\n", x);
    return 0;
}
A9
B7
C6
D8
Attempts:
2 left
💡 Hint
Evaluate each increment/decrement carefully and update x after each step.