Wednesday, February 1, 2012

Find the size of data types in C

This is a simple program to find the size of different basic data types in C Programming Language. I have added only four data types you can add more if you wish.
#include <stdio.h>
#include <malloc.h>

main()
{
int i;
printf("Size of an Integer \t=\t %d (Bytes)\n",sizeof(int));
printf("Size of a Character \t=\t %d (Bytes)\n",sizeof(char));
printf("Size of a Float \t=\t %d (Bytes)\n",sizeof(float));
printf("Size of a Double \t=\t %d (Bytes)\n",sizeof(double));
}



THE OUTPUT WILL BE LIKE THIS: