In this lesson, you will learn
Data types define the type of data a variable can hold.
It helps the compiler to understand how much memory to allocate and how to interpret the stored data.

| Type | Size (Bytes)* | Description | Example |
|---|---|---|---|
int | 2 or 4 | Stores integers | int a = 10; |
float | 4 | Stores decimal numbers (single precision) | float b = 3.14; |
double | 8 | Stores decimal numbers (double precision) | double d = 3.14159; |
char | 1 | Stores a single character | char ch = 'A'; |
| Type | Description | Example |
|---|---|---|
| Array | Collection of elements of same data type | int arr[5]; |
| Pointer | Stores memory address of another variable | int *p = &a; |
| Function | A block of code performing a task | int sum(int x, int y) |
| Type | Description | Example |
|---|---|---|
| struct | Collection of variables of different types | struct Student {int id; char name[20];} |
| union | Similar to struct, but shared memory | union Data {int i; float f;} |
| enum | Set of named integer constants | enum days {SUN, MON, TUE}; |
| typedef | Rename existing data type | typedef int marks; |
To further control the range and memory of variables, C provides modifiers:
| Modifier | Used With | Effect |
|---|---|---|
short | int | Reduces size |
long | int, double | Increases size |
signed | int, char | Allows negative and positive |
unsigned | int, char | Allows only positive |
short int s; // Smaller range
long int l; // Larger range
unsigned int u; // Only positive integers
| Data Type | Size (Bytes) | Range (Approx.) | Description |
|---|---|---|---|
char | 1 | –128 to 127 | Stores single character (signed by default) |
signed char | 1 | –128 to 127 | Explicitly signed character |
unsigned char | 1 | 0 to 255 | Only positive characters |
int | 4 | –2,147,483,648 to 2,147,483,647 | Default integer |
signed int | 4 | –2,147,483,648 to 2,147,483,647 | Same as int |
unsigned int | 4 | 0 to 4,294,967,295 | No negative integers |
short int | 2 | –32,768 to 32,767 | Short integer |
unsigned short int | 2 | 0 to 65,535 | Positive short integer |
long int | 4 or 8 | –2,147,483,648 to 2,147,483,647 or more | Larger integer |
unsigned long int | 4 or 8 | 0 to 4,294,967,295 or more | Positive long integer |
long long int | 8 | –9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 | Very large integers |
unsigned long long int | 8 | 0 to 18,446,744,073,709,551,615 | Very large positive integers |
float | 4 | ±3.4 × 10^–38 to ±3.4 × 10^38 | Single precision real number |
double | 8 | ±1.7 × 10^–308 to ±1.7 × 10^308 | Double precision real number |
long double | 10 or 12 | ±1.1 × 10^–4932 to ±1.1 × 10^4932 | Extended precision real number |
char is typically signed by default but may vary based on compiler.
Use unsigned when negative numbers are not needed — allows larger positive values.
Use long and long long when handling large integer values.
float, double, and long double are for decimal values, use double if more precision is needed.
#include<stdio.h>
int main() {
int age = 25;
float pi = 3.14;
char grade = 'A';
double bigNumber = 123456.789;
printf("Age: %d\n", age);
printf("Pi: %.2f\n", pi);
printf("Grade: %c\n", grade);
printf("Big Number: %.3lf\n", bigNumber);
return 0;
}
There are no reviews yet. Be the first one to write one.
You must be logged in to submit a review.