Sie sind auf Seite 1von 4

MCA Part-II, 1st Semester Examination, 2010

Subject: Computer Application


Paper: Object Oriented Programming Lab (301L)
Date: 30.06.2010

1. Write a program in C++ to get the following display pattern.

ABCDEFEDCBA
ABCDE EDCBA
ABCD DCBA
ABC CBA
AB BA
A A

2. Construct a class AREA with requisite data members. Write a C++ program using
appropriate member functions to calculate the area of rectangle, triangle & circle using
function overloading.

3. Write a program in C++ using class to implement Push & Pop operations of Stack.

4. Construct a class MATRIX with requisite data members. Write a in C++ program using
appropriate member functions to add, subtract & multiply two given matrices by
overloading the operators +, -, *.

5. Write a program in C++ to concatenate two text files “a.txt” and “b.txt” in memory.

6. In an office all the staffs get Basic and HRA but managers get additional allowance. The
office has branches in Kolkata, Delhi and Dargeeling. In Kolkata office all the staffs get
special allowance, in Delhi city allowance and in Darjeeling hill allowance.
Write a program in C++ to get data and show the data for each branches.

7. Write a program in C++ implementing hybrid inheritance.

8. Construct a class TIME having three data members for hours , minutes, seconds and some
member functions. One constructor should initialize these data members to 0 and another
should initialize those to fixed values.

Write a member function to display time in the format 12:28:35 and another member function
to add two TIME objects and hence develop a program in C++ to add two given TIME objects.
9 (i)
#include<iostream.h>
.
.
.
main(){
A x (5), y;
B z (2);
}
Design classes A and B giving the values as x=2,y=14,z=16 where x & y are data member of
class A and z is the data member of class B.

(ii) Write a program in C that replaces two or more consecutive blanks in a


string by a single blank.
For example, if the input is:
Grim return to the planet of apes!!
the output should be :
Grim return to the planet of apes!!

10. Imagine a company that markets both book and audio-cassette. Create a class publication
that stores the title (a string) and price (type float ) of a publication. From this class derive
two classes: book, which adds a page count (type int) and tape, which adds a playing time
in minutes (type float). Each of these three classes should have a getdata () function to get
its data from the user at the keyboard and putdata () function to display its data. Write a
main () program to test book and tape classes by creating instances of them, asking the
user to fill their data with getdata () and then displaying the data with putdata ().

11. Write a program to read a list containing item name, item code, and cost
interactively and produce a three column output as shown below.

NAME CODE COST


-------------------------------------------------------------------------------
Turbo C++ 1001 250.95
C Primer 905 95.70
…… …… ………
…… …… ………
…… …… ……....
---------------------------------------------------------------------------------
Note that the name and code are left-justified and the cost is right-justified
with a precision of two digits.
12. A file contains a list of telephone numbers in the following form::

Mohit 25775973
Aditya 23518496

……..
……..
The name contain only one word and the names and telephone numbers are separated by white
spaces. Write a program to read the file and output the list in two columns. The names should be
left-justified and the numbers right-justified.

13. Write a program in C+ to compare and concatenate two strings.

14. Write a program in C+ to allow the statement S1 += S2 using += operator; where S2 is added
(concatenated) to S1 and the result left in S1. The operator should also permit the result of the
operation to be used in other calculation, as in S3=S1+=S2.

15. Create two text files COUNTRY and CAPITAL. COUNTRY file contains name of at least five
countries and CAPITAL file contains names of the corresponding capitals. Write a program in C++ to
get the output in the following form:

The Capital of India is New Delhi


and so for other.

16. Write a program to calculate the scalar product of two vectors using operator
overloading and template.

17. Write a menu driven program to implement a Calculator.

18. WAP in C++ to add an compare two string using operator overloading.

19. WAP in C++ to read a text file and replace all blanks by two consecutive blanks and first letter of
each letter will be in upper case.

20 WAP in C++ to add, subtract and multiply two given matrices by operator overloading.

21. Write a program in C++ to concatenate two text files “a.txt” and “b.txt” in memory using command
line arguments.

22. Write a program in C++ to read a test file. In the output file all the blanks should be replaced by
two consecutive blanks and the first letter of each word should be in upper case.
23. Write a program in C++ to count the number of lines, blank space and character of a given
file.

24. Construct a class TRAINGLE with requisite data members. Write a C++ program using
appropriate member functions to test as whether a triangle can be
formed or not with supplied sides. Also write appropriate member functions to test as whether a
triangle is an equilateral triangle or an isosceles triangle.

Das könnte Ihnen auch gefallen