Jawaharlal Nehru Engineering College: Department of Information Technology
Jawaharlal Nehru Engineering College: Department of Information Technology
Lab Book
BTITL307: Object Oriented Paradigm with C++
Name: ________________________________________________
Lab Book
BTITL307: Object Oriented Paradigm with C++
To develop expertise of budding technocrats by imparting technical knowledge and human value
based education.
A. Equipping the students with technical skills, soft skills and professional attitude.
B. Providing the state of art facilities to the students to excel as competent professionals,
entrepreneurs and researchers.
PEO1. The graduates will utilize their expertise in IT industry and solve industry technological
problems.
PEO2. Graduates should excel in engineering positions in industry and other organizations that
emphasize design & implementation of IT applications.
PEO3. Graduates will be innovators & professionals in technology development, deployment
& system implementation.
PEO4. Graduates will be pioneers in engineering, engineering management, research and higher
education.
PEO5. Graduates will be good citizens & cultured human being with full appreciation of
importance of IT professional ethical & social responsibilities.
• PSO1. An ability to design, develop and implement computer programs in the areas
related to Algorithms, Multimedia, Website Design, System Software, DBMS and
Networking.
• PSO2. Develop software systems that would perform tasks related to Research,
Education and Training and/or E governance.
• PSO3. Design, develop, test and maintain application software that would perform tasks
related to information management and mobiles by utilizing new technologies to an
individual or organizations.
Lab outcomes: After the completion of this course students will be able to,
LO1: Set up the environment to write, compile and execute C++ programs.
LO2: Learn and develop structures to represent objects and the methods to perform operations
for a problem.
LO3: Apply object-oriented programming paradigms (standards and principles) to write program
for a given problem.
LO4: Understand and demonstrate usage of the object-oriented concepts like inheritance,
polymorphism, overloading, files etc.
LO5: Develop debug and correct the errors of a program to produce desired output.
1. Students should report to the concerned labs as per the given timetable.
2. Students should make an entry in the log book whenever they enter the labs during
practical or for their own personal work.
3. When the experiment is completed, students should shut down the computers and make
the counter entry in the logbook.
4. Any damage to the lab computers will be viewed seriously.
5. Students should not leave the lab without concerned faculty’s permission.
Mahatma Gandhi Mission
The internal architectural design of computers differs from one system model to another.
However, the basic organization remains the same for all computer systems. In order for a
computer system to operate, it requires a few key hardware components, the most important of
these being the Central Processing Unit (CPU) and the motherboard. The motherboard acts as
the central "hub" on which all of the computer's various hardware peripherals, ranging from
sound and video cards to hard drives, connect. The primary power source for the computer
connects to the motherboard, which then distributes power to the hardware connected to it.
1
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
Practice Exercise 1
The following entities or devices are part of a computer system’s hardware (H) or Software (S)?
2
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
Answer:
4. The process of drawing a flowchart for an algorithm is called __________
a) Performance
b) Evaluation
c) Algorithmic Representation
d) Flowcharting
Answer:
5. In flow chart, diamond shaped symbol is used to represent
a) Decision box
b) Statement box
c) Error box
d) if-statement box
6. Part of algorithm which is repeated for fixed number of times is classified as
a) iteration
b) selection
c) sequence
d) reverse action
3
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
DOS Commands
DOS (Disk Operating System) is an operating system that runs from a hard disk drive. The term
can also refer to a particular family of disk operating systems, most commonly MS-
DOS (Microsoft Disk Operating System).
DOS commands are small programs, which are made to perform a particular job. Every DOS
command performs different task. It is not possible to work on the computer without these
commands. There are two types of DOS command.
Internal Commands: These commands enter into the computer memory during computer
booting. These commands are not in the form of any file; so neither they can be viewed nor can
be edited or detected.
External Commands: These commands are stored in the computer list in the form of files.
These Commands can be viewed, copied, changed or deleted.
For example: FORMAT, COPY, PRINT, SYS, EDIT, TREE, SORT, PROMPT etc.
DOS commands are the commands available in MS-DOS that are used to interact with
the operating system and other command line based software.
Unlike in Windows, DOS commands are the primary way in which you use the operating
system. Windows and other modern OSs use a graphics-based system designed for touch or
a mouse.
DOS Commands in Windows: If you use Windows (like Windows 10, 8, 7, etc.) then you
have no need for DOS commands because you don't have MS-DOS. The commands in
Windows are available from the Command Prompt and are called Command Prompt commands
or CMD commands, but they are not DOS commands.
Linux Commands
Linux is a Unix-Like operating system. All the Linux/Unix commands are run in the terminal
provided by the Linux system. This terminal is just like command prompt of Windows OS.
Linux/Unix commands are case-sensitive. The terminal can be used to accomplish all
Administrative tasks. This includes package installation, file manipulation, and user
management. Linux terminal is user-interactive. The terminal outputs the results of commands
which are specified by the user itself. Execution of typed command is done only after you press
the Enter key.
4
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
MS-
Command's Purpose Linux Basic Linux Example
DOS
Copies files copy cp cp thisfile.txt /home/thisdirectory
Moves files move mv mv thisfile.txt /home/thisdirectory
Lists files dir ls ls
Clears screen cls clear clear
Closes shell prompt exit exit exit
Displays or sets date date date date
Deletes files del rm rm thisfile.txt
"Echoes" output to the
echo echo echo this message
screen
Edits text files edit gedit gedit thisfile.txt
Compares the contents of
fc diff diff file1 file2
files
Finds a string of text in a
find grep grep word or phrase thisfile.txt
file
format /sbin/mke2fs /dev/fd0 (/dev/fd0 is
Formats a diskette mke2fs
E: the Linux equivalent of A:)
comm
Displays command help man or info man command
and /?
Creates a directory mkdir mkdir mkdir directory
Views contents of a file more less less thisfile.txt
Renames a file ren mv mv thisfile.txt thatfile.txt
Displays your location in
chdir pwd pwd
the file system
Changes directories with
cd pat
a specified path (absolute cd pathname cd /directory/directory
hname
path)
Changes directories with
cd.. cd .. cd ..
a relative path
Displays the time time date date
Shows amount of RAM in
mem free free
use
Practice Exercise 2
5
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
d) Command
Answer:
5. If you need to duplicate the entire disk, which command will you use?
a) Copy
b) Diskcopy
c) Chkdsk
d) Format
Answer:
Grade: Signature of teacher:
6
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
Online IDE: IDE is Integrated Development Environment. It is a software application that can
be used for developing software. Many online IDEs are available which can be used to compile
and run C++ programs.
How to setup Local Environment: To setup a local development environment, install two
software:
1. Text Editor: Text Editors are the programs used to edit or write programs. For writing
C++ programs, we will use text-editors. The usual extension of a text file is (.txt) but for
a text file having C++ program needs to be saved with ‘.CPP’ or ‘.C’ extension. These
files are source code files. To start writing programs in C++, we should have a text-editor
installed to write programs.
2. C++ Compiler: After writing a C++ program (‘.CPP’ extension), we require a C++
compiler to compile this file.
A compiler is a computer program which converts high-level language (source-code) into
machine understandable low-level language. In other words we can say that it converts
the source code written in a programming language into another computer language which
computer understands. For compiling a C++ program we will need a C++ compiler which
will convert the source code written in C++ into machine codes. Below is the details about
setting up compiler on different platforms.
2.1 For Linux based systems: We can install the GNU GCC compiler on Linux. To
install and work with the GCC compiler on your Linux machine, following steps:
i. Run the two commands from your Linux terminal window:
7
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
iii. Now Linux environment is set up and can be used to compile C++ programs.
iv. Next step is to understand how to compile and run a C++ program.
Write program using a text editor and save it with any file name having
.CPP extension.
Next step is to open the Linux terminal and change to the directory where
.CPP file is saved. Use the following command to compile file:
$ g++ filename.cpp -o any-name
Here, filename.cpp is the name of the source code file and any-name is the file
name to be assigned to executable file. Executable file is created by compiler
post compilation. Run the command as:
$ g++ testfile.cpp -o testfile
v. The last step creates a new file in the same directory where we have saved the
source file and this new file is named as testfile.
vi. Next step is to run the program using following command:
$ ./testfile
This command will run the program in the terminal window.
2.2 For Windows based systems: A large number of IDE are available for Windows
OS to work with C++ programming language. The most popular IDE is Code::Blocks.
Download Code::Blocks and install.
8
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
Practice Exercise 3
Write a C++ program to write and display an essay on you. Write your introduction including
family background, strengths, weakness, future plan.
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
9
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
Algorithm:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
10
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Program:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
11
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
___________________________________________________________________________
___________________________________________________________________________
__________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Input:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Output:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
12
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
13
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
14
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Algorithm:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
15
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
Program:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
16
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
Input:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Output:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
17
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
18
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
Algorithm:
19
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Program:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
20
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Input:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Output:
21
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
22
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
23
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
Algorithm:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
24
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Program:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
25
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Input:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Output:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
26
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
27
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
28
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
Algorithm:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Program:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
29
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Input:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Output:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
30
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
31
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
32
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
Algorithm:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Program:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
33
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Input:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Output:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
34
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
35
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
Write a program that creates a binary file by reading the data for the students from the terminal.
The data of each student consist of roll number, name (a string of 30 or lesser number of
characters) and marks.
Algorithm:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
36
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Program:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
37
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Input:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Output:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
38
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
39
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
A hospital wants to create a database regarding its indoor patients. The information to store
include:
Name of the patient
Date of admission
Disease
Date of discharge
Create a structure to store the date (year, month and date as its members). Create a base class
to store the above information. The member function should include functions to enter
information and display a list of all the patients in the database. Create a derived class to store
the age of the patients. List the information about all the patients to store the age of the patients.
List the information about all the paediatric patients (less than twelve years in age).
40
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
Algorithm:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Program:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
41
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Input:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Output:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
42
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
43
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
Imagine a tollbooth with a class called toll Booth. The two data items are a type unsigned int to
hold the total number of cars, and a type double to hold the total amount of money collected. A
constructor initializes both these to 0. A member function called payingCar( ) increments the
car total and adds 0.50 to the cash total. Another function called nopayCar( ), increments the
car total but adds nothing to the cash total. Finally, a member function called display() displays
the two totals i.e. total cars and total cash. Include a program to test this class. This program
should allow the user to push one key to count a paying car, and another to count a nonpaying
car. Pushing the ESC key should cause the program to print out the total cars and total cash and
then exit.
Algorithm:
___________________________________________________________________________
___________________________________________________________________________
44
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Program:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
45
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Input:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
Output:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
46
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
47
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
Appendix A
Program Outcomes
48
______________________________ Practical Workbook: Object Oriented Paradigm with C++ Lab
11. Project management and finance: Demonstrate knowledge and understanding of the
engineering and management principles and apply these to one’s own work, as a
member and leader in a team, to manage projects and in multidisciplinary environments.
12. Life-long learning: Recognize the need for, and have the preparation and ability to
engage in independent and life-long learning in the broadest context of technological
change.
PSO1. An ability to design, develop and implement computer programs in the areas related to
Algorithms, Multimedia, Website Design, System Software, DBMS and Networking.
PSO2. Develop software systems that would perform tasks related to Research, Education and
Training and/or E governance.
PSO3. Design, develop, test and maintain application software that would perform tasks related
to information management and mobiles by utilizing new technologies to an individual
or organizations.
49