0
0
Cprogramming~20 mins

Operator precedence - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Operator Precedence Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of mixed arithmetic and bitwise operators
What is the output of this C code snippet?
C
int main() {
    int a = 5, b = 3, c = 2;
    int result = a + b << c;
    printf("%d", result);
    return 0;
}
A14
B16
C32
D13
Attempts:
2 left
💡 Hint
Remember that bitwise shift operators have lower precedence than addition.
Predict Output
intermediate
2:00remaining
Output of logical and bitwise operators combined
What is the output of this C code?
C
int main() {
    int x = 1, y = 0;
    int z = x && y & x;
    printf("%d", z);
    return 0;
}
A0
B1
C2
D3
Attempts:
2 left
💡 Hint
Check operator precedence between && and & operators.
Predict Output
advanced
2:00remaining
Result of complex expression with mixed operators
What is the output of this C program?
C
int main() {
    int a = 4, b = 2, c = 3;
    int result = a - b * c / b + c;
    printf("%d", result);
    return 0;
}
A4
B7
C3
D9
Attempts:
2 left
💡 Hint
Remember multiplication and division have higher precedence than addition and subtraction.
Predict Output
advanced
2:00remaining
Output of expression with ternary and logical operators
What does this C code print?
C
int main() {
    int x = 0, y = 5;
    int z = x ? y : y > 3 ? 10 : 20;
    printf("%d", z);
    return 0;
}
A5
B10
C20
D0
Attempts:
2 left
💡 Hint
Ternary operators associate right to left. Evaluate carefully.
Predict Output
expert
3:00remaining
Value of variable after complex expression with increments and precedence
What is the value of variable x after running this C code?
C
int main() {
    int x = 3;
    int y = x++ * ++x + x-- - --x;
    printf("%d", x);
    return 0;
}
A2
B1
C4
D3
Attempts:
2 left
💡 Hint
Remember the order of evaluation and side effects of post and pre increments.