Sunday 28 September 2014

What is Data type

What is Data types?

In the C Programming language a data type is classification identifying one of various type of data. such as Int, float, char, double, long etc. in other words we can say that  a data type in a programming language is a set of data with value having predefined characteristics. A data type is the identification of data which is input by user, data type describe the program, which type of data input by end user and which type of the operation perform on the input data.Result are depend on data type, such as  if user want to add two number 5 and 6, declare variable in the float data type then result will be in floating 11.0 if in the integer then only 11. data type play an important role in the program. it is a responsible for storage on the memory. storage representation of these data types is different in memory. there are four fundamental data types in c. which are int char , float , and double.
            char is used to store any single character, int is used to store integer value , float is used for storing single precision floating point number and double is used for storing double precision floating point number. we can use type qualifier with these basic types to get some more type.

There are two type of type qualifiers-
1. Size qualifier  ------- short , long
2. sign qualifier -------- signed, unsigned

when qualifier unsigned is used, the number is always positive, and when signed is used, number may be positive or negative. if the sign qualifier is not mentioned , then by default signed qualifier is assumed. the range of values for signed data type is less than that of unsigned type. this is because in sign type, the leftmost bit is used to represent the sign, while in unsigned type this bit is also used to represent the value.
 Range of data type given below--

Data type
Type of qualifier
size
Range




char
char or signed char
1
-128 to 127

char
unsigned char
1
0 to 255
int
int or signed int
2
-32768 to 32767

unsigned int
2
0 to 65535

short int  or signed short int
1
-128 to 127

unsigned short int
1
0 to 255

long int or signed long int
4
-2147483648 to 2147483647

unsigned long int
4
0 to 4294967295
float
float
4
3.4E-38 to 3.4E+38

double
double
8
1.7E-308 to1.7E+308

Long double
10
3.4E-4932 to1.1E+4932

No comments:

Post a Comment