Professional Documents
Culture Documents
Question 1
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]
(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
Member functions:
void fill( ) : to fill the elements of the array with the first (m x n) composite numbers.
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