sizeof Operator in C Programming Language

Notes:

sizeof Operator in C Programming Language:
- is used to get size of a given operand in bytes

Syntax:
int sizeof(operand)
where: operand can be a data type name, a variable name, a constant name, or a value

- returns how many bytes of memory location is allocated for a given operand

Example Code:
#include <stdio.h>
int main()
{
char ch = 'A';
int num = 22;
const float PI = 3.142;

printf("%d\n",sizeof(char)); // 1
printf("%d\n",sizeof(int)); // 4
printf("%d\n",sizeof(float)); // 4
printf("%d\n",sizeof(double)); // 8
printf("\n");

printf("%d\n",sizeof(ch)); // 1
printf("%d\n",sizeof(num)); // 4
printf("%d\n",sizeof(PI)); // 4
printf("\n");

printf("%d\n",sizeof(22)); // 4
printf("%d\n",sizeof(3.142)); // 8
printf("%d\n",sizeof((float)3.142)); // 4
printf("%d\n",sizeof('A')); // 4
printf("%d\n",sizeof((char)'A')); // 1

return 0;
}