0 day streak
c / beginner
Snippet

The unsigned Keyword

The unsigned keyword is a type qualifier that can be applied to integer types (char, int, short, long). It tells the compiler that the variable will only hold non-negative values. This doubles the maximum positive value the variable can store compared to its signed counterpart.

snippet.c
c
1
2
unsigned int positiveValue = 500;
// unsigned int errorValue = -5; // This would cause unexpected behavior
Breakdown
1
unsigned int positiveValue = 500;
Declares an integer that can only store zero or positive numbers.