cpp3
cpp3
SESSION 3
Data Types
Data types specify the type of data a
interpret values.
Derived
User-defined
www.sinet.in 2
Primary (Fundamental) Data Types
1. int – Integer
Used for: Storing whole numbers without any decimal
point.
Memory size: Typically 4 bytes (can store -
2,147,483,648 to 2,147,483,647)
2. char – Character
Used for: Storing a single character.
numbers.
Memory size: 8 bytes
5. void – No Value
Used for: Indicating no data type.
Single
char 'A', '9' 1 byte
characters
Decimal
float numbers (less 3.14f, -0.5f 4 bytes
precise)
Decimal (more
double 6.022e23 8 bytes
precise)
No value (used
void void 0 bytes
in functions)
www.sinet.in 5
Type Modifiers
Type modifiers change the size or range of
the base data types like int and char.
🔸 Available Modifiers:
short
long
signed
unsigned
You can combine them with primary types like
int and char.
www.sinet.in 6
.
🔸 short int
Smaller range than int.
🔸 long int
Larger range than int.
🔸 unsigned int
Only stores non-negative numbers.
🔸 signed int
Default modifier (can store both positive and negative values).
www.sinet.in 7
Declaring Variables
🔸 What is a Variable?
A named storage location that holds data
which can be changed during program
execution.
Syntax:
data_type variable_name;
Eg: int age = 25;
www.sinet.in 8
Constants
🔸 What is a Constant?
www.sinet.in 9
Types of Constants
1. Integer Constants
Whole numbers (positive or negative).
No decimal.
2. Floating-Point Constants
Numbers with decimal point.
4. String Constants
A sequence of characters inside double
quotes.
Eg: const char message[] = "Welcome to C++!";
www.sinet.in 11
END
www.sinet.in 12