Data Types

1 Data Types

In the C programming language, data types refer to an extensive system used for declaring variables or functions of different types. The type of a variable determines how much space it occupies in storage and how the bit pattern stored is interpreted.

The types in C can be classified as follows:

1

Primary Types:
They are arithmetic types and consists of the four types: (a) integer types and (b) floating-point types.(c) void types and (d)character type.

2

Derived types
They include (a) Pointer types, (b) Array types, (c) Structure types, (d) Union types and (e) Function types.

  3)  User defined data types

 

Integer Types

Following table gives you details about standard integer types with its storage sizes and value ranges:

Type

Storage size

Value Range

char

1 byte

       -128 to 127 or 0 to 255

unsigned char

1 byte              

        0 to 255

signed char

1 byte

       -128 to 127

int

2 or 4 bytes

       -32,768 to 32,767 or -2,147,483,648 to 2,147,483,647

unsigned int

2 or 4 bytes

       0 to 65,535 or 0 to 4,294,967,295

short

2 bytes

     -32,768 to 32,767

unsigned short

2 bytes

      0 to 65,535

long

4 bytes

     -2,147,483,648 to 2,147,483,647

unsigned long

4 bytes

     0 to 4,294,967,295

 

Floating-Point Types

Following table gives you details about standard floating-point types with storage sizes and value ranges and their precision:

Type

Storage size

Value range

Precision

float

4 byte

1.2E-38 to 3.4E+38

6 decimal places

double

8 byte

2.3E-308 to 1.7E+308

15 decimal places

long double

10 byte

3.4E-4932 to 1.1E+4932

19 decimal places

 

void Type

The void type specifies that no value is available.

Character Types

A single character can be defined as a character(char) type data. Characters are usually stored in 8bits of internal storage.

It can be signed or unsigned. Unsigned chars have values between 0 to 255.

Signed chars have values from -128 to 127