C Numeric Data Types

C Numeric Data Types (Complete Guide: Beginner → Advanced)
In C language, numeric data types are used to store numbers.
They are broadly classified into integer types and floating-point types and are very important for memory usage, performance, and interviews.
Classification of Numeric Data Types
C numeric data types are divided into two main categories:
Integer Types (Whole numbers)
charintshort intlong intlong long intunsignedvariants
Floating-Point Types (Decimal numbers)
floatdoublelong double
Integer Data Types
char (Numeric use)
Size: 1 byte
Range:
signed char: −128 to 127unsigned char: 0 to 255
- Often used for byte-level data & ASCII values
int
Size: 4 bytes (usually)
Range: −2,147,483,648 to 2,147,483,647
- Most commonly used numeric type
short int
Size: 2 bytes
Range: −32,768 to 32,767
- Saves memory
long int
Size: 4 or 8 bytes (system dependent)
Used for large integer values
long long int
Size: 8 bytes
Very large integer range
- Used in competitive programming & finance
Unsigned Integer Types
Used to store only positive values (double the range).
| Type | Range |
|---|---|
unsigned char | 0 to 255 |
unsigned int | 0 to ~4.29 billion |
unsigned long | Very large |
- Cannot store negative numbers
Floating-Point Data Types
float
Size: 4 bytes
Precision: ~6–7 digits
- Faster, uses less memory
- Less accurate
double (Most Used)
Size: 8 bytes
Precision: ~15 digits
- Best balance of speed & accuracy
long double
Size: 10–16 bytes (platform dependent)
Highest precision
- Used in scientific calculations
Size of Numeric Data Types (Example)
Integer vs Floating-Point (Comparison)
| Feature | Integer | Floating |
|---|---|---|
| Decimal values | No | Yes |
| Precision | Exact | Approximate |
| Speed | Faster | Slower |
| Memory | Less | More |
Numeric Type Conversion
- Type casting avoids integer division errors
Common Mistakes
- Using
floatfor money - Overflow with
int Using signed when unsigned is needed- Assuming same size on all systems
Interview Questions (Must Prepare)
Difference between
int,long, andlong longWhat is unsigned data type?
Size of
intin C?Difference between
floatanddoubleWhy
doubleis preferred overfloat?What happens on integer overflow?
Real-Life Use Cases
Counters & indexes →
intFinancial values →
long long/ integersScientific calculations →
double,long doubleEmbedded systems →
short,unsigned
Summary
- Numeric data types store numbers
- Integers → whole numbers
- Floating types → decimal numbers
doubleis most commonly used- Unsigned types increase positive range
- Crucial for performance, accuracy & interviews
