Search Placementyogi.com
 

C Data Types

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

 

   

Types

Description

1.

Basic types

 

The C language provides  four basic arithmetic type identifiers in C (char, int, float and double) and optional specifiers (signed, unsigned, short, long).

2.

Enumerated types

Enumeration data type consists of named integer constants as a list. It start with 0(zero) by default and value is incremented by 1 for the sequential identifiers in the list. example: enum

3.

void type 

The type specifier void indicates that no value is available.

4.

Derived types

Array, pointer, structure, union and function are called derived data type.

Character Types

'char' data type is used to store 1 character and it occupies 1 byte in storage.

Ex. char ch='A'

Here what gets stored in ch is binary equivalent of the ASCII value of 'A'(.i.e binary of 65)

char can be signed or unsigned. signed char is same as ordinary char.

 

Data Type

Storage Size

Value range

char

1 byte

-128 to +127

unsigned char

1 byte

 0 to 255

Interger Types

This data type allows a variable to store numerical values. Range of an interger is compiler dependent.

For example in 16 bit compiler like Tubo C, it is 2 bytes and for 32 bit compiler it is 4 bytes.

C offers a variation of the integer data type. Like short and long. short minimum size is 2 bytes and long minimum size is 4 bytes.

 

Data Type

Storage Size  

Value range

int

4 bytes

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

unsigned int

4 bytes

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

[Note :  Sizes in above table are for 32 bit compiler]

Floating-point Types

Float data type allows a variable to store decimal values. A float occupies four bytes in memory. If this is insufficient, then C offers a double datatype that occupies 8 bytes in memory. If situation demands more then long double can be used. It occupies 10 bytes in memory.

 

Data Type

Storage Size

Value range

Precision

float

4 bytes

1.2E-38 to 3.4E+38

6 decimal places

double

8  bytes

2.3E-308 to 1.7E+308

15 decimal places

long double

10 bytes

3.4E-4932 to 1.1E+4932

19 decimal places

void types

'void' is an empty data type or it specify that no value is available. In C we can use void in three situations:

A. function return type as void

void main()
  {
  }

 It indicates that main function doesn't return any value.  

B. function arguments type as void

int fun(void)
 {
 }

 It indicates that fun does not accept any parameter  

C. A pointer variable type(void pointer)

  void *p;

  Here void* represents the address of variable, but not its type. 

Banner to LogicGuns.com

Hide Page Information

C Data Types,basic, enumerated, void, derived

C Basic data types, What are c data types, C floating data type, C interger data type