Challenge - 5 Problems
Arithmetic Operator Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of mixed arithmetic operations
What is the output of the following C# code?
C Sharp (C#)
int a = 10; int b = 3; int result = a / b * b + a % b; Console.WriteLine(result);
Attempts:
2 left
💡 Hint
Remember integer division truncates the decimal part.
✗ Incorrect
Integer division 10 / 3 equals 3, then 3 * 3 = 9, plus remainder 10 % 3 = 1, total 10.
❓ Predict Output
intermediate2:00remaining
Result of floating-point arithmetic
What will be printed by this C# code snippet?
C Sharp (C#)
double x = 5.0 / 2.0; Console.WriteLine(x);
Attempts:
2 left
💡 Hint
Division with doubles keeps the decimal part.
✗ Incorrect
Dividing 5.0 by 2.0 results in 2.5 as a double value.
❓ Predict Output
advanced2:00remaining
Understanding operator precedence
What is the output of this C# code?
C Sharp (C#)
int a = 4; int b = 2; int c = 3; int result = a + b * c - b / c; Console.WriteLine(result);
Attempts:
2 left
💡 Hint
Remember multiplication and division have higher precedence than addition and subtraction.
✗ Incorrect
b * c = 2 * 3 = 6; b / c = 2 / 3 = 0 (integer division); so result = 4 + 6 - 0 = 10.
❓ Predict Output
advanced2:00remaining
Effect of parentheses on arithmetic operations
What will this C# code print?
C Sharp (C#)
int x = 8; int y = 4; int z = 2; int result = (x + y) / z; Console.WriteLine(result);
Attempts:
2 left
💡 Hint
Parentheses change the order of operations.
✗ Incorrect
Parentheses cause x + y to be evaluated first: 8 + 4 = 12; then 12 / 2 = 6.
❓ Predict Output
expert2:00remaining
Complex arithmetic with mixed types
What is the output of this C# code?
C Sharp (C#)
int a = 7; double b = 2.5; var result = a / b + a % (int)b; Console.WriteLine(result);
Attempts:
2 left
💡 Hint
Remember that % requires integers and division with double returns double.
✗ Incorrect
a / b = 7 / 2.5 = 2.8; a % (int)b = 7 % 2 = 1; sum = 2.8 + 1 = 3.8.