// program to find
the size of all data types
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("\n The number of bytes int takes
is %d", sizeof(int));
printf("\n The number of bytes float
takes is %d", sizeof(float));
printf("\n The number of bytes double
take is%d",sizeof(double));
printf("\n The size of bytes char takes
is %d",sizeof(char));
printf("\n The size of bytes long takes
is %d",sizeof(long));
printf("\n----------------");
getch();
}
Output:
The number of bytes int takes
is 2
The number of bytes float takes
is 4
The number of bytes double takes
is 8
The number of bytes char takes
is 1
The number of bytes long takes
is 4
____________________________
But be aware which compiler you are using if you are using Turbo C 3.0 then number of bytes used will be different in comparison to number of bytes used in Turbo C 4.5.
ReplyDeleteSize of data types in Turbo C 3.0:
Data type Size
short int 2
int 2
long int 4
char 1
float 4
double 8
long double 10
Turbo C 3.0 is based on MS DOS operation system.
Size of data type in Turbo C 4.5:
Data type Size (Byte)
short int 2
int 4
long int 4
char 1
float 4
double 10
long double 12
Turbo C 4.5 is based on Microsoft window operating system.
---
SACHIN KUMAR SAINI
Pursuing M.Tech(IS)
MNNIT, Allahabad.
Ph- +91-8853470382
sachinsaini_it@yahoo.co.in