We might need to work with various data for programming. Such as, integer number ( 1, 2, 5, 7,……….) , floating number (2.5, 3.5, 8.9 ………), various character (a….z, A…..Z, #, &) etc. In C programming these are classified four types→
Data Type
Example
Description
char
‘S’ or ‘J’
Various character
int
325759
Integer value
float
3.1416
Floating number
double
8.430896314
Floating number greater than float.
These four types are known as basic built-in data type in C/C++ Language. This data is kept in memory while running program and different data takes different memory in RAM. Such as
Data type
Memory space
Range
char
1 byte or 8 bit
Any number between -128 to 127 but it is used only to keep ASCII character.
integer
2 byte or 16 bit
Any number between -32768 to 32767
float
4 byte or 32 bit
Any number betweendouble
8 byte or 64 bit
Any number between
Example
[You must be registered and logged in to see this link.]
[You must be registered and logged in to see this link.]
void main()
{
clrscr();
printf("char takes %d byte\n",sizeof(char));
printf("int takes %d byte\n",sizeof(int));
printf("float takes %d byte \n",sizeof(float));
printf("Double takes %d byte",sizeof(double));
getch();
}
Output
Remarks
Here we have used sizeof keyword to know the size of data type and we can see the corresponding output.
Hello, Guest !
We would like to invite you to join our community.
Register & Login now
( " We are currently recruiting forum staffs " )