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.

TypesData Types
1.Basic data typesint, char, float, double
2.Derived data typepointer, array, structure, union
3.Enumeration data typeenum
4.Void data typevoid

Format Specifier with different Data Types

Format specifier is used for input and output function. It tells what kind of value is going to store in a variable while taking input using the scanf() and display the output using printf(). Format specifiers are almost same for scanf() and printf() function.
for eg. %d, %c, %f

Note: While working with strings %s format specifier will be used.

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.

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 depends 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

TypeSizeRangeFormat Specifier
signed int / int4 byte-2,147,483,648 to 2,147,483,647 %d 
unsigned int4 byte0 to 4,294,967,295 %u 
signed short int / short int2 byte−32,768 to 32,767%hd 
unsigned short int2 byte0 to 65,535%hu 
signed long int / long int4 byte-2,147,483,648 to 2,147,483,647 %ld 
unsigned long int4 byte0 to 4,294,967,295%lu 
signed long long int / long long int 8 byte-(2^63) to (2^63)-1 %lld 
unsigned long long int 8 byte0 to 18,446,744,073,709,551,61%llu 

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.

TypeStorageValue rangeDecimal PointsFormat Specifier
float4 byte1.2E-38 to 3.4E+386 decimal places%f 
double8 byte1.7E-308 to 1.7E+30815 decimal places%lf 
long double16 byte3.4E-4932 to 1.1E+493219 decimal places%Lf 

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

TypeSizeRangeFormat Specifier
singed char1 byte−128 to 127%c
unsigned char1 byte0 to 255%c

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. Learn more about the similar topics:
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.