C Programming Tutorial
Computer Tutorial

Data Type in C

Data Type

Data types are means to identify the types of data and associated operations for handling it.
There are five foundational data types: character, integer, floating-point, double floating-point, and valueless . These are declared using char, int, float, double, and void, respectively. These types form the basis for several other types. The size and range of these data types may vary among processor types and compilers.

C data types are two types

1. Fundamental data types
2. Derived data types

Fundamental data types are the following types :

Integer data Type

Integer are whole number. They have no fractional parts. Integer are represented in C by int data type. It can holds only integer value. The size of an int is usually the same as the word length of the execution environment of the program.

Character data type

Character can stored any number of the C implementation basic character set. If character from this set is stored in a character variable, its value, its value is equivalent to the integer code of that character. An identifier declared as char becomes a character variable. char are generally used to hold values defined by the ASCII character set. Values outside that range may be handled differently by different compilers. In all cases an object of type char is 1 byte.

Float data Type

A number having fractional part is floating pointer number.The range of float will depend upon the method used to represent the floating-point numbers. Standard C specifies that the minimum range for a floating-point value is 1E–37 to 1E+37.

Double data type

The data type double is also used for handling floating point number. But it is treated as a distinct data types because, it occupies twice as much memory as type float.

Void data type

The void type specifies an empty set of values. The type void either explicitly declares a function as returning no value or creates generic pointers.

Modifying the Basic Types

Except type void, the basic data types may have various modifiers preceding them. A type modifier alters the meaning of the base type to more precisely fit a specific need.

Type Typical Size in Bits Minimal Range
char 8 -127 to 127
unsigned char 8 0 to 255
int 16 or 32 –32,767 to 32,767
unsigned int 16 or 32 0 to 65,535
short int 16 –32 767 to 32,767
long int 32 –2,147,483,647 to 2,147,483,647
float 32 1E–37 to 1E+37 with six digits of precision
double 64 1E–37 to 1E+37 with ten digits of precision
long double 80 1E–37 to 1E+37 with ten digits of precision