Data Types in C
A data type tells C what kind of value a variable will store. It also affects the operations that can be performed and the amount of memory used.
Basic data types
| Type | Stores | Example | Typical use |
| char | one character | char grade=’A’; | letters/symbols |
| int | whole number | int age=20; | count, age, marks |
| float | decimal value | float price=25.5f; | decimal values |
| double | more precision decimal | double pi=3.14159; | scientific/precise values |
| void | no value | void display(void); | functions with no return value |
Derived and user-defined types
- Array – stores multiple values of the same type.
- Pointer – stores an address in memory.
- Structure (struct) – groups related values of different types.
- Union – different members share the same memory area.
- Enumeration (enum) – creates named integer constants.
sizeof operator
| #include <stdio.h> int main() { |
The exact size of some types can depend on the compiler and platform, so sizeof is the correct way to check the size on your system.
| 📝 EXAM POINT: Do not assume every C data type has exactly the same size on every computer. |