Challenge - 5 Problems
Integer Types Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of integer overflow in C#
What is the output of the following C# code snippet?
C Sharp (C#)
checked
{
byte b = 255;
b = (byte)(b + 1);
Console.WriteLine(b);
}Attempts:
2 left
💡 Hint
The checked block throws an exception on overflow.
✗ Incorrect
The byte type can hold values from 0 to 255. Adding 1 causes an overflow. The checked block causes an OverflowException to be thrown.
❓ Predict Output
intermediate2:00remaining
Range of Int16 type
What is the output of this C# code?
C Sharp (C#)
short min = short.MinValue; short max = short.MaxValue; Console.WriteLine($"{min} {max}");
Attempts:
2 left
💡 Hint
Short is a 16-bit signed integer.
✗ Incorrect
The Int16 (short) type ranges from -32768 to 32767.
❓ Predict Output
advanced2:00remaining
Unsigned integer max value output
What does this C# code print?
C Sharp (C#)
uint max = uint.MaxValue; Console.WriteLine(max);
Attempts:
2 left
💡 Hint
uint is a 32-bit unsigned integer.
✗ Incorrect
The uint type ranges from 0 to 4294967295. MaxValue is 4294967295.
❓ Predict Output
advanced2:00remaining
Behavior of integer underflow in unchecked context
What is the output of this C# code?
C Sharp (C#)
unchecked
{
int min = int.MinValue;
int result = min - 1;
Console.WriteLine(result);
}Attempts:
2 left
💡 Hint
Unchecked context allows silent overflow/underflow.
✗ Incorrect
int.MinValue is -2147483648. Subtracting 1 causes underflow and wraps around to 2147483647 in unchecked context.
🧠 Conceptual
expert2:00remaining
Size and range of long type in C#
Which of the following correctly describes the size and range of the C# long type?
Attempts:
2 left
💡 Hint
long is a 64-bit signed integer in C#.
✗ Incorrect
The long type in C# is a 64-bit signed integer with the specified range.