CLASS XII PRACTICE PAPER - 1
COMPUTER SCIENCE (083)
1. / (a) / What do you understand by actual argument and formal argument? Explain with example. / 2(b) / Write the header files compulsory required to execute the following c++ code:
void main(){
char Text[40];
strcmp(Text,"AISSCE");
gets(Text);
} / 1
(c) / Read the given C++ code carefully, which is supposed to count the number of character ‘a’ or character ‘A’ from a string argument str. But it contains some logical error and does not produce the required output. Write the corrected required code without adding any new statement in the code:
void count_a_A(char str[30))
{inti,count=0;
for(i=0; i!=”\0” ; i++)
{
if(str[i]='a' || str[i]='A')
count + 1 ;
}
cout<"Count = "<count<endl;
} / 2
(d) / Observe the following C++ code carefully and write the output:
#include<iostream.h
int a=3;
void callme(inti,int j, int k=1)
{
a+=i;
j=i+k;
k++;
couti<','<j<','<k<endl;
}
void main()
{
int a=10, b=20;
callme(::a,a,b);
cout<a<','<::a<','<b<endl;
callme(a,::a);
} / 3
(e) / Observe the following C++ code carefully and write the output:
#include<iostream.h
void main()
{
int a[]={30,33,44,55,66},i=1;
while( i++ < 4 )
{
a[i]%2==0 ? cout<a[i]<'*' : cout<a[i]<endl;
}
} / 2
(f) / Observe the given c++ code carefully and select the incorrect output out of options (i) to (iv), if the value of n is 4. Also justify your answer:
#include<iostream.h
#include<stdlib.h
void main()
{
intn,k,i;
cout<"Enter value of n: ";
cin>n;
randomize();
for(i=0;i<3;i++)
{
k=random(n);
n--;
cout<k<':';
}
}
(i). 3:2:1: (ii). 2:2:1: (iii). 3:2:3: (iv). 0:0:0: / 2
2. / (a) / What do you mean by inheritance? Explain with the help of c++ code. / 2
(b) / Given the following C++ code, answer (i) & (ii):
class Date
{
intdd,mm,yy;
public:
Date(); //function-1
Date(int,int,int);//function-2
Date(Date &d); //funciton-3
void getDate(); //function-4
~Date(); //funciton-5
};
(i). Which function(s) will be invoked if the following statement is executed:
Date d1;
Date d2(d1);
(ii).Define the coding of function-3 outside the class. / 2
(c) / Define a class Ticket as per the given details:
Private Members:
To of type string (for storing destination city)
From of type string (for storing start city)
Distance of type integer.
Fare of type float.
BasicFare of type float.
A function InitiateFare() to assign the value of Fare as BaseFare + DistanceFare, where DistanceFare is calculated as per the distance and Rate per KM as given below:
Distance(in KM)Rate/KM(in Rs)
<=500200 Rs/Km
>500 & <=1000150 Rs/Km
>1000100 Rs/Km
Public Members:
A function getdata() to accept the values of all data members except Fare from user and to call the function AssignFare() to calculate and assign value of Fare.
A function showdata() to display all data members. / 4
(d) / Answer the questions (i) to (iv) based on the following:
class HQ
{ long HQmaxvalue;
protected :
long HQfundvalue;
public:
intno_of_HQmeritcert;
HQ( );
void HQREAD( );
void HQWRITE( );
};
class RO: protected HQ
{ intROcode;
long ROmaxvalue;
protected:
long ROfundvalue;
public:
intno_of_ROmeritcert;
RO( );
void HQUPDATE( );
void ROREAD( );
void ROWRITE( );
};
class KV: private RO
{ intKVcode, no_of_achivements;
char KVname[30];
public:
long cashprize;
KV( );
void ROUPDATE( );
void KVREAD( );
void KVWRITE( );
};
i)Mention the member names that are accessible by an object of RO class.
ii)Name the members which can be accessed by the objects of KV class.
iii)Name the date members that can be accessed by the ROUPDATE() of KV class.
iv)How many bytes will be occupied by an object of class KV? / 4
CLASS XII PRACTICE PAPER - 2
COMPUTER SCIENCE (083)
Q 1 a.What is the similarity and difference between break and continue statements?2
b. Write the names of the header files to which the following belong:1
i) puts() ii) sin()
c. Rewrite the following program after removing the syntactical error(s) if any. 2 Underline each correction. 2
#include<iostream.h
void main()
{
First=10, Second=20;
Jumpto(First;Second);
Jumpto(second);
}
voidJumpto(int N1, int N2=20)
{
N1=N1+N2;
cout>N1>N2
}
d. Give the output of the following program:2 #include<iostream.h
int g=20;
voidFunc(int &x, int y)
{
x=x-y;
y=x*10;
cout<x<’,’<y<”\n”;
}
void main()
{
int g=7;
Func(g,::g);
cout<g<’,’<::g<’\n’;
Func(::g,g);
cout<g<’,’<::g<’\n’;
}
e. Find the output of the following program:3
#include<iostream.h
#include<ctype.h
typedef char Txt80[80];
void main()
{
char *PText;
Txt80 Txt=”Ur2GReAt”;
int N=6;
PText=Txt;
while(N>=3)
{
Txt[N]=isupper(Txt[N])? tolower(Txt[N]):toupper(Txt[N]);
coutPTextendl;
N--;
PText++;
}
}
f. The following code is from a game, which generates a set of 4 random numbers. Anuska is playing this game; help her to identify the correct option(s) out of the four choices given below as possible set of such numbers generated from the program code so that she wins the game. Justify your answer. 2
#include<iostream.h
#include<stdlib.h
constint LOW=25;
void main()
{
randomize();
int POINT=5, Number;
for(int I=1;I<=4;I++)
{
Number= LOW + random(POINT);
cout<Number<”:”;
POINT--;
}
}
(i) 29: 26: 25: 28:(ii) 24: 28: 25: 26:
(iii) 29: 26: 24: 28:(iv) 29: 26: 25: 26:
2. a. What is the difference between abstract class and concrete class?2
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 ELECTION with the following specifications. Write a suitable main ( ) function also to declare 3 objects of ELECTION type and find the winner and display the details. 4
Private Members :
Data:Candidate_Name , Party , Vote_Received
Public members :
Functions:Enterdetails ( ) – to input data
Display ( ) – to display the details of the candidates
Winner ( ) – To display the details of the winner through the object after comparing the votes received by three candidates.
d. Answer the question (i) to (iv) based on the following4
class Book
{
char Title[20];
char Author[20];
intnoofpages;
public:
void read();
void show();
};
classTextBook: private Book
{ intnoofchap, noofassignments;
protected:
int standard;
public:
voidreadtextbook();
voidshowtextbook();
};
class Physicsbook: public TextBook
{
char Topic[20];
public :
voidreadphysicsbook();
voidshowphysicsbook();
};
(i) Names the members, which are accessible from the member functions of class Physicsbook.
(ii) Write the names of members, which are accessible by an object of class Textbook.
(iii) Write the names of all members, which are accessible by an object of class Physicsbook.
(iv) How many bytes will be required by an object belonging to class Physicsbook.
CLASS XII PRACTICE PAPER - 3
COMPUTER SCIENCE (083)
Q.1 / (a) / What is the difference between implicit & explicit type casting? Give suitable examples to support your answer.2(b) / Name the header file(s) that shall be needed for successful compilation of the following C++ code : 1
void main( )
{
clrscr();
char name[20];
gets(name);
if(strcmp(name,”KV”)==0)
cout<”String matched!!!”;
else
cout<”Not matching!!!”;
}
(c) / Rewrite the following program after removing the syntactical error(s), if any. Underline each correction.
#include <iostream.h
class InService
{
intgroup_no;
PUBLIC:
void get_info(){cingroup_no;}
void disp_info{coutgroup_no;}
}
void main()
{
InService I;
I.get_info();
disp_info();}
(d) / Find the output of the following program assuming all necessary header files are included:2
void Encoding(char E[])
{
for (inti=strlen(E);i>=0;i-=2)
if (E[i]=='A' || E[i]=='E')
E[i]='^';
else if (isupper(E[i]))
E[i]=tolower(E[i]);
else E[i]='%';
}
void main()
{
char line[]="KeNdriYAVidyaLAya";//The two words in the string
//line are separated by single space
Encoding(line);
cout<line<endl;}
(e) / Find the output of the following program- 2
#include<iostream.h
class student
{
public:
student()
{
cout<”\n Computer Science“;
}
~student()
{
cout<” subject”;
}
}st;
void main()
{
cout< “is my favourite” ;
}
(f) / Study the following program and select the possible output from it. Also find the maximum & minimum value of count 2
#include<iostream.h
#include<stdlib.h
constint VAL=3;
void main( )
{ randomize( );
int count;
count=70+random(VAL);
for(int x=count;x>=70;x--)
cout<x<”*”;
}
(i) 70*71* (ii) 71*70*
(iii) 73*72*71*70* (iv) 70*71*72*
(a) / Why an object in a copy constructor is passed by reference? How is it invoked?2
(b) / Answer the questions (i) and (ii) after going through the following class:2
class Commerce
{
char chapter[20];
int Weightage;
public:
Commerce ( ) //Function 1
{
strcpy (chapter, “Java” );
Weightage = 30;
cout<“chapter started”;
}
Commerce( Commerce &C); //Function 2
~Commerce( ) //Function 3
{
cout’<”chapter completed”;
}
(i) Name the specific features of class shown by Function 1 , Function 2 and Function 3 in the above example.
(ii) Write complete definition for Function 2.
(c) / Define a class TV_Channels in C++ with following description: 4
Private Members:
Channel number Integer
Name of channel String of 25 characters
Channel type String
Recharge Cost Float (per month)
Duration integer (in months)
Total cost Float
Public Members
- A function INPUT( ) to allow the user to enter the values of Channel no,Name of channel,Channeltype,recharge cost per month, duration and call the function calculate() to find total cost.
- A function Calculate( ) to find the total cost as per the following formula - recharge cost * duration.
- A function OUTPUT( ) to allow user to view the content of all the data members.
(d) / Consider the following declarations and answer the questions given below:
class School 4
{
protected:
intschool_code;
char school_name[50];
public:
void Get_data();
void Show_data();
School( );
~School( );
};
class Primary: public School
{
protected:
int strength;
public:
void Get_primarydata(int);
void Show_primarydata(int);
Primary( );
~Primary( );
};
class Secondary: public School
{
int sections;
public:
void Show_Secondarydata(void);
Secondary( );
~Secondary( );
};
i) How many bytes will be required by an object belonging to class Secondary?
ii) Which type of inheritance is depicted in the above example?
iii) List the data members that can be accessed by the member function Show_primarydata( )
iii)What is the order of constructor execution at the time of creating an object of class Secondary?