List of Programs
Subject Code: PCS-307 Subject: OOP Using C++ Programming Lab
1. Write a program in C++ to display the multiplication table vertically from 1 to n.
Sample Output:
Input the number upto: 5
Multiplication table from 1 to 5
1x1=1 2x1=2 3x1=3 4x1=4 5x1=5
1x2=2 2x2=4 3x2=6 4x2=8 5x2=10
1x3=3 2x3=6 3x3=9 4x3=12 5x3=15
1x4=4 2x4=8 3x4=12 4x4=16 5x4=20
1x5=5 2x5=10 3x5=15 4x5=20 5x5=25
1x6=6 2x6=12 3x6=18 4x6=24 5x6=30
1x7=7 2x7=14 3x7=21 4x7=28 5x7=35
1x8=8 2x8=16 3x8=24 4x8=32 5x8=40
1x9=9 2x9=18 3x9=27 4x9=36 5x9=45
1x10=10 2x10=20 3x10=30 4x10=40 5x10=50
2. Write a program in C++ to display the sum of the series [ 9 + 99 + 999 + 9999 ...]
Sample Output:
Input number of terms: 5
9 99 999 9999 99999
The sum of the Series = 111105
3. Write a C++ program to sort a given array of 0s, 1s and 2s. In the final array put all
0s first, then all 1s and all 2s in last.
4. Create a Java program to perform survey on four different model of Maruti
(Maruti -K10, Zen-Astelo, Wagnor, Maruti- SX4) owned by person living in four
metro cities(Delhi, Mumbai, Chennai & Kolkatta). Display tabulated report like
format given below:
Maruti- Zen-Astelo Wagnor Maruti-
K10 SX4
Delhi
Mumbai
Cheenai
Kolkatta
Calculate numbers of cars of different model in each metro city.
5. The daily maximum temperatures recorded in 5 cities during the month of January
(for all 31days) have been tabulated as follows:
Cities
Day Delhi Mumbai Kolkatta Chennai Dehradun
10
Write a program to read the table elements into a two-dimensional array
temperature, and to find the city and day corresponding to (a) the highest
temperature and (b) the lowest temperature.
6. Write C++ program to reverse each word of string.
e.g. Input- I love my India Output – I evol ym aidnI)
7. Write a C++ program to find the maximum occurring character in a string.
8. A class Telcall calculates the monthly phone bill of a consumer. Some of the members of
the class are given below:
Class name:
Data members/instance variable : phno(phone Number), sname(subscriber Name )
n(number of calls made) and amt (bill amount).
Member function/methods:
TelCall() : Parameterized constructor to assign values to data
members.
Void compute( ) : to calculate the phone bill amount base on the slabs given
below.
Void display( ) : to display the details in the specified format.
Number of calls Rate
1 – 100 Rs. 500/- rental charge only
101 – 200 Rs 1.00 per call + rental charge
201-300 Rs. 1.20 per call + rental charge
Above 300 Rs. 1.50 per call + rental charge
9. Design a class to represent bank account. Includes the following members:
Name of depositor
Account number
Type of account
Balance amount in the account
Methods:
To assign initial values
To deposit an amount
To withdraw an amount after checking balance.
To display the name and balance.
Write a program to incorporate the constructor to provide initial values.
10. Write a program to implement array of object.
11. Write a program to compare two objects using friend functions.
12 Create a class of Employ, in that considers their names, age, and employee code. In the same
class, create a - (subtract) overloading operator to find the age gap of two employees?
Example:
[Employ is a Class in C++]
Employ e1("Nitin", 30, "E001");
Employ e2("Amit", 25, "E002");
int diff = e1 - e2;
13. Write a program to count number of objects created for a class.
14. Write a C++ program to declare a class. Declare pointer to class. Initialize and display the
contents of the class member.
15. Write a C++ program to use scope resolution operator. Display the various values of the same
variables declared at different scope levels.