In this article, we will learn about the very important concept of any programming language which is data types. Without the data types, you can not write a program. So let’s start and dive deeper into data types in C
Table of Contents
Data Types:- As the name indicates, data type i.e., types of data that a variable can hold. So basically, data types specify the type of data which can be entered/assigned in the particular variables/identifiers.
One may ask why we need data types and what’s its purpose is.
As you already knew the world is full of so many intelligent people. While surfing the Internet or filling out any form online/offline if one is asked to enter a mobile number they will try to enter some symbols, alphabets etc. to prove that they are intelligent.
So to avoid these types of errors caused by intelligent people which can harm our data integrity we have to use data types in C or in any programming language with proper and strict validations.
Data types in C

Technically there are 4 types of data types in C
- Primary/Basic/Fundamental Data Types
- Derived Data Type
- Enumuration Data Type
- Void Data Type
Primary Data Types

- Primary data type is also known as Basic or Fundamenta data type.
- These are also called arithmetic data types.
- Categoriesed into 4 categories: (a) integer(int) (b) floating-point(float) (c) character (char)
Integer Type
- Used for whole numbers.
- eg: 23, 59, -78, -13 etc
- Refer to the following table for the detailed specifications
Type | Size(bytes) | Range |
---|---|---|
Int (signed) | 2 | -32,768 to 32767 |
unsigned int | 2 | 0 to 65535 |
short int (signed) | 1 | -128 to 127 |
unsigned short int | 1 | 0 to 255 |
long int (signed) | 4 | -2,147,483,648 to 2,147,483,647 |
unsigned long int | 4 | 0 to 4,294,967,295 |
Floating Type
- Used for real numbers.
- eg: 23.5, 59.5, -78.0, -13.0 etc
- Refer to the following table for the detailed specifications
Type | Size(bytes) | Range |
---|---|---|
Float | 4 | 3.4E-38 to 3.4E+38 |
double | 8 | 1.7E-308 to 1.7E+308 |
long double | 10 | 3.4E-4932 to 1.1E+4932 |
Character Type
- Used for character
- eg: ‘a’, ‘A’, ‘5’, ‘-8’ etc
- Refer to the following table for the detailed specifications
Type | Size(bytes) | Range |
---|---|---|
char or signed char | 1 | -128 to 127 |
unsigned char | 1 | 0 to 255 |
Void Type
- Void means empty, nothing.
- Used with the function which returns no value means return nothing on the execution of its block.
Derived Data Type
- Derived data types are used to derive a new user define data type as per the requirement of the programmer to accomplish the task at hand.
- Pointer, Array, Structure, Union and Functions are examples.
- We will cover this topic in our upcoming articles.
Enumerated Data Type
- Enumeration data type is also a user-defined data type.
- Used to assign names to integral constants.
- Keyword enum is used to declare new enumeration data types in C.
- Can be de defined in 2 ways
enum week{Mon, Tue, Wed};
enum week day;
or
enum week{Mon, Tue, Wed}day;
Variables in C
- Variables are like containers which contain values depending on their data types.
- Variables definitions tell the compiler where and how much storage is to be created.
- Syntax for variable declaration
- return_type variable_name(identifiers)
- Eg:-
- int i, j, k;
- char ch;
- float f;
- syntax for variable declaration and Initialization
- return_type variable=value;
- Eg
- int i=5, j=9, k=15;
- char ch=’a’
- float f=5.2 etc
- Lvalues and Rvalues in C
- Lvalues:- Repesent memory location and may appear on either the left or right side of the expressions. Eg- variables are lvalues which may appear on either side of the expression.
- Rvalues:- Repesent data value which is stored at a particular memory location and always must appear at only the right side of the expression. Eg: numeric literals or numbers are rvalues which always appear at the right side of the expression.
Write some programs with explaination.
Hello Abhishek
Thank you for your suggestion.