What is sizeof operator?

sizeof will return the number of bytes reserved for a variable or data type. The sizeof operator is a compile-time operator that returns an integer value. In other words since it is a compile time operator When the programmer uses the sizeof operator in a expression then the operator do not get compiled into executable code in the expression.


Syntax of this operator is


sizeof (type-name)


For instance if one wants to know the length of a data type it can be obtained by using sizeof operator as follows:


main()

{

printf("%d n", sizeof(int));

}


This returns the size of integer which is generally 2.


Suppose we have a program like below


main()

{

int a;

float b=4.0

a= sizeof(10) / sizeof(b);

)


Then the result would be sizeof integer value generally would be 2 and sizeof float which would be generally 4. Therefore result would be 2/4 which gives result as 0.

Questions by GeekAdmin   answers by GeekAdmin

 

This Question is not yet answered!

 
 

Related Answered Questions

 

Related Open Questions