Data Types

A variable must have a data type like integer, decimal numbers, characters etc.  The variable of type Integer stores integers and a character type variable stores characters. The primary difference between data types is their size in memory. Different data types have different size in memory depending on the machine and compilers. These also affect the way they are displayed. The ‘cout’ knows how to display a digit and a character. There are few data types in C language. These data types are reserved words of C language. The reserve words can not be used as a variable name.

 

Let’s take a look into different data types that the C language provides us to deal with whole numbers, real numbers and character data.

 

Whole Numbers

 

The C language provides three data types to handle whole numbers.

 

*       int

*      short

*      long

 

int Data Type

 

The data type int is used to store whole numbers (integers). The integer type has a space of 4 bytes (32 bits) in memory. And it is mentioned as ‘int’ which is a reserved word of C, so we can not use it as a variable name. 

 

In programming before using any variable name we have to declare that variable with its data type. If we are using an integer variable named as ‘i’, we have to declare it as

                                  int i ;

The above line is known as declaration statement. When we declare a variable in this way, it reserves some space in memory depending on the size of data type and labels it with the variable name. The declaration statement int i ; reserves 4 bytes of memory and labels it as ‘i’. This happens at the execution time.

 

 

 

Previous

 

 

TOC

 

 

Next