C is a very powerful programming language because of its various data types. In computer data and information are stored and manipulated. Storage representation and machine instructions to handle constants differ from machine to machine. Data types are used to define the kind of data being stored or manipulated. ANSI C supports three classes of data types.

  1. Primary (Fundamental) Data Types
  2. Derived Data Types
  3. User-defined Data Types

Primary Data Types

There are the basis data types and supported by all the C compilers. They are mention below.

a. Integer Types

Integers are whole numbers with a range of values which differ from machine to machine architecture. Generally, integer occupies one word of storage, the word size may be the 16 or 32 bits depends upon the machine to machine. C has three classes of integer storage, they are short int, int, and long int having both signed and unsigned forms. By default integer is always signed. Unsigned integer use all the bits for the magnitude of the number and always positive.

b. Floating Point Types

Floating point is also called real number which is decimal point value having 6 digits of precision. The word size is 32 bits in all the 16 or 32 bits machine. For more accuracy double is used instead of float which uses 64 bits giving precision of 14 digits. Further extended to long double which uses 80 bits. Real number can be expressed in exponent form also.

c. Character Types

A single character can be defined as a character type data. The character data type consists of ASCII character. Characters are usually stored in 8 bits. The qualifier signed or unsigned may used. 

d. Void Types

The void type has no values, means empty. Generally, void is not used to declare the variable. This is usually used to specify the type of functions. The type of function is said to be void when it does not return any value to the calling function. For example, void add()

Derived Data Types

Fundamental data types are extensively used to express the identifiers as a derived data types such as functions, structures, pointers, arrays etc are discussed as and when they are encountered.

User-defined Data Types

C language has given the features for defining user-defined data types. On the basis of fundamental data types, users (programmers) can defined their own data types as a new name not new data type. By two different ways, programmer can define user defined data types, they are type definition and enumeration.

a. Type definition

C allows the definition of our own types based on existing fundamental data types. We can define using the keyword typedef.

Syntax: typedef fundamental data type identifier
where identifiers to the "new" name given to the data types.

For example, 
typedef int marks; // marks is used as a new data type
marks English, Computer, Maths;

b. Enumeration type

Enumeration is the user define technique which defines by default integer type constants. Enumeration is useful to define a set of constants instead of using multiple # define (symbolic constant). Enumeration is used to create user define data type. Keyword enum is used to create enumerated data type. It is defined as follows.

Syntax: enum identifier {value1, value2, ........, valuen};

The "identifier" is a user defined enumerated data type which can be used to declare variables that can have one of the values enclosed within the braces (known as enumerated constants). We can declare variable to be of this "new" type.

Syntax: enum idetifier var1, var2, ........, varn;

Then, we can assign the value to the variable by this way given below.

var1 = value2;
var3 = value5;

For example,
enum day {sun, mon, ...., sat};
enum day st_week, end_week;
st_week = sun;
end_week = Friday;

The compiler automatically assign integer digits beginning with 0 and increment by 1 to all the enumeration constants up to the last value successively. However, programmer can assign values explicitly to the enumeration constants.

For example, enum day {sun = 2, mon, ....., sat};

Both definition and declaration can be combined in one statement.

enum day {sun, mon, ........, sat} st_week, end_week; 

Qualifiers

Qualifiers modify the behavior of the variable type and their size to which they are applied. There are four different types of qualifiers.
  1. Size qualifiers : Size qualifiers alter the size of the basic data type. The keyword long and short qualifiers are used. Both long and short can be applied to int but only long can be applied to double.
  2. Sign qualifiers : Sign qualifiers alter the size of data type dividing from negative to positive. The keyword signed and unsigned qualifiers are used. Both signed and unsigned can be applied to the data types int and char only.
  3. Const : This is new qualifier defined by ANSI standard. A variable declared to be const cannot be modified by a program. Using const variable can be declared as const int a = 10; but the following segment of code is invlaid (a = 15; //illegal)
  4. Volatile : This is also a new qualifier defined by ANSI standard. A variable should be declared volatile whenever its value can be changed by same external sources from outside the program. Using volatile, variables can be declared as volatile int a = 10;