Q1 Write a c program to show the data types, their ranges, sizes in bytes and format specifiers.
Program: 139
Write a c program to show the data types, their ranges, sizes in bytes and format specifiers.
Data Type | Range | Bytes | Format Specifier |
signed char | -128 to +127 | 1 | %c |
unsigned char | 0 to 255 | 1 | %c |
short signed int | -32,768 to +32,767 | 2 | %hd |
short unsigned int | 0 to 65,535 | 2 | %hu |
signed int | -2,147,483,648 to 2,147,483,647 | 4 | %d or %i |
unsigned int | 0 to 4,294,967,295 | 4 | %u |
long signed int | -2,147,483,648 to 2,147,483,647 | 4 | %ld or %li |
long unsigned int | 0 to 4,294,967,295 | 4 | %lu |
long long int | -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 | 8 | %lld or %lli |
unsigned long long int | 0 to 18,446,744,073,709,551,615 | 8 | %llu |
float | 3.4E +/- 38 (7 digits) | 4 | %f |
double | 1.7E +/- 308 (15 digits) | 8 | %lf |
long double | Same as double | 10 | %Lf or %e or %E |
bool | 0 and 1 | 1 | %d or %i |
Output:
Size of signed char(┐): 1 byte Size of unsigned char(A): 1 byte Size of signed short int(-12345): 2 byte Size of unsigned short int(12345): 2 byte Size of signed int(-123456789): 4 byte Size of unsigned int(123456789): 4 byte Size of signed long int(-123456789): 4 byte Size of unsigned long int(123456789): 4 byte Size of signed long long int(-123456789): 8 byte Size of unsigned long long int(123456789): 8 byte Size of float(2.123457): 4 bytes Size of double(2.123457): 8 bytes Size of long double(3.172866E-317): 16 bytes Size of bool(1): 1 byte