Sunday, December 28, 2014

Datatype(2-sizeof)

1:
#include <stdio.h>
///***size of character:
int main()
{
 char ch;
ch=5;
printf("char=%d byte",sizeof(char));
return 0;
}

output: 1

2:
#include <stdio.h>
///***size of integer:
int main()
{
 int ch;
ch=5;
printf("int=%d byte",sizeof(int));
return 0;
}

output:  4

3:
#include <stdio.h>
///***size of float:
int main()
{
float ch;
ch=5;
printf("float=%d byte",sizeof(float));
return 0;
}

output:  4

4:
#include <stdio.h>
///***size of double:
int main()
{
double ch;
ch=5;
printf("Double=%d byte",sizeof(double));
return 0;
}

output:  8

/***little discussion:
#char= 1 byte=8 bit
  int= 4 byte=32 bit
 float= 4 byte=32 bit
double= 8 byte=64 bit

No comments:

Post a Comment