PROGRAMINING
CHAPTER # 01:
A
Procedural Programming (POP)
H
ES
What it is:
Procedural programming is a way of writing code where you solve problems step by step using
functions.
AY
Idea:
“Do this → then this → then this”
BY
Example (real life):
Making tea
S
TE
1. Boil water
2. Add tea leaves
3. Add sugar
4. Pour into cup
O
Each step = a function
N
Key Features:
S
● Uses functions (procedures)
● Follows top-to-bottom execution
C
● Data and functions are separate
● Simple and easy for small programs
BS
CODE:
void makeTea() {
boilWater();
addTea();
, addSugar();
}
Object-Oriented Programming (OOP)
What it is:
OOP is a way of programming where you organize code using objects and classes.
A
H
Idea:
ES
“Group data + functions together”
Example (real life):
AY
Think of a Car
Car = Object
●
●
Data: color, speed
Functions: drive(), brake()
BY
Key Features:
S
● Uses Classes & Objects
● Encapsulation (data is protected)
TE
● Inheritance (reuse code)
● Polymorphism (same function, different behavior)
Everything related is grouped together
O
DIFFERENCE
N
Procedural Object-Oriented Programming
S
1.it is main focus in the function 1 it is used to make the classes and object
C
BS
2.It work step by step execution 2.it is work real world modelingIt
3.It divided into the function 3. it divided into object
4.Data and functions work separately 4. data and function are combined
5.It is less secure 5. it is more secure in data hiding
6.It reusability is limited 6. it has high inheritance
7.It have less flexible 7. it is more flexible
,8.It is good from small programs 8. it is best from large program
Example Example
C,pascal c++,java,python
CLASS AND OBJECT
A
What is a Class?
H
A Class is like a blueprint (design)
ES
Think like this:
If you want to build a house. You first create a map/design.
AY
That design = Class
Example:
BY
Class = Car
It defines:
S
● Color
TE
● Speed
● Functions like drive(), brake()
O
But it’s just a design… not a real car yet
N
What is an Object?
S
An Object is the real thing created from a class
C
Think like this:
BS
Using the house design, you build a real house
That real house = Object
EXAMPLE
Class:
Student
, Objects:
● Ali (Roll no: 1, Age: 18)
● Ahmed (Roll no: 2, Age: 19)
Real students = objects
What are Access Modifiers?
A
Access Modifiers control who can use your data or methods in a program
H
ES
Simple idea:
“Who is allowed to see or use this?”
AY
Real-Life Example
Think of a house BY
● Public → Anyone can enter
● Private → Only you can enter your room
● Protected → Only family members can enter
● Default → Only people in the same house
S
TE
Why Important?
1. Protects your data
O
2. Prevents misuse
3. Makes code secure and clean
N
Types of Access Modifiers
S
C
1. Public
BS
Accessible from anywhere
public int age;
Anyone can use it
2. Private