Programming Resource
  datasize.c
 
/* Program to display the size of various data-types */

#include <stdio.h>
#define BITS 8

int main(void)
{
short size=0;
/* Size of char type */
size=sizeof(char);
printf("The size of %-12s is %2hi Byte(s) or %2hi bits\n","char",size,size*BITS);
/* Size of short int type */
size=sizeof(short int);
printf("The size of %-12s is %2hi Byte(s) or %2hi bits\n","short int",size,size*BITS);
/* Size of int type */
size=sizeof(int);
printf("The size of %-12s is %2hi Byte(s) or %2hi bits\n","int",size,size*BITS);
/* Size of long int type */
size=sizeof(long int);
printf("The size of %-12s is %2hi Byte(s) or %2hi bits\n","long int",size,size*BITS);
/* Size of float type */
size=sizeof(float);
printf("The size of %-12s is %2hi Byte(s) or %2hi bits\n","float",size,size*BITS);
/* Size of double type */
size=sizeof(double);
printf("The size of %-12s is %2hi Byte(s) or %2hi bits\n","double",size,size*BITS);
/* Size of long double type */
size=sizeof(long double);
printf("The size of %-12s is %2hi Byte(s) or %2hi bits\n","long double",size,size*BITS);
/* Size of variable size */
size=sizeof(size);
printf("The size of %-12s is %2hi Byte(s) or %2hi bits\n","var size",size,size*BITS);
/* Size of constant BITS */
size=sizeof(BITS);
printf("The size of %-12s is %2hi Byte(s) or %2hi bits\n","const BITS",size,size*BITS);
return 0;
}
 
 
  Today, there have been 1 visitors (1 hits) on this page!  
 
This website was created for free with Own-Free-Website.com. Would you also like to have your own website?
Sign up for free