The code is a C program that prints the size, minimum and maximum value of different data types. Here is an explanation of each line of the code:
When you run this code, it will print the size, minimum and maximum value of different data types in bytes to the console.
An integer is a whole number that can be positive, negative, or zero.
Data Type | Memory | Range | Format Specifier |
---|---|---|---|
short int | 2 | -32768 to 32767 | %hd |
unsigned short int | 2 | 0 to 65535 | %hu |
unsigned int | 4 | 0 to 4294967295 | %u |
int | 4 | -2147483648 to 2147483647 | %d |
long int | 4 | -2147483648 to 2147483647 | %ld |
unsigned long int | 4 | 0 to 4294967295 | %lu |
long long int | 8 | -9223372036854775808 To 9223372036854775807 | %lld |
unsigned long long int | 8 | 0 to 18446744073709551615 | %llu |
Character is a data type that holds one character (letter, number, etc.) of data. It must be enclosed with single quotes. e.g. 'A', '4', or '#'
Data Type | Memory | Range | Format Specifier |
---|---|---|---|
char or signed char | 1 | -128 to 127 | %c |
unsigned char | 1 | 0 to 255 | %c |
Float is a shortened term for floating point.
Data Type | Memory | Range | Format Specifier |
---|---|---|---|
float | 4 | 3.4E-38 to 3.4E+38 | %f |
double | 8 | 1.7E-308 to 1.7E+308 | %lf |
long double | 12 | 3.4E-4932 to 1.1E+4932 | %lf |
#include<stdio.h> #include<limits.h> #include<float.h> int main() { //Integer printf("\nShort int %u Bytes %d To %d",sizeof(short int),SHRT_MIN,SHRT_MAX); printf("\nunsigned short int %u Bytes 0 To %d",sizeof(unsigned short int),USHRT_MAX); printf("\nunsigned int %u Bytes 0 To %u",sizeof(unsigned int),UINT_MAX); printf("\nint %u Bytes %d To %d",sizeof(int),INT_MIN,INT_MAX); printf("\nlong int %u Bytes %ld To %ld",sizeof(long int),LONG_MIN,LONG_MAX); printf("\nunsigned long int %u Bytes 0 To %u",sizeof(unsigned long int),ULONG_MAX); printf("\nlong long int %u Bytes %lld To %lld",sizeof(long long int),LONG_LONG_MIN,LONG_LONG_MAX); printf("\nunsigned long long int %u Bytes 0 To %llu \n\n",sizeof(unsigned long long int),ULONG_LONG_MAX); //Character printf("\nCharacter %u Bytes %d To %d",sizeof(char),CHAR_MIN,CHAR_MAX); printf("\nCharacter %u Bytes 0 To %d\n\n",sizeof(unsigned char),UCHAR_MAX); //Float printf("\nFloat %u Bytes",sizeof(float)); printf("\nDouble %u Bytes",sizeof(double)); printf("\nLong Double %u Bytes\n\n",sizeof(long double)); return 0; }To download raw file Click Here
Short int 2 Bytes -32768 To 32767 unsigned short int 2 Bytes 0 To 65535 unsigned int 4 Bytes 0 To 4294967295 int 4 Bytes -2147483648 To 2147483647 long int 4 Bytes -2147483648 To 2147483647 unsigned long int 4 Bytes 0 To 4294967295 long long int 8 Bytes -9223372036854775808 To 9223372036854775807 unsigned long long int 8 Bytes 0 To 18446744073709551615 Character 1 Bytes -128 To 127 Character 1 Bytes 0 To 255 Float 4 Bytes Double 8 Bytes Long Double 12 Bytes
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions