Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

SINHGAD INSTITUTE OF MANAGEMENT, PUNE – 41

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}

6 Define and write Greedy Algorithm.

Solve the following knapsack problem

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

7 Write an algorithm for merge sort. Sort the following elements


{423,365,276,786,587,911,388,600,38}

8 Write an algorithm to explain tower Tic-tac-toe

9 Explain any five manipulators with suitable examples

10 Design a manipulator for displaying CURRENCY to provide following output


specifications for printing float value. 10 cols width, right justified, two digits
precision, fill unused spaces with $, show trailing zeros.

11 Design a manipulator for displaying RESULT with respective following


specifications. Width for each column will be 10, SubCode, SubjectName left
justified and remaining columns would be right justified, 2 digits precision marks,
fill unused space with ‘#’.

12 Write a program to find area of square, rectangle, circle and triangle using function

SIOM, CPP Question Bank Page 1


SINHGAD INSTITUTE OF MANAGEMENT, PUNE – 41

overloading.

13 Describe Function overloading. Write a C++ program to calculate area of different


shapes (circle, triangle, square).

14 What is default argument? Explain with suitable example

15 Write a program to demonstrate default argument and constant argument for a


function

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.

19 What is Friend Function? Write a program to accept Student information, write a


friend function RESULT (Student obj). Also write a code for getdata() and putdata()
function

20 Write a program to illustrate pointers to data members and pointer to objects

21 Write a C++ program to design a class COMPLEX and overload following


operators

pre increment, post increment operators (++)

pre decrement, post decrement operators (--)

22 Create a class String that will store array of characters provides suitable constructors
and overloaded the following operators.

Operator + to concatenate two strings.

Operator > =to compare two strings

Operator != to check inequality of two strings.

The Operator function is member function of class.

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.

e.g. if D=21-01-2019 & n=2 then function returns 19-01-2019

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

SIOM, CPP Question Bank Page 2


SINHGAD INSTITUTE OF MANAGEMENT, PUNE – 41

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.

Create array object for 11 players of team.

25 A company has following details of their employee.

i) Emp ID ii) Emp Name iii) Emp Address iv) Emp


Dept(Admin/Sales/Production/IT) v) Emp Phone vi) Emp age. Write a program to
read the 10 employees information, also write function to display department wise
employee as per user choice

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.

27 Define a class to represent employee. Include following

Data members:

Employee code,Employee Name ,Department ,Basic Salary

Employee count for computer department (Static Member variable)

Employee count for Management Department (Static Member variable)

Member functions:

To read employee details

To display employee data

To calculate net salary

To display employee count for computer and management department. (Static


member function)Write a main program to test the class for handling N
customers.

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%

SIOM, CPP Question Bank Page 3


SINHGAD INSTITUTE OF MANAGEMENT, PUNE – 41

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.

31 What is private inheritance? Explain protected inheritance with suitable example

32 Illustrate virtual function with sample program. What is pure virtual function?

SIOM, CPP Question Bank Page 4

You might also like