Write a C program to find the size of different data types.
#include <stdio.h>
int main() {
printf("Size of Character: %d\n", sizeof(char));
printf("Size of unsigned char: %d\n", sizeof(unsigned char));
printf("Size of signed char: %d\n", sizeof(signed char));
printf("Size of Integer: %d\n", sizeof(int));
printf("Size of Signed int: %d\n", sizeof(signed int));
printf("Size of unsigned int: %d\n", sizeof(unsigned int));
printf("Size of long: %d\n", sizeof(long));
printf("Size of unsigned long: %d\n", sizeof(unsigned long));
printf("Size of signed long: %d\n", sizeof(signed long));
printf("Size of long long: %d\n", sizeof(long long));
printf("Size of Float: %d\n", sizeof(float));
printf("Size of Double: %d\n", sizeof(double));
printf("Size of long double: %d\n", sizeof(long double));
return 0;
}
int main() {
printf("Size of Character: %d\n", sizeof(char));
printf("Size of unsigned char: %d\n", sizeof(unsigned char));
printf("Size of signed char: %d\n", sizeof(signed char));
printf("Size of Integer: %d\n", sizeof(int));
printf("Size of Signed int: %d\n", sizeof(signed int));
printf("Size of unsigned int: %d\n", sizeof(unsigned int));
printf("Size of long: %d\n", sizeof(long));
printf("Size of unsigned long: %d\n", sizeof(unsigned long));
printf("Size of signed long: %d\n", sizeof(signed long));
printf("Size of long long: %d\n", sizeof(long long));
printf("Size of Float: %d\n", sizeof(float));
printf("Size of Double: %d\n", sizeof(double));
printf("Size of long double: %d\n", sizeof(long double));
return 0;
}
Output:
jp@jp-VirtualBox:~/$ ./a.out
Size of Character: 1
Size of unsigned char: 1
Size of signed char: 1
Size of Integer: 4
Size of Signed int: 4
Size of unsigned int: 4
Size of long: 4
Size of unsigned long: 4
Size of signed long: 4
Size of long long: 8
Size of Float: 4
Size of Double: 8
Size of long double: 12
Size of Character: 1
Size of unsigned char: 1
Size of signed char: 1
Size of Integer: 4
Size of Signed int: 4
Size of unsigned int: 4
Size of long: 4
Size of unsigned long: 4
Size of signed long: 4
Size of long long: 8
Size of Float: 4
Size of Double: 8
Size of long double: 12
No comments:
Post a Comment