CHAPTER 05 / 26
C Data Types
Understand the main C data types such as int, float, char and double.
01 — Syntax
int, char, float, double, void
02 — Example
#include <stdio.h>
int main() {
int a = 10;
float price = 12.5;
char grade = 'A';
printf("%d %.1f %c", a, price, grade);
return 0;
}03 — Important Points
- Choose a type that matches the data.
- int is common for whole numbers.
- float and double represent decimal values.
04 — Common Mistakes
- Using the wrong printf format specifier.
- Assuming all numeric types are identical.
05 — Real-World Use
Data types are important in embedded systems, numerical programs and memory-conscious software.
06 — Practice
Create a small program that demonstrates the main idea of C Data Types.