C Data Types

A data type is a classification that specifies which type of value a variable can store.

  • We need to define data types of each variable during variable declaration.
  • Each data types requires different amount of memory storage.
  • The data type of a variable also determines that what kind of operation can be performed on variable data.

C Data Types

C Language has some predefined set of data types to handle various kinds of data in any program. There are four basic data types that can be associated with variables in C.

Types Data Types
1. Basic data types int, char, float, double
2. Derived data type pointer, array, structure, union
3. Enumeration data type enum
4. Void data type void

Basic Data Type

The basic data types in C are integer (int), floating (float), character (char) and double. These are also called fundamental data types or primary data types.

The memory storage of basic data types can be different in 32 or 64 bit operating system.

Integer type

Integer data type allows a variable to store some range of mathematical numbers. Integer data types are declared using ‘int’ keyword. The storage size of integer data type can be 2, 4 or 8 byte. It mainly depend upon the processor in the CPU.

C language supports both signed and unsigned literals. Integers are able to store whole numbers only. Therefore, decimal values can not be stored in integers. Example of Integers are: 2, 50, 1000, 23954.

Types of integer type
Type Size Range
int 2 byte −32,768 to 32,767
signed int 2 byte −32,768 to 32,767
unsigned int 2 byte 0 to 65,535
short int 2 byte −32,768 to 32,767
signed short int 2 byte −32,768 to 32,767
unsigned short int 2 byte 0 to 65,535
long int 4 byte -2,147,483,648 to 2,147,483,647
signed long int 4 byte -2,147,483,648 to 2,147,483,647
unsigned long int 4 byte 0 to 4,294,967,295

Floating Type

Float data type can store decimal values to a variable. Storage size of float data type is often 4 and it can vary depending upon the processor in the CPU. In float data type, we can use up-to 6 digits after decimal.

Floating type variables can hold real numbers such as: 1.5, -4.123, 20.0 etc.


Double data type stores decimal values similar to float data type but it can store up-to 10 digits after decimal. The range for double datatype is from 1E–37 to 1E+37.

Type Storage Value range Decimal Points
float 4 byte 1.2E-38 to 3.4E+38 6 decimal places
double 8 byte 2.3E-308 to 1.7E+308 15 decimal places
long double 10 byte 3.4E-4932 to 1.1E+4932 19 decimal places

Character Type

Character data type is used to store only one character to a variable. ‘char’ keyword is used to define character data type in C programming. Storage size of character data type is 1.

Example of Char data types are: ‘a’,’b’,’x’,’y’.

Types of Character Type
Type Size Range
char 1 byte −128 to 127
singed char 1 byte −128 to 127
unsigned char 1 byte 0 to 255

Void Data type

Void data type mostly used to specify the type of functions & pointers. Void simply means empty or no value.

In C language, some functions do not return any value. We can use void data type for those functions as a return type. Example of void data type is: void mytask();

There are few more data type which we will cover in details. You can learn about them in next chapters.

Congratulations! Chapter Finished. Do you want to practice more?
Exercises & Assignments
  • No Content Found.
  • Interview FAQs
  • No Content Found.