Program to find Size of Data Types in C

Notes:

Program to find Size of Data Types in C Programming Language

The data type also indicates the amount of memory to be allocated for a specific type of data
1. int : 4 or 2 bytes
2. float : 4 bytes
3. double : 8 bytes
4. char : 1 byte
5. void : 1 or 0 byte
To display size of any data type, we take help of sizeof special operator
int sizeof(data type/data value) :returns the amount of memory to be allocated for given data or data type in bytes.

Example Code:
#include <stdio.h>
int main()
{
printf("Size of int is=%i bytes\n",sizeof(int));//4
printf("Size of float is=%i bytes\n",sizeof(float));//4
printf("Size of double is=%i bytes\n",sizeof(double));//8
printf("Size of char is=%i byte\n",sizeof(char));//1
printf("Size of void is=%i byte\n",sizeof(void));//1

printf("Size of 128 is=%i bytes\n",sizeof(128));//4
printf("Size of 3.142 is=%i bytes\n",sizeof(3.142));//8
printf("Size of 3.142 is=%i bytes\n",sizeof((float)3.142));//4
printf("Size of 'A' is=%i bytes\n",sizeof('A'));//4
printf("Size of 'A' is=%i bytes\n",sizeof((char)'A'));//1
return 0;
}