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 Type | Constant | Value |
Signed char | SCHAR_MIN SCHAR_MAX | -128 127 |
char | CHAR_MIN CHAR_MAX | -128 127 |
Unsigned char | UCHAR_MAX | 255 |
Short int | SHRT_MIN SHRT_MAX | -32768 32767 |
Unsigned short int | USHRT_MAX | 65535 |
int | INT_MIN INT_MAX | -2147483648 2147483647 |
Unsigned int | UINT_MAX | 4294967295 |
Long int | LONG_MIN LONG_MAX | -9223372036854775808 9223372036854775807 |
Unsigned long int | ULONG_MAX | 18446744073709551615 |
Contents
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