« Previous                                                                  Next Chapter »
Data Types

Data type can be defined as the type of data of variable or constant store. When we use a variable in a program then we have to mention the type of data. The following data types are the most commonly used data types in C.

Keyword

Format

Size

Data Range

char

%c

1 Byte

-128 to +127

unsigned char

<-- -- >

8 Bytes

0 to 255

int

%d

2 Bytes

-32768 to +32767

long int

%ld

4 Bytes

-231 to +231

unsigned int

%u

2 Bytes

0 to 65535

float

%f

4 Bytes

-3.4e38 to +3.4e38

double

%lf

8 Bytes

-1.7e38 to +1.7e38

long double

%Lf

12-16 Bytes

-3.4e38 to +3.4e38

 

 

 

 

 

 

 

 

 

 

 






Qualifier

When qualifier is applied to the data type then it changes its size or its size.

Size qualifiers: short, long

Sign qualifiers: signed, unsigned


Enum Data Type

This is an user defined data type having finite set of enumeration constants. The keyword 'enum' is used to create enumerated data type.

Syntax: enum [identifier] {const1, const2... const n};

Ex: enum month { jan = 1, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec}; 


Typedef

Typedef is used to create new data type. But it is commonly used to change existing data type with another name.

Syntax:

typedef [data_type] synonym;

typedef [data_type] new_data_type;

Ex:

typedef int integer;

integer rno;

 

  « Previous                                                                  Next Chapter »