Size of Operator in C

Size of Operator

Size of operator are used to determine the size,in bytes, of a variable or data type.It is a keyword but it  is also a compile time operator.

The size of operator helps in memory allocation for data structures that are passed out of managed application to unmanaged code like Interop, custom serialization, etc.

The symbol or we can say syntax of Size of operator is-

Sizeof (data type)

The size of operator can be used to get size of data type ,classes ,structure and any other user defined data type.

SizeofOperator in C

Size of Operator

Size of operator are used to determine the size,in bytes, of a variable or data type.It is a keyword but it  is also a compile time operator.

The size of operator helps in memory allocation for data structures that are passed out of managed application to unmanaged code like Interop, custom serialization, etc.

The symbol or we can say syntax of Size of operator is-

Sizeof (data type)

The size of operator can be used to get size of data type ,classes ,structure and any other user defined data type.

Implementation of Size of operator

  • We know that actually work of Size of operator so we implement size of operator in this program.
  • When we initialize the data type like int,char,float,double so in this data type have some value in bytes.
  • like int has 2 bytes space in memory so in this program we find the value of some data type in bytes.

Code for Size of Operator in C


#include <stdio.h>

int main()
{
int a,x;
char b;
double c;
float d;
x= sizeof(a);

printf("\n%d",x);
printf("\n%d",sizeof(b));
printf("\n%d",sizeof(c));
printf("\n%d",sizeof(d));

return 0;
}
Competitive Coding Techniques
Output
4
1
8
4