You are on page 1of 20

PROGRAMMING Instructor:

Ms. Sadia Zar


CONCEPTS
ARRAYS
Write a C++ program to find minimum value from an array of 5
members.

Syntax:
int a[5];
SOLUTION
DRY RUN 2D ARRAY
OUTPUT:
ARRAYS
Self-Test 01:
Array Frequency Count: Implement a C++ program to
count the frequency of a given element in an array of
integers.
SOLUTION
USING A POINTER VARIABLE
2000
int x; 12
x = 12;
x

int* ptr; 3000


ptr = &x;
2000
ptr

NOTE: Because ptr holds the address of x, we say that ptr “points to”
x
USING A POINTER VARIABLE
WITH ARRAY
ARRAYS & POINTERS
Self-Test 02:
Provide output for following code segment?
OUTPUT:
FUNCTIONS
Write a C++ program to write a function named sum. Pass
two integer type values from main to function and return
the sum of numbers in main

1. Function Declaration void add(int, int);

2. Function Definition // function definition


void add(int a, int b) {
3. Function Call cout << (a + b);
}
TYPES OF FUNCTIONS
1. Standard Library Functions:
Predefined in C++
2. User-defined Function:
Created by users

Function Calling
SOLUTION
Object Oriented Programming
Techniques
PROGRAMMING PARADIGM
1. Procedural Programming
Structured/Modular Programming

2. Object Oriented
Programming
HISTORY
Difficult to code using Machine Language

After the invention of the microprocessor,


assembly languages flourished

• Importance to functions rather than data


• Functions and Modules
• Functions
• Used for medium-sized applications
• Data is global
• Security issues
HISTORY
▪ These programming constructs were developed in the late 1970s and
1980s
▪ Issues with well structured programs
▪ Over generalization
▪ Correlation problem
▪ Not suitable for real time applications
Solution:
Object Oriented Approach
OBJECT ORIENTED
APPROACH
▪ Revolution in the programming methodology field
▪ Generalization
▪ Real-time objects creation
▪ Results in more organized, reusable, and maintainable code
Languages:
▪ C++ (C with Classes)
▪ Java
▪ Python
▪ C#
OBJECT ORIENTED
PROGRAMMING
▪ OOP is centered around the object, which packages together both
the data and the functions that operate on the data
▪ Object-oriented programming (OOP) is a programming language
model organized around objects rather than "actions" and data
rather than logic
OOP TERMINOLOGY
▪ In OOP, an object’s member variables are often called its
attributes and its member functions are sometimes referred to as
its behaviors or methods
Any
Questions?

You might also like