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

Integer types and their ranges in C Sharp (C#) - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Integer Types Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2: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);
}
AOverflowException
B255
C0
D256
Attempts:
2 left
💡 Hint
The checked block throws an exception on overflow.
Predict Output
intermediate
2: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}");
A-65536 65535
B-32767 32768
C-32768 32767
D-128 127
Attempts:
2 left
💡 Hint
Short is a 16-bit signed integer.
Predict Output
advanced
2:00remaining
Unsigned integer max value output
What does this C# code print?
C Sharp (C#)
uint max = uint.MaxValue;
Console.WriteLine(max);
A4294967295
B-1
C2147483647
D0
Attempts:
2 left
💡 Hint
uint is a 32-bit unsigned integer.
Predict Output
advanced
2: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);
}
AOverflowException
B-2147483649
C-2147483648
D2147483647
Attempts:
2 left
💡 Hint
Unchecked context allows silent overflow/underflow.
🧠 Conceptual
expert
2:00remaining
Size and range of long type in C#
Which of the following correctly describes the size and range of the C# long type?
A32-bit signed integer ranging from -2,147,483,648 to 2,147,483,647
B64-bit signed integer ranging from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
C64-bit unsigned integer ranging from 0 to 18,446,744,073,709,551,615
D16-bit signed integer ranging from -32,768 to 32,767
Attempts:
2 left
💡 Hint
long is a 64-bit signed integer in C#.