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 TypeRangeBytesFormat Specifier
signed char-128 to +1271%c
unsigned char0 to 2551%c
short signed int-32,768 to +32,7672%hd
short unsigned int0 to 65,5352%hu
signed int-2,147,483,648 to 2,147,483,6474%d or %i
unsigned int0 to 4,294,967,2954%u
long signed int-2,147,483,648 to 2,147,483,6474%ld or %li
long unsigned int0 to 4,294,967,2954%lu
long long int-9,223,372,036,854,775,808 to 9,223,372,036,854,775,8078%lld or %lli
unsigned long long int0 to 18,446,744,073,709,551,6158%llu
float3.4E +/- 38 (7 digits)4%f
double1.7E +/- 308 (15 digits)8%lf
long doubleSame as double10%Lf or %e or %E
bool0 and 11%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

Lokesh Kumar

Being EASTER SCIENCE's founder, Lokesh Kumar wants to share his knowledge and ideas. His motive is "We assist you to choose the best", He believes in different thinking.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.