Important Questions

CBSE Guess > Papers > Important Questions > Class XII > 2010 > Computer Science > Computer Science By Ravi Kiran

CBSE CLASS XII

(f) In the following C++ program what is the expected value of Myscore from Options (i) to (iv) given below. Justify your answer.
#include<stdlib.h>
#include<iostream.h>
void main( )
{
randomize();
int Score[] = {25,20,34,56, 72, 63}, Myscore;
Myscore = Score[2 + random(2)];
cout<<Myscore<<endl; }
(i) 25
(ii) 34
(iii) 20
(iv) None of the above

2. (a) Differentiate between Protected and Private members of a class in context of Inheritance using C++.

(b) Answer the questions (i) and (ii) after going through the following class: 2
class Science
{
char Topic[20];
int Weightage;
public:
Science ( ) //Function 1
{
strcpy (Topic, “Optics” );
Weightage = 30;
cout<<“Topic Activated”;
}
~Science( ) //Function 2
{
cout’<<”Topic Deactivated”;
}

(i) Name the specific features of class shown by Function 1 and Function 2 in the above example.

(ii) How would Function 1 and Function 2 get executed ?

(c) Define a class Travel in C++ with the description given below :
Private Members :
T_Code of type string
No_of_Adults of type integer
No_of_Children of type integer
Distance of type integer
TotalFare of type float
Public Members :

(i) A constructor to assign initial values as follows :
T_Code with the word “NULL”
No_of_Adults as 0
No_of_Children as 0
Distance as 0
TotalFare as 0

(ii) A function AssignFare( ) which calculates and assigns the value of the data member TotalFare as follows :
For each Adult
Fare (Rs) For Distance (Km)
500 >=1000
300 <1000 & >=500
200 <500
For each Child the above Fare will be 50% of the Fare mentioned in the above table.
For example :
If Distance is 750, No_of_Adults = 3 and No_of_Children = 2
Then TotalFare should be calculated as
No_of_Adults * 300 + No_of_Children * 150
i.e. 3 * 300 + 2 * 150 = 1200

(iii) A function EnterTraveK ) to input the values of the data members T_Code, No_of_Adults, No_of_Children and Distance; and invoke the AssignFare( ) function.

(iv) A function ShowTraveK) which displays the content of all the data members for a Travel.

Paper By Mr. Ravi Kiran
Email Id : [email protected]