Data types in 'C'.

Storage representations and machine instruction to handle constants differ from machine to machine. 'C' supports 4 classes of data types.

1. Primary or fundamental data types .
2. User defined data type.
3. Derived data type.
4. Empty data set.

Primary data type:

'C' Compilers support four fundamental data types, namely integer (int), character (char) floating point (float), and double precision floating point (double) many of them also after extended data types long int, short int.

Integer type:

Integers are where with a range of values supported by a systems in order to provide control over range of nos and storage namely short int, long int, int in both signed and unsigned form int requires only half amount of storage space as that of int unsigned integer use all the bits for the magnitude of number and are always positive.

Floating point type:

They store real nos in 32 bits with 6 digits of precision A double data type uses 64 bits giving a precision of 14 digits. A long double also stores real nos in 80 bits.

Character type:

A single character can be defined as a character type data. They are usually stored in 8 bits.

Data type: Character or (Signed character). Keyword: Char or Signed char. Sine in bits: 8.

Data type: Unsigned Character. Keyword: Unsigned char sine in bits: 8.

Data type: Integer or Signed Integer. Keyword: int or signed int. Sine in bits: 16.

Data type: Unsigned Integer. Keyword: Unsigned int Sine in bits:16.

Data type: Short Integer or Signed Short Integer. Keyword: Short int or Signed short int. Sine in bits: 8.

Data type: Unsigned Short Integer. Keyword: Unsigned short int. Sine in bits: 8.

Data type:  Long Integer or Signed Long Integer. Keyword: Long int or Signed long int. Sine in bits: 32.

Data type: Unsigned Long Integer. Keyword: Unsigned long int. Sine in bits: 32.

Data type: Float. Keyword: Float. Sine in bit: 32.

Data type: Double. Keyword: Double. Sine in bits: 64.

Data type: Long Double. Keyword: Long Double. Sine in bits: 80.

User defined data type:

 'C' supports a feature known as "type definition" that allows users to defined on identifiers that could represent existing data type. These can be used to declare other variable.

Syntax:

type def <type> <identifier>

Example:

type def int ints;
units b1, b2.

Here for int we have given a new name units. Hence b1, b2, is also of type integer 'C' also supports another user defined data type called as enumenated data type which can be used to declare variables that can have one of the values enclosed with in braces.

Syntax:

enum <identifier> {value1, value2,....valuen};

Exmaple:

enum day {mon, tue, wed};

Here mon is equal to 1, tue=2, wed=3. (which are automatically initialized).

enum day birthday; now birthday can have any one of the value(1,2,3).

Derived data type:

Arrays functions, structures and pointers are called as derived data types.

Syntax:

data type v1, v2.....}

Example:

in a1, a2;

Declaration of variable tells the compiler what is the variable name. It specifies the type of data which the variable will hold.