0
0
C Sharp (C#)programming~20 mins

Comparison operators in C Sharp (C#) - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Comparison Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of chained comparison operators
What is the output of this C# code snippet?
C Sharp (C#)
int a = 5;
int b = 10;
int c = 15;
Console.WriteLine(a < b && b < c);
ATrue
BFalse
CCompilation error
DRuntime exception
Attempts:
2 left
💡 Hint
Think about how logical AND works with comparison operators.
Predict Output
intermediate
2:00remaining
Result of equality and assignment operators
What will be printed by this code?
C Sharp (C#)
int x = 7;
int y = 7;
Console.WriteLine(x == y);
A7
BFalse
CCompilation error
DTrue
Attempts:
2 left
💡 Hint
Check if x and y have the same value.
Predict Output
advanced
2:00remaining
Output of mixed comparison and logical operators
What is the output of this code?
C Sharp (C#)
int a = 3;
int b = 4;
int c = 5;
Console.WriteLine(a < b || b > c && c == 5);
AFalse
BCompilation error
CTrue
DRuntime exception
Attempts:
2 left
💡 Hint
Remember operator precedence: && before ||.
Predict Output
advanced
2:00remaining
Value of variable after comparison and assignment
What is the value of variable result after running this code?
C Sharp (C#)
int x = 10;
int y = 20;
bool result = x > y;
result = !result;
Console.WriteLine(result);
AFalse
BTrue
C10
DCompilation error
Attempts:
2 left
💡 Hint
Check the initial comparison and then the negation.
Predict Output
expert
2:00remaining
Output of complex comparison with nullable types
What will this code print?
C Sharp (C#)
int? a = null;
int? b = 5;
Console.WriteLine(a < b);
AFalse
BTrue
CCompilation error
DRuntime exception
Attempts:
2 left
💡 Hint
Consider how nullable comparisons behave in C#.