Basic DataTypes Of C language
Each and every Variables in C is associated with DataTypes. For specifying type of data, that variables store their values in which type. Like in "Integer", "Float", "Character", etc.
In this Blog, we're going to see Basic datatypes and its specific size and range to store value.
Basic Data Types Of C
Data Types
Sub Types
Format Specifier
Ranges
int
signed
%i or %d
(-32768
till +32768 )
unsigned
(0 till 65535)
short
(-32768
till +32768 )
long
(-232 till +232)
float
%f
long
(1.2E-38 till 3.4E+38)
double
(1.7E-308 till 1.7E+308)
char
%c
signed
(-128 to
+127)
unsigned
(0 to 255)
- int
- Integer is used to store positive, negative and a whole numbers. example: -52, 0 , 123 ,3, etc.. - float
- Float is used to store decimal and exponential values. example: 3.14, 0.6666...,9.054054..., etc.. - char
- Character is used to store a single character or value in quotes. example: "a", '#'."@','6',etc..
Source Code to get the Sizes Of DataTypes:
Basic Data Types Of C
Data Types
Sub Types
Format Specifier
Ranges
int
signed
%i or %d
(-32768
till +32768 )
unsigned
(0 till 65535)
short
(-32768
till +32768 )
long
(-232 till +232)
float
%f
long
(1.2E-38 till 3.4E+38)
double
(1.7E-308 till 1.7E+308)
char
%c
signed
(-128 to
+127)
unsigned
(0 to 255)
- float
- Float is used to store decimal and exponential values.
example: 3.14, 0.6666...,9.054054..., etc..
- char
- Character is used to store a single character or value in quotes.
example: "a", '#'."@','6',etc..
(a simple method/short code)
#include<stdio.h>
int main()
{
printf("Int = %d bytes\n",sizeof(int));
printf("Signed Int = %d bytes\n",sizeof(signed int));
printf("Unsigned Int = %d bytes\n",sizeof(unsigned int));
printf("Short Int = %d bytes\n",sizeof(short int));
printf("Long Int = %d bytes\n",sizeof(long int));
printf("float = %d bytes\n",sizeof(float));
printf("long float = %d bytes\n",sizeof(long));
printf("double float = %d bytes\n",sizeof(double));
printf("char = %d bytes\n",sizeof(char));
printf("Signed char = %d bytes\n",sizeof(signed char));
printf("Unsigned char = %d bytes\n",sizeof(unsigned char));
}
- In this code, to get the size of data types, I've use the command of "sizeof(datatype)"
Ouput:
ThankYou!!
KeepReading&Learning!
0 Comments