Skip to content
Home » C Program to Find Range of Data Types

C Program to Find Range of Data Types

Learn about C Program to Find Range of Data Types in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.

Data TypeConstantValue
Signed charSCHAR_MIN
SCHAR_MAX
-128
127
charCHAR_MIN
CHAR_MAX
-128
127
Unsigned charUCHAR_MAX255
Short intSHRT_MIN
SHRT_MAX
-32768
32767
Unsigned short intUSHRT_MAX65535
intINT_MIN
INT_MAX
-2147483648
2147483647
Unsigned intUINT_MAX4294967295
Long intLONG_MIN
LONG_MAX
-9223372036854775808
9223372036854775807
Unsigned long intULONG_MAX18446744073709551615
C program Datatype Ranges

C Program to Find Range of Data Types

The below program prints the range of Data types in a C program.

Program:

#include<stdio.h>
#include<limits.h>
int main()
{
   printf("The number of bits in a byte = %d\n", CHAR_BIT);

   printf("\nThe minimum value of Signed CHAR is = %d\n", SCHAR_MIN);
   printf("The maximum value of Signed CHAR is = %d\n", SCHAR_MAX);
   printf("The minimum value of CHAR is = %d\n", CHAR_MIN);
   printf("The maximum value of CHAR is = %d\n", CHAR_MAX);

   printf("\nThe minimum value of Signed INT is = %d\n", INT_MIN);
   printf("The maximum value of Signed INT is = %d\n", INT_MAX);
   printf("The maximum value of Unsigned INT is = %u\n", UINT_MAX);

   return 0;
}

Output:

The number of bits in a byte = 8

The minimum value of Signed CHAR is = -128
The maximum value of Signed CHAR is = 127
The minimum value of CHAR is = -128
The maximum value of CHAR is = 127

The minimum value of Signed INT is = -2147483648
The maximum value of Signed INT is = 2147483647
The maximum value of Unsigned INT is = 4294967295

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

Similar Codes :
Size of Structure data type
Size of a Variable