This blog is under construction

Saturday, 22 June 2013

C program to find the size of basic data types

Write a C program to find the size of basic data types using sizeof Operator.


  #include <stdio.h>
  int main() {
        printf("size of int    : %d\n", sizeof (int));
        printf("size of float  : %d\n", sizeof (float));
        printf("size of double : %d\n", sizeof (double));
        printf("size of char   : %d\n", sizeof (char));
        printf("size of long   : %d\n", sizeof (long));
        return 0;
  }



  Output:
  jp@jp-VirtualBox:~/$ ./a.out
  size of int        : 4
  size of float     : 4
  size of double  : 8
  size of char     : 1
  size of long     : 4





See Also:

No comments:

Post a Comment