C: Data Types
C is a statically typed language, meaning you must specify the type of data a variable will hold upon declaration.
1. Basic Types
-
Integer Types
char: 1 byte (stores ASCII code values)int: 4 bytes (the most common integer type)short: 2 byteslong: 4–8 bytes
-
Floating-point Types
float: 4 bytes (approx. 6 decimal places)double: 8 bytes (approx. 15 decimal places, recommended)
2. Type Casting
A feature that manually overrides the data type of a value.
int a = 10, b = 3;
double result = (double)a / b; // Convert integer to double to obtain a precise result
note
You can check the memory size of a type or variable in bytes using the sizeof() operator.