Basically, Data type defines the Type of the variable.
There are many data type for different different Purposes.
like:
int
float
double
char
long
etc.
program:
#include< stdio.h>
int main()
{
int number;
float n;
char c;
return 0;
}
-In this program, (number,n,c) are the variable in C.
-number is a integer variable that can store only integer value like 1,2,3,4,.....
- n is a float variable that can store float value like 1.23, 3.00 etc.
- c is a char variable that can store characters like
'a', 'b' etc.
Range of Data type :
char : -128 to 127
int : -32,768 to 32,767
long : -9223372036854775808 to 9223372036854775807
-Range is also depend on the Signed or unsigned data type.
Storage Size of Data type :
char : 1 Byte(4 bit)
int : 2 or 4 Bytes
short : 2 Byte
long : 8 Bytes
Find the Storage Size of Any data type :
program-
#include< stdio.h>
int main()
{
int a;
float b;
char c;
printf("%dn",sizeof(a))
printf("%dn",sizeof(b))
printf("%dn",sizeof(c))
return 0;
}
output-
4
4
1