Previous Year Computer Science Question Paper For CBSE Class 12 - 2018
Previous Year Computer Science Question Paper For CBSE Class 12 - 2018
SECTION - A
[Only for Candidates, who adopted for C++]
1. (a)
Ans. (i) else : Keywords
(ii) Long : Keywords
(iii) 4Queue : Identifiers
(iv) _count : Identifiers
(b)
Ans. fstream . h
string.h
(c)
Ans. typedef int Count;
void main ( )
{
Count C;
cout<<“Enter the count:”;
cin>>C;
for (int K = 1 ; K<=C; K++)
cout<< C << “*” << K <<end1;
}
www.vedantu.com 1
(d)
Ans. 35 & 4
38 # 3
38 # 9
(e)
Ans. 40 : 55 : 46 : 61
(f)
Ans. 13@10@11@10@
2. (a)
Ans. void Execute (char A, int B) ; // Function 1
void Execute (int A, char B) ; // Function 2
void Execute (int P=10) ; // Function 3
(b)
Ans. (i) Single Inheritance
(ii) S.display ( );
S.First : : display ( );
(c)
Ans. Class CONTAINER
{ f loat Radius, Height;
int Type ;
float Volume ;
void CalVolume(float Radius, float Height, int n)
{Volume = (3.14*Radius*Radius*Height)/n;
}
void CalVolume(float Radius, float Height)
{Volume = 3.14*Radius*Radius*Height;
}
www.vedantu.com 2
public :
void GetValues( )
{cout << “Enter Radius”;
cin >>Radius;
cout<<“Enter Height”;
cin>>Height;
cout<<“Enter Type (1 for cone and 2 for cylinder)”;
cin>>Type;
switch(Type)
{case 1: CalVolume(Radius, Height, 3);
ShowAll( );
break;
case 2: CalVolume(Radius, Height);
ShowAll( );
break;
}
}
void ShowAll( )
{cout<< “Radius : “<<Radius;
cout<<“Height :”<< Height;
cout << “Volume : “<<Volume;
}
};
(d)
Ans. (i) Multiple Inheritance
(ii) DD,MM,YYYY, Title[30], Name[20]
(iii) Start ( ), View( ), Initiate( ), Display( ), Enter( ), Show( )
(iv) Schedule ( ), Course( ), Teacher( )
3. (a)
Ans. void sum EO(int VALUES [ ], int N)
{
int S1 = 0;
int S2 = 0;
for(int i = 0 ; i < N ; i + +)
www.vedantu.com 3
{ if(VALUES[i]% 2 = = 0)
{S1 + = VALUES [i];}
else
{S2 + = VALUES [i];}
}
cout << “Sum of even values”<< S1 << endl ;
cout << “Sum of odd values”<< S2 << endl ;
}
(b)
Ans. void UpperHalf (int Mat [4][4])
{for (int i = 0; i < 4; i + +)
{ for (int j = 0; j < 4; j ++)
{ cout << Mat [i] [j] << “ ”;
}
cout << endl;
}
}
(c)
Ans. W-2
N - 20
M - 15
Loc(Data[15][10]) = 15000
Row major formula :
Loc(Data[i][j]) = Base(Data) + W*(M * i + j)
Loc(Data[15][10]) = Base(Data) + 2*(15 * 15 + 10)
15000 = Base(Data) + 2*(225 + 10)
= Base(Data) + 2 * 235
= Base(Data) + 470
Base(Data) = 15000 – 470
= 14530
Loc(Data[10][5]) = 14530 + 2 * (15 * 10 + 5)
= 14530 + 2 * (150 + 5)
= 14530 + 2 * 155
= 14530 + 310
= 14840
www.vedantu.com 4
(d)
Ans. void QUEUE : : AddPacket( )
{ Packet *temp = new Packet;
if(temp==NULL)
{
cout<<“Overflow”<<endl;
}
cout<< “Enter PID”;
cin >> temp->PID;
int n = temp->PID;
temp -> Link=NULL;
/ / for first node
if(Front == NULL)
{
Front = Rear = temp;
}
else
{
Rear->Link = temp;
Rear = temp;
}
cout<< n << “has been inserted successfully.”<<endl;
/ /display
if(Front= =NULL)
{
cout<< “Underflow.”<<endl;
return;
}
else
{ temp = Front;
/ /will check until NULL is not found
while(temp)
{
cout << temp -> PID << “ “;
temp = temp -> Link;
}
cout<<endl;
}
www.vedantu.com 5
}
void QUEUE : : DeletePacket ( )
{
if(Front = = NULL)
{
cout<< “underflow”<< endl;
return;
}
cout << Front -> PID <<“ is being deleted “endl;
if (Front = = Rear) / / if only one node is there
Front = Rear = NULL;
else
Front = Front -> Link;
/ /display
if(Front= =NULL)
{
cout<< “Underflow.”<<endl;
return;
}
else
{
Packet *temp=Front;
/ / will check until NULL is not found
while(temp)
{
cout << temp -> PID << “ “;
temp = temp -> Link;
}
cout<<endl;
}
}
www.vedantu.com 6
(e)
Ans.
Symbols Stock Expression
U U
* * U
V * UV
+ + UV*
C +( UV*
W +( UV*W
– +(– UV*W
Z +(– UV*WZ
) + UV*WZ–
/ +/ UV*WZ–
X +/ UV*WZ–X
+ UV*WZ–X/
UV*WZ–X/+
4. (a)
Ans. void HashDisplay( )
{
ifstream fin(“MATTER.TXT”); / /opening text file
int size;
char ch;
fin.seekg(0, ios : : end);
size = fin.tellg( );
fin.seekg(0, ios : : beg);
for(int i=0; i < size; i++)
{
fin.get(ch);
cout << ch << “#”;
}
fin.close( );
}
www.vedantu.com 7
(b)
Ans. void putnot ( )
{
cout << NOT << “ ”;
}
void Total Teachers( )
{ fstream f;
SCHOOLS Stu;
f.open(“SCHOOLS.DAT”, ios : : in | ios : : binary);
cout << “\nTotal no. of Teachers : \n”;
while( ( f.read( (char*) &Stu, sizeof(Stu))) ! = NULL )
Stu.putnot( );
f.close( );
}
(c)
Ans. Record : 7
SECTION C
[For all the candidates]
5. (a)
Ans. (iv) CARTESIAN PRODUCT : VIDEO × MEMBER
Degree : 5
Cardinality : 9
(b)
Ans. (i) SELECT * FROM TRANSACT WHERE TYPE = ‘Deposit’
(ii) SELECT ANO, AMOUNT FROM TRANSACT WHERE MONTH(DOT) = 10;
(iii) SELECT DOT FROM TRANSACT WHERE ANO = 103
ORDER BY DOT DESC LIMIT = 1
(iv) Select A.ANAME, T.ANO, T.DOT FROM ACCOUNT as A
JOIN TRASACT as T ON A.ANO = T.ANO
WHERE T.AMOUNT < = 3000;
www.vedantu.com 8
(v) ANO ANAME
103 AliEReza
105 Simran Kaur
(vi) ANO
101
103
102
6. (a)
Ans. X (X+Y) = X
The truth is :
X Y XY X X .Y
0 0 0 0
0 1 0 0
1 0 0 1
1 1 1 1
(b)
Ans.
U V W
U'
(U ' V)
V
www.vedantu.com 9
(c)
Ans. ( )( )(
Output : X +Y +Z X +Y +Z X +Y +Z X +Y +Z )( )
(d)
Ans. G U ,V ,W , Z 3,5, 6, 7,11,12,13,15
W .Z V .Z U .V .W U .V .W
WZ
UV 00 01 11 10
00 0 0 1 0
01 0 1 1 1 U.V.W
11 1 1 1 0
10 0 0 1 0
U.V.W
V.Z W.Z
7. (a)
Ans. A bus topology is a networking architecture that is linear, usually by using one or more pieces of
cable to
form a single line, or bus. The Signals sent by one station extend the length of this cable to be heard by other
stations.
A star topology is an architecture that includes a central device or hub to connect all stations together. Signals
sent by a station must pass through (and are usually regenerated) by these central hubs.
Since the hub sits in the center and all other stations are linked through the hub, the architecture resembles a
star.
Advantages of Star Topology
(i) As compared to Bus topology it gives far much better performance, signals don’t necessarily get
transmitted to all the workstations. A sent signal reaches the intended destination after passing through
no more than 3-4 devices and 2-3 links.
(ii) Centralized management. It helps in monitoring the network.
Disdvantages of Star Topology
(i) Too much dependency on central device has its own drawbacks. It it fails whole network goes down.
(ii) The use of hub, a router or a switch as central device increases the overall cost of the network.
www.vedantu.com 10
(b)
Ans. (i) Java Script : Client Side Scripting
(ii) ASP : Server Side Scripting
(iii) VB : Client Side Scripting
(iv) JSP : Server Side Scripting
(c)
Ans. (i) SMTP : Simple Mail Transfer Protocol
(d)
Ans. (i) Administrative office as this department contains the maximum number of computers thus
decreasing
the cabling cost for most of the computers as well as increasing the efficiency of the maximum computers
in the network.
(ii)
Administrative
Office
Orthopedics Pediatrics
Unit Unit
Neurology
Unit
(iii) Switch : Switch would be needed in each of these builsings to interconnect the computers
installed within the building.
(iv) Topologies : Star Topology
Network Cable : Coaxial Cable
www.vedantu.com 11