Professional Documents
Culture Documents
CPP Questions Bank
CPP Questions Bank
MCA –I SEMESTER – I
SUBJECT: Problem Solving using C++
Question Bank
1 Explain algorithm on tower of Hanoi
2 Write a pseudo code to perform addition of two matrices. Also find time and space
complexity.
3 Write pseudo code to sum of n natural numbers. Also calculate the time and space
complexity for it.
4 Write a pseudo code factorial of given number. Also calculate the time and space
complexity for it.
5 Write a pseudo code for divide and conquer algorithm for binary search. Search the
item 23 in the array A= {1, 5, 7, 8, 13, 19, 20, 23, 29}
N=7
M=15
Objects: 1 2 3 4 5 6 7
Profit: 10 5 15 7 6 18 3
Weights: 2 3 5 7 1 4 1
12 Write a program to find area of square, rectangle, circle and triangle using function
overloading.
16 Explain memory management operators new and delete with suitable example
17 Write a program to swap private data members of two classes using friend function.
18 What is inline function? Explain with suitable example. Also explain Merits and
demerits of it.
22 Create a class String that will store array of characters provides suitable constructors
and overloaded the following operators.
23 Accept date 'D' in DD-MM-YYYY format and an integer number 'n' from keyboard.
Write a program to overload - (minus) operators which give the date difference
between two dates also validate date, month and year. 'D', in DD-MM-YYYY
format.
24 Create a class cricket having data members player ID, player name, no. of inning,
total runs, number of fifties and number of centuries. Add necessary member
functions in it. Write a c++ program to accept the complete information of player
from the user. Calculate its average of runs and display all information.
Overload insertion << and extraction >> operators to accept and display
information.
26 Create the class Time with data members hours and minutes. Write a program that
can read values for the two objects. The Time class also contains one friend function
add(Time, Time). It required two objects as arguments and return object as result of
addition. Use constructor to initialize the Time class objects.
Data members:
Member functions:
28 Create a class Person with data members PCode and PName. Derive two classes
Account and Official from Person. Class Account contains members as Acno and
balance, while Official class contains members designation and experience. Further
derive another class Employee from both Account and Official classes. Write C++
program to create and display information of the Employee. Use Concept of Virtual
Base Class to implement Hybrid Inheritance.
29 Create a class employee with data members emp_no, emp_name and basic_sal.
Derive a class officer from employee who gets additional travelling allowance (10%
of basic). Derive a class manager from officer who gets a special children education
allowance (Rs. 5000/-). Write the necessary member functions to accept and display
details. Write a function in each class which displays the total salary
30 Create a class student (rollno, name). Derive two classes science (maths, physics,
computer) and commerce (account, stats). Accept details of 10 students
dynamically, they could be science or commerce students. Display the details of all
students in same order of acceptance.
32 Illustrate virtual function with sample program. What is pure virtual function?