C Programming/C Basics

C Data Types

Updated on January 8, 2026
1 min read

Data Types in C

Data types tell the compiler what kind of data a variable will store and how much memory it needs.

 They help the compiler allocate memory correctly and perform operations safely.

EASY LEVEL (Beginner Friendly)

Why Data Types Are Needed

  • Different data needs different memory
  • Numbers, characters, and decimals are stored differently
  • Data types avoid confusion and errors

Main Types of Data Types in C (Easy)

1. Integer Type (int)

Used to store whole numbers.

int age = 20;

Examples: -50100

2. Character Type (char)

Used to store single characters.

char grade = 'A';

Stores only one character at a time.

3. Floating Point Type (float)

Used to store decimal numbers.

float price = 99.50;

4. Double Type (double)

Used to store large decimal values with more accuracy.

double distance = 12345.6789;

5. Void Type (void)

Used when no value is returned.

void show() {
}

EXPERT LEVEL (Technical & Exam-Oriented)

Classification of Data Types in C

1. Basic (Primitive) Data Types

TypeDescription
intInteger values
charCharacter data
floatDecimal numbers
doubleHigh-precision decimals
voidNo value

2. Derived Data Types

Derived from basic types.

TypeExample
Arrayint a[5];
Pointerint *p;
Functionint add();

3. User-Defined Data Types

Created by the programmer.

TypePurpose
structGroup different data types
unionShare memory
enumNamed constants
typedefRename data types

Memory Size (Typical)

Data TypeSize
char1 byte
int4 bytes
float4 bytes
double8 bytes

(Note: Size may vary by system/compiler)

Example Showing Data Types in Use

int count = 10;
char letter = 'C';
float marks = 85.5;
double avg = 92.3456;

Each variable:

  • Has a type
  • Uses specific memory
  • Supports type-specific operations

Key Expert Insights

  • Data types define memory allocation
  • They ensure type safety
  • Correct data type choice improves performance
  • Wrong data type can cause overflow or precision loss

One-Line Exam Answer

Data types in C specify the type of data a variable can store and determine the amount of memory allocated for it.