Ticker

6/recent/ticker-posts

Data Types in C Programming

Data Types 

Data types refer to an extensive system used for declaring variables or functions of different types before its use. The type of a variable determines how much space it occupies in storage and how the bit pattern stored is interpreted. The value of a variable can be changed any time.

C has the following 4 types of data types 

basic built-in data types: int, float, double, char 

Enumeration data type: enum 

Derived data type: pointer, array, structure, union 

Void data type: void

A variable declared to be of type int can be used to contain integral values only—that is, values that do not contain decimal places. A variable declared to be of type float can be used for storing floating- point numbers (values containing decimal places). The double type is the same as type float, only with roughly twice the precision. The char data type can be used to store a single character, such as the letter a, the digit character 6, or a semicolon similarly A variable declared char can only store character type value.

There are two types of type qualifier in c 

Size qualifier: short, long 

Sign qualifier: signed, unsigned

When the 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 sign qualifier is assumed. The range of values for signed data types is less than that of unsigned data type. Because in signed type, the left most bit is used to represent sign, while in unsigned type this bit is also used to represent the value. 

The size and range of the different data types on a 16 bit machine is given below: 

Basic data type Data type with type
qualifier
Size (byte) Range
char char or signed char
Unsigned char
1
1
-128 to 127
0 to 255
int int or signed int
unsigned int
short int or signed short int
unsigned short int
long int or signed long int
unsigned long int
2
2
1
1
4
4
-32768 to 32767
0 to 65535
-128 to 127
0 to 255
-2147483648 to 2147483647
0 to 4294967295
float float 4 -3.4E-38 to 3.4E+38
double double
Long double
8
10
1.7E-308 to 1.7E+308
3.4E-4932 to 1.1E+4932

ALSO SEARCH:

"data types in c programming"

"data types in c programming language"

"data types in c programming with examples"

"data types in c programming definition"

"basic data types in c programming"

"how many ways are there to create custom data types in c programming"

"user defined data types in c programming"

"explain data types in c programming"

"different data types in c programming"

"how many data types in c programming"

"primitive data types in c programming"

"fundamental data types in c programming"