Introduction to Programming - (C Language) - Unit : 1 – DATA TYPES

 

DATATYPES IN C

·     Each variable in C has an associated data type. It specifies the type of data that the variable can store like integer, character, floating, double, etc.

·     Each data type requires different amounts of memory and has some specific operations which can be performed over it.




·     Please keep in mind that storage size and range for int and float datatype will vary depend on the CPU processor (8,16, 32 and 64 bit)

·      Below table gives the detail about the storage size,format specifier and range of each C basic data types.

DATATYPE

SIZE

(BYTES)

FORMAT SPECIFIER

RANGE

int

atleast 2,

usually 4

%d,%i

-32,768 to 32,767

char

1

%c

-128 to 127  or 0 to 255

float

4

%f

1E-37 to 1E+37

with 6 digits of precision

double

8

%lf

1E-37 to 1E+37

with 10 digits of precision

short int

Usually 2

%hd

-32,767 to 32,767

unsigned int

atleast 2,

usually 4

%u

0 to 65,535 or

0 to 4,294,967,295(0 to 65,535)

long int

atleast 4,

 usually 8

%ld,%li

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

long long int

atleast 8

%lld,%lli

-(263-1) to (263-1)

unsigned long int

atleast 4

%lu

0 to 4,294,967,295

unsigned long long int

atleast 8

%llu

264-1(Added by C99)

signed char

1

%c

-128 to 127

unsigned char

1

%c

0 to 255

long double

atleast 10, usually 12 or 16

%lf

1E-37 to 1E+37 with 10 digits of precision

signed int

16 or 32

 

Same as int

unsigned short int

16

 

0 to 65,535

signed short int

16

 

Same as short int

signed long int

32

 

Same as long int

Comments

Popular posts from this blog

How to Get a Job in Top IT MNCs (TCS, Infosys, Wipro, Google, etc.) – Step-by-Step Guide for B.Tech Final Year Students

Common HR Interview Questions

How to Get an Internship in a MNC