Thursday, July 22, 2010

Program to display size of int,float and double variables ( GTU Sem I Program No : 24)

/*Program to print the size of int,float and double variables
  Program No   : 24 of GTU Practice Programs
  Developed by : Malhar Vora
  Developed on : 20/07/2010
  Email        :
  Web Site     :


void main()
   int i=1;
   float f=2.5;
   double d=2.60;
   printf("Size of int is %d",sizeof(i));
   printf("\nSize of int is %d",sizeof(f));
   printf("\nSize of int is %d",sizeof(d));



  1. I used to think that "sizeof()" was a function when I started learning C/C++. Actually sizeof() is an operator just like + - * / % etc.

    Also, below two lines are same. (That's parenthesis is not compulsory. But some few compilers must need parenthesis)

    1. sizeof(int);
    2. sizeof int;

  2. First of all I am very much thankful as You noticed My Blog [Malhar2010]. You are the First who has commented on my Blog.

    Ya, absolutely, sizeof is an operator but it is misunderstood due to use of ().

    So, You have also given me additional Knowledge on it, as I wasn't knowing that actually. So I appreciate your comment. Thanks.

  3. how do you compile it (not a c programmer, but want to run the job.