Professional Documents
Culture Documents
STUDENT INFORMATION:
Note: Provide the following information (Use capital letters).
Student ID 0000
Group # in OOP1 000
___________________________________________________________________
SPECIAL INSTRUCTIONS:
1. Negative Points: 2 points will be deducted from the total points in the following cases
Incomplete, Incorrect, unclear Student Information.
Final Answers written with Pencil.
2. All answers should be written in the space provided for each question.
3. Calculators are not allowed.
4. Exchange of any object including eraser, pen, ruler etc. is strictly forbidden during exam.
3
Student ID: U16____________
Q. 1 Write the correct choice (the most appropriate answer) in the table given below. [1x15 Point]
Q# 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Answer
1. When we pass two-dimensional array parameters to function, Size of first dimension of array is not required but Size
of second dimension is required.
a. True b.False
3. Which one of following convenient for situations in which the “same” function is needed for different numbers or
types of arguments
a. Inline function b. Function overloading
c. Recursive function d. Default argument
5. Name of an array is
a. A constant pointer b. Address of the first element of array
c. A non-constant pointer d. Both a and b
6. Life time of an automatic storage class is the execution time of local function in which it is declared.
a. True b. False
4
Student ID: U16____________
13. Which of the following operator use to access members (fields) of structure.
a. ; (Semicolon) b. . (Dot)
c. : (colon) d. , (coma)
15. Which of the following is the correct way of declaring a three dimensional array (2x3x4 dimensions)
a. int array[[3][4]] b. int array[2, 3, 4]
c. int array[2][3][4] d. int array[2,3][4]
5
Student ID: U16____________
Q. 2. Write the OUTPUT of the following Code, if there is any Syntax Error, mention the error.
[15 Points]
III. [1 points]
I. [2 Points]
Output: 7 9 11
Output:
A IV.
of the following pointer/array operations are invalid [2 P
U
II. [2 points]
Output:
Invalid Operations:
//p2=&a;
//*p1=*p2;
//*p1=10;
//p2++;
6
Student ID: U16____________
//array++;
V. [1 Points]
Output:
Output: Line # 9:__________________
Line # 10:_______1
Line # 12:__________________
VII. [3 points]
7
Student ID: U16____________
Output:
Line # 29:__________________23
Line # 31:__________________32
Line # 33:__________________23
8
Q. 3. Write function definitions for the following function. [15 Points]
Note: Choose appropriate data types for the arguments and return type, and use constant (const), wherever
required.
1. Write a function that takes a string as parameter, and replace Lowercase characters in the string by Uppercase
and Uppercase by lowercase. [5 Points]
Example: String “INHA Tashkent123” replace to “inha tASHKENT123”
2. Write a recursive function POWER( base, exponent) that takes base and exponent as parameters and return
baseexponent
Assume that exponent is an integer greater than or equal to 1. [5 Points]
Hint: base case: base1 = base
3. Write a function that takes two dimension array of size 3x3 (rows x column), and return the sum of its
diagonal elements. [5 points]
Hint: Sum of the diagonal elements for the matrix given below is: 1+2+0=3
Q. 4. Write a C++ program that multiply two 3x3 matrices. The program should include the following functions. [15
Points]
InputMatrix(): Takes the elements of a two dimensional matrix from the user. [3points]
DisplayMatrix(): Display the elements of a two dimensional matrix. [3 points]
MultiplyMatrices(): Multiply two matrices, store the result in a 3rd matrix. [6 points]
Call these functions in the appropriate order to take input matrices, multiply it and display the result. [3 Points]