# Mumbai University Previous year question papers

Table of Contents

## Computer Programming-II

N.S. (1) Question NO.1 is compulsory.

(2) Attempt any four  questions out of remaining six questions.

(3) Answers to a main question shall be grouped  and written together.

1. (a) Explain storage class with one programming example.

(b)  Write a program to reverse the digits of a positive integer number for example, if the number 8735 is entered, the number dispalyed should be 5378.

(Hint: Use a do statement and continusoly strip off and display the units digit of the number. If the variable num initially contains the number entered, the units digit is obtained as (num% 10). After a units digit is displayed, dividing the number by sets up the number for the next iteration. Thus (8735% 10) is 5 and (8735/10) is 873. The do statement should continue as long as the remaining number is not zero.

2. (a) What is hybrid inheritance? What are the problems in it? How it is resolved? Give one programming example.

(b) Write a program to reverse a sentence (do not reverse the words).

3. (a) . Writea programto shift the elementsof a singledimensionalarray in the rightdirection by one position. If the given array is [76 35 43 22] then after execution of the program it should be [22 76 35 43].

(b) Write a program to find LCM and GOD of two non-negative integers.

4.(a) Define a structure “Hockey” consisting of following elements

i) Player name

(ii) Name of the country

(iii) Number of matches played

(iv) Number of Goals scored.

Write a program to read records of ‘N’ players and to prepare following lists:

(i) List prepared according to player’s name.

(ii) List prepared according to country’s name.

(iii) List prepared according to number of matches played.

(iv) List prepared according to number of goals scored.

(b) What is the difference between declaration and definition?

5.(a) What is the output of the following program?

# include < io stream.h >

int main ( )

{

int b = 3, a = 2, ab = 4 ;

int i ;

int in = ‘2’ * ‘2’ ;

char ch = ‘c’ ;

cout « ch « ” ” « (++ ch) « endl ;

cout « a « ” ” « a « ” ” « (++a) « end I ;

Gout « b « ” ” « b « ” ” « (++ b) « endl ;

Gout « ab « “” « ab « ” ” « (++ ab) « endL;

Gout « a « ” ” « !! a ;

return 0 ;

(b)Write a program to read elements of a square matrix and to transpose the matrix. Use single two dimensional array.

6.(a) What is copy constructor? Give one programming example of it.

(b) Write a program to find value of y using recursive function, where y = xn, x & yare real number & ‘n’ is an integer.

7. (a) Write a program to find how many objects of a class has been created using static member function.

(b) Write a program to find area of circle, area or reactangle and area of triangle lI.~jl)aov.er.loaded constructor function.