XII C COMPUTER SCIENCE (JUNE 2014 MONTHLY RE TEST PAPER)
KENDRIYA VIDYALAYA NO. 1 , NAUSENABAUGH
, VSKP-05
XII C
COMPUTER SCIENCE (JUNE 2014
MONTHLY RE TEST)
Time Allowed : 90 Minutes
Note : All questions are compulsory.
1.Write a
function in C++ to return the element which is present maximum number of times
in an array . The function prototype is given below.
4M
int
MAX(int arr[], int size)
e.g : If the array is 2 4 2 4 2 4 2 4 2 4 2 2
4
then the function will return a value 2
2. Rewrite the following program after removing the
syntax error(s), if any. Underline each
correction4M
#include<iostream.h>
int main(){ struct student
{
int. rno, mark;
}stu;
student stuA= (1001,49);
student stuB= stuA;
if
(stuA!= stuB)
stuA.mark= 55;
else
stuB.mark= 25;
cout<<stuA.mark<<stub.mark;
}
3. Name the header files that shall be needed for the following
code: 2M
void main() {
int N, G;
randomize();
cin>>N;
G=random(N-5)+5;
cout<<G<<endl; getch();
}
4. Answer the questions (i) and (ii) after going
through the following program: 4M
class Match{
int Time;
public:
Match() //Function
1
{
Time=0;
cout<<”Match
commences”<<end1;
}
void
Details() //Function
2
{
cout<<”Inter
Section Basketball Match”<<end1;
}
Match(int Duration) //Function 3
{
Time=Duration;
cout<<”Another
Match begins now”<<end1;
}
Match(Match
&M) //Function 4
{
Time=M.Duration;
cout<<”Like
Previous Match ”<<end1;
}};
i)
Which category of constructor - Function 4 belongs
to and what is the purpose of using it?
ii)
Write statements that would call the member
Functions 1 and 3
5. Define a class FLIGHT in C++ with
following description: 4M
Private
Members
·
A data member Flight number of type integer
·
A data member Destination of type string
·
A data member Distance of type float
·
A data member Fuel of type float
·
A member function CALFUEL() to calculate the value
of Fuel as per the following criteria
Distance Fuel
<=1000 500
more
than 1000 and <=2000 1100
more
than 2000 2200
Public Members
·
A function FEEDINFO() to allow user to enter values
for Flight Number, Destination, Distance & call function CALFUEL() to
calculate the quantity of Fuel
·
A function SHOWINFO() to allow user to view the
content of all the data members
·
6. An array A[40][10] is stored in the
memory along the column with each element occupying 4 bytes. Find out the Base
address and address of the element A[3][6] if the element A[30][10] is stored
at the address 9000. 4M
7. Given two dimensional array
A[10][20], base address of A being 100 and width of each element is 4 bytes,
find the location of A[8][15] when the array is stored as (a)
column wise (b) Row wise. 4M
8.An array P[20][30] is stored in the memory along
the column with each of the element occupying 4 bytes, find out the memory
location for the element P[5][15], if an element P[2][20] is stored at the
memory location 5000 4M
9 .
Answer the questions (i) to (iv) based on the following code : 4M
class Goods
{ int id;
protected :
char name[20];
long qty;
void Incr(int n);
public :
Goods();
~Goods();
void get(); };
class Food_products : public Goods
{
char exp_dt[10];
protected :
int id;
int qty;
public :
void getd();
void showd(); };
class Cosmetics : private Goods
{ int qty;
char exp_date[10];
protected :
int id;
public :
~Cosmetics();Cosmetics();void show();};
(i) How many bytes will be required by
an object of class Food_products.
(ii) Name the member functions
accessible through the object of class Food_products.
(iii) From the following, Identify the
member function(s) that cannot be called directly from the object of class
Cosmetics
show(), getd(), get()
(iv) If the class cosmetics inherits the
properties of food_products class also, then name the type of inheritance.
10.Write a function in C++ which
accepts an integer array and its size as arguments and change all the even
number with twice and odd with thrice.
Example: if an array of five elements
initially contains the element as
2,4,1,5,7
then the function should rearrange the
array as
4,8,3,15,21
11. Write a
function in C++ which accepts an integer array and its size as arguments/
parameters and then assigns the elements into a two dimensional array of
integers in the following format:
If the array is 1, 2, 3, 4, 5, 6
The resultant 2 D array is given below |
If the array is 1, 2, 3
The resultant 2 D array is given below |
|||||||
0
0 0 0 0 6 |
0
0 0 0 5 5 |
0
0 0 4 4 4 |
0
0 3 3 3 3 |
0
2 2 2 2 2 |
1
1 1 1 1 1 |
0
0 3 |
0
2 2 |
1
1 1 |