You are on page 1of 2

The Lucknow Public Collegiate

Online Periodic Test 3


Class: XII (ISC)
COMPUTER SCIENCE

Time: 1hrs M.M: 25

Question 1

(a) Complement the following : [2]


(x+y’).y.z’+x’z(y+x’.y)
(b) Convert the following expression F (X,Y,Z) =X’+Y’Z into canonical SOP form. [2]
(c) Convert the following infix notation to postfix: [2]
A* (B/C+D)*E-(F+G-H)
(d) Each element of an array arr[15][20] requires ‘W’ bytes of storage. If the address of
arr[6][8] is 4580 and the Base Address at arr[1][1] is 4000, find the width ‘W’of each cell
in the array arr[][] when the array is stored as Row Major Wise. [3]

Question 2

(a) The following function recur() and someRecur( ) are a part of some class. Give the
output when the function someRecur( ) is called. Show the dry run/ working.

int recur(int n)
{
if(n>1)
return (n*recur(n-1));

else return 1;
}
int someRecur(int m)
{
if(m==0)
return 0;
else
return recur(m%10)+someRecur(m/10);

}
(i)What will the function someRecur(145) return? [2]

(ii)What will the function someRecur(101)return? [2]

(iii) For what purpose are the two functions used together? [2]

Question 3

Design a class Composite to fill an array of order [m x n] with the first [m x n] composite

numbers column wise. The details of the members of the class are given below:
Class name: Composite

Data members/ instance variables:

arr[ ] [ ] : Two dimensional array.

m : integer to store the number of rows.

n : integer to store the number of columns.

Member functions:

Composite( ) : to accept the size of the array.

int isComposite( int p) : return 1 if number is composite and 0 if not composite.

void fill( ) : to fill the elements of the array with the first (m x n) composite numbers.

void display( ) : displays the array in a matrix form.

Specify the class Composite giving details of the constructor and member functions int

isComposite(int), void fill( ) and void display( ) with main( ) function to create an

object and call the function accordingly. [10]

You might also like