CPP - Lab Manual 1 - Basics of OOP
CPP - Lab Manual 1 - Basics of OOP
HISTORY OF C++
C++ extensions of C were first invented by Bjarne Stroustrup in 1979 and it was called C with
classes, became C++ in 83. First revision 1985, Second revision 1990, Third revision 1994
(ISO standardization is an international organization for standardization) C++ is used by
hundreds of thousands of programmers in essentially every application domain.
C++ is being highly used to write device drivers and other software that rely on direct
manipulation of hardware under real-time constraints. C++ is an Object Oriented Programming
(OOP) Language. OOP is an approach that provides a way of modularizing programs by creating
partitioned memory area for both data & functions that can be used as templates for creating
copies of such modules on demand.
PROCEDURAL vs. OBJECT ORIENTED PROGRAMMING
Procedural programming is a programming paradigm, derived from structured programming,
based upon the concept of the procedure call. Procedures, also known as routines, subroutines,
methods, or functions.
Object-oriented programming (OOP) is an approach to problem-solving where all
computations are carried out using objects. An object is a component of a program that knows
how to perform certain actions and how to interact with other elements of the program.
PILLARS OF OOP DEVELOPMENT
Encapsulation (data hiding): The wrapping of data & functions together is known as
encapsulation.
Abstraction: Prevention of data accessing of a class for other class objects is known as data
abstraction.
Inheritance: A mechanism that helps objects of one class to inherit properties from objects
of other class. Inheritance supports re-usability.
Polymorphism: A same action can cause different reaction from different objects.
LAB EXERCISE
EXERCISE: 1
Write a program that ask for a name and say hello to the name.
EXERCISE: 2
Create a directory (folder) called "Arithmetic_Calculation". Inside this directory, create a
program file called "Arithmetic.cpp", save the file, write the solution of following problems,
compile it, and run it.
Write a program that takes two input from the keyboard separately by displaying the following
text in the monitor and asking for Insert Number 1: and put this number into a variable n.
Then display Insert Number 2: in the monitor and ask for number 2 for variable m. Then
perform addition, subtraction, multiplication, and division from the stored number of variable n
to the stored number of variable m and display the arithmetic results each time.
EXERCISE: 3
Write a program that takes three numbers 51, 72 and 90 from the keyboard, calculate and display
the according grades against these numbers (grading criteria, A is 90 to100, B is from 80 to 89
and C is from 70 to 79, bellow 70 is F), display the evaluation of these grading as A is Excellent
B is Very Good, C is Good and F is Better Try Next Time