Monday 8 December 2014

C Program to check size of Various C data types

Program to check size of data types
#include<stdio.h>
main()
{
//int a=4,b;
//char ch='A';
printf("sizeof integer is %d\n",sizeof(int));
printf("size of float is %d\n",sizeof(float));
printf("size of real type is %d\n",sizeof(double));
printf("size of long real type is %d\n",sizeof(long double));
printf("size of long integer type is %d\n",sizeof(long long int));
printf("size of signed integer type is %d\n",sizeof(signed int));
printf("size of unsigned integer type is %d\n",sizeof(unsigned int));
printf("size of signed char type is %d\n",sizeof(signed char));
printf("size of unsigned char type is %d\n",sizeof(unsigned char));
}
OutPut:
madan@madan-Lenovo-G570:~/madan$ cc ex55.c

madan@madan-Lenovo-G570:~/madan$ ./a.out
sizeof integer is 4
size of float is 4
size of real type is 8
size of long real type is 16
size of long integer type is 8
size of signed integer type is 4
size of unsigned integer type is 4
size of signed char type is 1
size of unsigned char type is 1