home
C TUTORIALS

DATA TYPES

In the C programming language, data types refers to an extensive system for declaring variables of different types. The language itself provides basic arithmetic types and syntax to build array and compound types. The C language defines 4 fundamental data types:

  1. Integer
  2. Character
  3. Floating point
  4. Double-floating point

1. INTEGER

2. CHARACTER

3. FLOATING POINT

4. DOUBLE-FLOATING POINT

MODIFIERS IN C

The amount of memory space to be allocated for a variable is derived by modifiers. Modifiers are prefixed with basic data types to modify (either increase or decrease) the amount of storage space allocated to a variable. For example, storage space for int data type is 4 byte for 32 bit processor. We can increase the range by using long int which is 8 byte. We can decrease the range by using short int which is 2 byte. There are 5 modifiers available in C :

Below table gives the detail about the storage size of each C basic data type in 16 bit processor.

S.no. C Data types Storage size Range
1. char 1 –127 to 127
2. int 2 –32,767 to 32,767
3. float 4 -3.4e38 to +3.4e38
4. double 8 -1.7e308 to +1.7e308
5. long double 10 -3.4e38 to +3.4e38
6. signed char 1 -128 to +127
7. unsigned char 1 0 to 255
8. short signed int 2 -32768 to +32767
9. short unsigned int 2 0 to 65535
10. signed int 4 -2147483648 to +2147483647
11. unsigned int 4 0 to 4294967295
12. long signed int 4 -2147483647 to +2147483647
13. long unsigned int 4 0 to 4294967295

STORAGE CLASSES IN C

Every variable in C programming has two properties: type and storage class. Type refers to the data type of variable whether it is character or integer or floating-point value etc. And storage class determines how long it stays in existence. There are 4 types of storage class:

  1. Automatic storage class
  2. Register storage class
  3. Static storage class
  4. External storage class

Automatic storage class

Keyword for automatic variable

auto

The features of a variable defined to have an automatic storage class are under:

Register storage class

Keyword to declare register variable

register

The features of a variable defined to be of register storage class are as under:

Static storage class

The value of static variable persists until the end of the program. A variable can be declared static using keyword: static. For example:

static int i;

Here, i is a static variable. The features of a variable defined to have a static storage class are as under:

External storage class

External variable can be accessed by any function. They are also known as global variables. Variables declared outside every function are external variables. The features of a variable whose storage class has been defined as external are as follows: