Name of the Board : CBSE Academic
Class : XII STD
Subject : Computer Science
Year : 2015-16
Website : http://cbseacademic.in/SQP_CLASSXII_2015_16.html
Download Sample Question Paper : https://www.pdfquestion.in/uploads/8030ComputerScience.pdf
Download Marking Scheme : https://www.pdfquestion.in/uploads/8030ComputerScienceMS.pdf
Computer Science Sample Question Paper :
Time: 3hrs
M.M: 70
Instructions:
i. All Questions are Compulsory.
ii. Programming Language: Section A : C++
iii. Programming Language: Section B: Python
iv. Answer either Section A or B, and Section C is compulsory
Section : A (C++)
Q1 a. Define Macro with suitable example. 2
b. Which C++ header file (s) will be included to run /execute the following C++ code? 1
void main( )
{ int Last =26.5698742658;
cout<<setw(5)<<setprecision(9)<<Last; }
c. Rewrite the following program after removing any syntactical errors. Underline each
correction made. 2
#include<iostream.h>
void main( )
int A[10];
A=[3,2,5,4,7,9,10];
for( p = 0; p<=6; p++)
{ if(A[p]%2=0)
int S = S+A[p]; }
cout<<S; }
d. Find the output of the following C++ program: 2
#include<iostream.h>
void repch(char s[])
{
for (int i=0;s[i]!=’\0′;i++)
{
if(((i%2)!=0) &&(s[i]!=s[i+1]))
{
s[i]=’@’;
}
else if (s[i]==s[i+1])
{
s[i+1]=’!’;
i++;
}
}
}
void main()
{
char str[]=”SUCCESS”;
cout<<”Original String”<<str
repch(str);
cout<<“Changed String”<<str;
}
e. Find the output of the following : 3
#include<iostream.h>
void switchover(int A[ ],int N, int split)
{
for(int K = 0; K<N; K++)
if(K<split)
A[K] += K;
else
A[K]*= K;
}
void display(int A[ ] ,int N)
{
for(int K = 0; K<N; K++)
(K%2== 0) ?cout<<A[K]<<“%” : cout<<A[K]<<endl;
}
void main( )
{ int H[ ] = {30,40,50,20,10,5};
switchover(H,6,3);
display(H,6);
}
f. Observe the following C++ code and find out , which out of the given options i) to iv) are the expected correct output.Also assign the maximum and minimum value that can be assigned to the variable ‘Go’. 2
void main()
{ int X [4] ={100,75,10,125};
int Go = random(2)+2;
for (inti = Go; i< 4; i++)
cout<<X[i]<<”$$”;
}
i. 100$$75 ii. 75$$10$$125$$ iii. 75$$10$$ iv.10$$125$
Q2a. Differentiate between data abstraction and data hiding. 2
b. Answer the questions (i) and (ii) after going through the following class : 2
class Exam
{
int Rollno;
char Cname[25];
float Marks ;
public :
Exam( ) //Function 1
{
Rollno = 0 ;
Cname=””;
Marks=0.0;
}
Exam(int Rno, char candname) //Function 2
{
Rollno = Rno ;
strcpy(Cname,candname);
}
~Exam( ) //Function 3
{
cout << “Result will be intimated shortly” << endl ;
}
void Display( ) //Function 4
{
cout << “Roll no :”<<Rollno;
cout<<”Name :” <<Cname;
cout <<” Marks:”<<Marks;
}
} ;
(i)Which OOP concept does Function 1 and Function 2 implement.Explain?
(ii)What is Function 3 called? When will it be invoked?
c. Define a class Candidate in C++ with the following specification : 4
Private Members :
A data members Rno(Registration Number) type long
A data member Cname of type string
A data members Agg_marks (Aggregate Marks) of type float
A data members Grade of type char
A member function setGrade () to find the grade as per the aggregate marks obtained by the student. Equivalent aggregate marks range and the respective grade as shown below.
Aggregate Marks Grade
>=80 A Less than 80 and >=65 B
Less than 65 and >=50 C
Less than 50 D
Public members:
A constructor to assign default values to data members:
Rno=0,Cname=”N.A”,Agg_marks=0.0
A function Getdata () to allow users to enter values for Rno. Cname, Agg_marks and call
function setGrade () to find the grade.
A function dispResult( ) to allow user to view the content of all the data members.
d. Give the following class definition answer the question that is follow: 4
class University
{
char name [20];
protected :
char vc[20];
public :
void estd();
void inputdata();
void outputdata();
}
class College : protected University
{ int regno;
protected
char principal()
public :
int no_of_students;
void readdata();
void dispdata ( );
};
class Depart