Data type is used to declare type of variable in C Programming. Because Data Type is very important if we want make variable.
First condition in order to make variable is user must know about data. Its mean programmer have knowledge about type of data programmer wants store into variable and then program make variable according to its receiving value.
Now we try :-
Any one say make a program in C to add to values and print result into screen.
But in above program we recognized that values are number but C compiler approved two type of number that are a number without decimal and another number with decimal point.
Then here a question arise which type of data is comming? Then programmer will clear to person about type of number.
Ok after conversation we have no doubt about variable's data type and we can declare our data. In C we use a keyword to represent data type that are given below
if we want declare none decimal number it called integer and in C has reserved key for integer that written by "int". int is symbolic name of Integer. similarly for Floating values can declare y using keyword/reserved word that is "float"
for integer value
int number1 = 12;
for floating values
float number1 = 12.00;
There are basically four type of data types that are given below -
1) - Basic Types or Fundamental types.
2) - Enumerated types
3) - Void Types
4) - Derived Types.
Basic Data Types : - In C there are three basic fundamental types of data are existed namely integer (int), Character (char), floating point (float).
Integer Type :- Integer are whole Numbers, that use for non decimal number it has range of value supported by particular machine. Generally three range of integer are exist in C which are "short int" , "int" and "long ing"
short int comes in two type
(a) - unsigned short int : this type of int we use when our input range between -128 to 127
(b) - signed short int : We use this type of integer when we require to take input that range vary between 0 to 255.
now second type of integer is "int" that come also in two type "signed int" and "unsigned int" whose range are -32768 to 32767 and 0 to 65535 respectively.
now similarly all fundamental variables have different different range according to its use.
Floating Point
First condition in order to make variable is user must know about data. Its mean programmer have knowledge about type of data programmer wants store into variable and then program make variable according to its receiving value.
Now we try :-
Any one say make a program in C to add to values and print result into screen.
But in above program we recognized that values are number but C compiler approved two type of number that are a number without decimal and another number with decimal point.
Then here a question arise which type of data is comming? Then programmer will clear to person about type of number.
Ok after conversation we have no doubt about variable's data type and we can declare our data. In C we use a keyword to represent data type that are given below
if we want declare none decimal number it called integer and in C has reserved key for integer that written by "int". int is symbolic name of Integer. similarly for Floating values can declare y using keyword/reserved word that is "float"
for integer value
int number1 = 12;
for floating values
float number1 = 12.00;
There are basically four type of data types that are given below -
1) - Basic Types or Fundamental types.
2) - Enumerated types
3) - Void Types
4) - Derived Types.
Basic Data Types : - In C there are three basic fundamental types of data are existed namely integer (int), Character (char), floating point (float).
Integer Type :- Integer are whole Numbers, that use for non decimal number it has range of value supported by particular machine. Generally three range of integer are exist in C which are "short int" , "int" and "long ing"
short int comes in two type
(a) - unsigned short int : this type of int we use when our input range between -128 to 127
(b) - signed short int : We use this type of integer when we require to take input that range vary between 0 to 255.
now second type of integer is "int" that come also in two type "signed int" and "unsigned int" whose range are -32768 to 32767 and 0 to 65535 respectively.
now similarly all fundamental variables have different different range according to its use.
Type | Storage size | Value range |
---|---|---|
char | 1 byte | -128 to 127 or 0 to 255 |
unsigned char | 1 byte | 0 to 255 |
signed char | 1 byte | -128 to 127 |
int | 2 or 4 bytes | -32,768 to 32,767 or -2,147,483,648 to 2,147,483,647 |
unsigned int | 2 or 4 bytes | 0 to 65,535 or 0 to 4,294,967,295 |
short | 2 bytes | -32,768 to 32,767 |
unsigned short | 2 bytes | 0 to 65,535 |
long | 4 bytes | -2,147,483,648 to 2,147,483,647 |
unsigned long | 4 bytes | 0 to 4,294,967,295 |
Floating Point
Type | Storage size | Value range | Precision |
---|---|---|---|
float | 4 byte | 1.2E-38 to 3.4E+38 | 6 decimal places |
double | 8 byte | 2.3E-308 to 1.7E+308 | 15 decimal places |
long double | 10 byte | 3.4E-4932 to 1.1E+4932 | 19 decimal places |
No comments:
Write comments