CBSE Sample Papers for Class 12 Computer Science Paper 2

CBSE Sample Papers for Class 12 Computer Science Paper 2 is part of CBSE Sample Papers for Class 12 Computer Science. Here we have given CBSE Sample Papers for Class 12 Computer Science Paper 2.

CBSE Sample Papers for Class 12 Computer Science Paper 2

BoardCBSE
ClassXII
SubjectComputer Science
Sample Paper SetPaper 2
CategoryCBSE Sample Papers

Students who are going to appear for CBSE Class 12 Examinations are advised to practice the CBSE sample papers given here which is designed as per the latest Syllabus and marking scheme, as prescribed by the CBSE, is given here. Paper 2 of Solved CBSE Sample Paper for Class 12 Computer Science is given below with free PDF download Answers.

Time: 3 Hours
Maximum Marks: 70

General Instructions

  • All questions are compulsory within each Section.
  • Programming Language in SECTION A : C++.
  • Answer the questions after carefully reading the text.

SECTION A

Question 1.
(a) Write the type of C++ tokens (keywords and user defined identifiers) from the following:
(i) else
(ii) Long
(iii) 4Queue
(iv) _count
(b) The following C++ code during compilation reports errors as follows:
Error; ‘ofstream’ not declared
Error; ‘strupr’ not declared
Error; ‘strcat’ not declared
Error; ‘FIN’ not declared
Write the names of the correct header files, which must be included to compile the code successfully:

void main ()
{
ofstream FIN ("WISH. TXT");
char TEXT2 [] = "good day";
char TEXT1 []= "John!";
strupr (TEXT2);
strcat(TEST1, TEXT2);
FIN << TEXT1 << endl;
}

(c) Rewrite the following C++ code after removing any/all syntactical errors with each correction underlined.
Note: Assume all required header files are already included in the program.

Typedef Count int;
void main ()
{
Count C;
cout<<"Enter the count:"; cin>>C;
for (K = 1; K<=C; K++)
cout << C "*" K << endl;
}

(d) Find and write the output of the following C++ program code:
Note: Assume all required header files are already included in the program.

void Revert(int &Num, int Last = 2)
{
Last = (Last % 2 ==0) ? Last + 1 ; Last - 1:
for (int C=1; C< Last; C++)
Num+=C;
}
void main ()
{
int A = 20, B= 4;
Revert(A, B);
cout<<A<<"&"<<B<<endl;
B--;
Revert(A, B);
cout<<A<< "#"<<B<<endl;
Revert(B):
cout<<A<< "#" <<B<<endl; 
}

(e) Find and write the output of the following C++ program code:
Note: Assume all required header files are already included in the program.

#define Modify (N) N*3+10 
void main() 
{ 
int LIST [] = {10, 15, 12, 17}; 
int *P=LIST, C; 
for(C=3; C>=0: C--)
LIST[I] = Modify(LIST[I]);
for(C=0; C<=3; C++)
{
cout<<*P<<":";
P++;
}
}

(f) Look at the following C++ code and find the possible output(s) from the options (i) to (iv) following it. Also, write the highest and lowest values that can be assigned in the array A.
Note :

  • Assume all the required header files are already being included in the code.
  • The function random(n) generates an integer between 0 and n -1.
void main()
{
randomize();
int A[4], C;
for(C=0: C<4; C++) 
A[C]= random(C+1) + 10; 
for(C=3; C>=0; C--)
cout<<A[C]<<"@";
}

CBSE Sample Papers for Class 12 Computer Science Paper 2 1

Question 2.
(a) Which function (s) out of the following can be considered as overloaded function(s) in the same program? Also, write the reason for not considering the other(s) as overloaded function(s).

void Execute (char A, int B); //Function1
void Execute (int A, char B); //Function2
void Execute (int P = 10); //Function3
void Execute(); //Function4
int Execute (int A); //Function5
void Execute (int &K); //Function6

(b) Observe the following C++ code and answer the questions (i) and (ii).
Note: Assume all necessary files are included.

class FIRST
{
int Num1;
public:
void Display() // Member Function1
{
cout<< Num1<<endl;
}
};
class SECOND : public FIRST
{
int Num2;
public:
void Display() //Member Function2
{
cout<<Num2<<endl;
}
};
void main()
{
SECOND S;
............... //Statement 1
............. //Statement 2
}

(i) Which Object-Oriented Programming feature is illustrated by the definitions of classes FIRST and SECOND?
(ii) Wife Statement1 and Statement2 to execute Member Function 1 and Member Function 2 respectively using the object S.
(c) Write the definition of a class CONTAINER in C++ with the following description:
Private Members
– Radius, Height // float
– Type //int (1 for Cone, 2 for Cylinder)
– Volume // float
– CalVolume() // Member function to calculate
// volume as per the Type
CBSE Sample Papers for Class 12 Computer Science Paper 2 2
Public Members
– GetValues()
// A function to allow user to enter value
// of Radius, Height and Type. Also, call
// function CalVolume () from it
– ShowAll ()
// A function to display Radius, Height,
// Type and Volume of Container
(d) Answer the questions (i) to (iv) based on the following :

class Teacher
{
int TCode;
protected:
char Name[20];
public:
Teacher();
void Enter(); void Show();
};
class Course
{
int ID;
protected;
char Title [30];
public:
Course();
void Initiated;
void Display();
};
class Schedule : public Course, private Teacher
{
int DD, MM, YYYY;
public:
Schedule();
void Start();
void View();
};
void main()
{
Schedule S;
}

(i) Which type of Inheritance out of the following is illustrated in the above example?
Single Level Inheritance, Multilevel Inheritance, Multiple Inheritance.
(ii) Write the names of all the members, which are directly accessible by the member function View() of class Schedule.
(iii) Write the names of all the members, which are directly accessible by the object S of class Schedule declared in the main () function.
(iv) What will be the order of execution of the constructors, when the object S of class Schedule is declared inside the main() function?

Question 3.
(a) Write the definition of a function SumEO(int VALUES[], int N) in C++, which should display the sum of even values and sum of odd values of the array separately.
Example: If the array VALUES contains
CBSE Sample Papers for Class 12 Computer Science Paper 2 3
Then the functions should display the output as :
Sum of even values = 42 (i.e., 20 + 22)
Sum of odd values = 99 (i.e., 25 + 21 + 53)
(b) Write a definition for a function UpperHalf (int Mat [4][4]) in C++, which displays the elements in the same way as per the example shown below.
For example, if the content of the array Mat is as follows:
CBSE Sample Papers for Class 12 Computer Science Paper 2 4
The function should display the content in the following format:
25 24 23 22
20 19 18
15 14
10
(c) Let us assume Data [20] [15] is a two-dimensional array, which is stored in the memory along the row with each of its elements occupying 2 bytes. Find the address of the element Data[10][5], if the element Data [15][10] is stored at the memory location 15000.
(d) Write the definition of a member function AddPacket() for a class QUEUE in C++, to remove/delete a Packet from a dynamically allocated QUEUE of Packets considering the following code is already written as a part of the program.

struct Packet
{
int PID;
char Address [20];
Packet *Link;
};
class QUEUE
{
Packet * Front, * Rear;
public;
QUEUE() {Front=NULL; Rear=NULL;}
void AddPacket();
void Delete Packet();
~QUEUE();
};

(e) Convert the following Infix expression to its equivalent Postfix expression, showing the stack contents for each step of conversion:
+ –

Question 4.
(a) A text file named MATTER. TXT contains some text, which needs to be displayed such that every next character is separated by a symbol ‘#’.
Write a function definition for HashDisplay() in C++ that would display the entire content of the file MATTER. TXT in the desired format.
Example:
If the file MATTER.TXT has the following content stored in it:
THE WORLD IS ROUND
The function HashDisplay() should display the following content:
T#H#E#
#W#0#R#L#D#
#I#S# #R#0#U#N#D#
(b) Write a definition for a function TotalTeachers() in C++ to read each object of a binary file SCHOOLS. DAT, find the total number of teachers, whose data is stored in the file and display the same. Assume that the file SCHOOLS. DAT is created with the help of objects of class SCHOOLS, which is defined below:

class SCHOOLS
{
int SCode; //School Code
char SName[20]: //School Name;
int NOT://Number of Teachers in the school
public:
void Display()
{cout<<SCode<<"#"<<SName<<"#"<<N0T<<endl:}
int RNOT() {return NOT;}
};

(c) Find the output of the following C++ code considering that the binary file SCHOOLS.DAT exists on the hard disk with the following records of 10 schools of the class SCHOOLS as declared in the previous question (4 b).
CBSE Sample Papers for Class 12 Computer Science Paper 2 5

void main()
{
fstream SFIN;
SFIN.open("SCHOOLS.DAT", ios::binary | ios::in);
SCHOOLS S;
SFIN.seekg(5*sizeof(S));
SFIN.read((char*)&S, sizeof(S));
S.Display();
cout<<"Record:"<<SFIN.teIlg()/sizeof(S)
+1<<endl;
SFIN.close();
}

SECTION B

Question 5.
(a) Observe the following tables VIDEO and MEMBER carefully and write the name of the RDBMS operation out of (i) SELECTION (ii) PROJECTION (iii) UNION (iv) CARTESIAN PRODUCT, which has been used to produce the output as shown below. Also, find the Degree and Cardinality of the final result.
CBSE Sample Papers for Class 12 Computer Science Paper 2 6
(b) Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii), which are based on the tables.
CBSE Sample Papers for Class 12 Computer Science Paper 2 7
(i) To display details of all transactions of TYPE Deposit from Table TRANSACT.
(ii) To display the ANO and AMOUNT of all Deposits and Withdrawals are done in the month of October 2017 from table TRANSACT.
(iii) To display the last date of transaction (DOT) from the table TRANSACT for the Accounts having ANO as 103.
(iv) To display all ANO, ANAME and DOT of those persons from tables ACCOUNT and TRANSACT who have done transactions less than or equal to 3000.

(v) SELECT ANO. ANAME FROM ACCOUNT
WHERE ADDRESS NOT IN ('CHENNAI', 'BANGALORE');
(vi) SELECT DISTINCT ANO FROM TRANSACT ;
(vii) SELECT ANO. COUNT (*) , MIN (AMOUNT) FROM TRANSACT GROUP BY ANO HAVING COUNT (*) > 1;
(viii) SELECT COUNT (*), SUM (AMOUNT) FROM TRANSACT
WHERE D0T<= '2017-06-01';

Question 6.
(a) State any one Absorption Law of Boolean Algebra and verify it using truth table.
(b) Draw the Logic Circuit of the following Boolean Expression:
(U’ + V) . (V’ + W’)
(c) Derive a Canonical POS expression for a Boolean function FN, represented by the following truth table:
CBSE Sample Papers for Class 12 Computer Science Paper 2 8
(d) Reduce the following Boolean Expression to its simplest form using K-Map:
G(U, V, W, Z) = Σ (3, 5, 6, 7, 11, 12, 13, 15)

Question 7.
(a) Differentiate between Bus Topology and Star Topology of Networks. What are the advantages and disadvantages of Star Topology over Bus Topology?
(b) Classify each of the following Web Scripting as Client-Side Scripting and Server Side Scripting:
(i) Java Scripting
(ii) ASP
(iii) VB Scripting
(iv) JSP
(c) Write the expanded names for the following abbreviated terms used in Networking and Communications:
(i) SMTP
(ii) VoIP
(iii) GSM
(iv) WLL
(d) CASE STUDY BASED QUESTIONS :
Ayurveda Training Educational Institute is setting up its center in Hyderabad with three specialized departments for Orthopedics, Neurology, and Pediatrics along with an Administrative office in separate buildings. The physical distances between these department buildings and the number of computers to be installed in these departments and administrative office are given as follows. You, as a network expert, have to answer the queries as raised by them in (i) to (iv).
Shortest distances between various locations in meters:
CBSE Sample Papers for Class 12 Computer Science Paper 2 9
Number of Computers installed at various locations are as follows :
CBSE Sample Papers for Class 12 Computer Science Paper 2 10
(i) Suggest the most suitable location to install the main server of this institution to get efficient connectivity.
(ii) Suggest the best cable layout for effective network connectivity of the building having server with all the other buildings.
(iii) Suggest the devices to be installed in each of these buildings for connecting computers installed within the building out of the following:

  • Gateway
  • Modem
  • Switch

(iv) Suggest the topology of the network and network cable for efficiently connecting each computer installed in each of the buildings out of the following:
Topologies: Bus Topology, Star Topology
Network Cable: Single Pair Telephone Cable, Coaxial Cable, Ethernet Cable.

Answers

Answer 1.
(a) else is a keyword.
Long, 4Queue, _ count are user defined identifiers.
(b) Correct header files-

#include → ofstream
#include → strupr, strcat

(c) The correct C++ code after removing any/all syntactical errors:

typedef int Count:
void main ()
{
Count C;
cout <<"Enter the count : "; cin>>C;
for(int K=1 ; K<= C ; K++)
cout<<C<<"*"<<K<<endl;
}

(d) Output
35 & 4
38 # 3
38 # 9
(e) Output
10 : 15 : 12 : 17 :
(f) The possible output is
(iv) 12@11@10@10
The highest value of array A = 14
The lowest value of array A = 11

Answer 2.
(a) Function1, Function2 and Function 5 can be considered as overloaded function in the same program.
(b) (i) Inheritance is an Object Oriented Programming feature which is illustrated by the definitions of classes FIRST and SECOND.
(ii) Statement1
S.FIRST :: Display();
Statement 2
S.SECOND :: Display();

(c) class CONTAINER
{
float Radius, Height, Volume;
int Type;
void Cal Volume()
{
if(Type ==1)
Volume = 3.14* Radius * Height;
else if (Type =2)
Volume = 3.14* Radius * Height/3;
else
Volume =0;
}
public;
void GetValues()
{
cout<<"\n Enter the Radius"; cin>>Radius;
cout<<"\n Enter the Height"; cin>>Height;
cout<<"\n Enter the Type (1 for Cone, 2 for Cylinder)"; cin>>Type;
CalVolume();
}
void ShowAll()
{
cout<<"\n Radius :"<<Radius;
cout<<"\n Height:"<<Height;
cout<<"\n Type :"< cout<<"\n Volume:"<<Volume;
}
};

(d) (i) Multiple Inheritance is illustrated in the given example.
(ii) Members directly accessible by the member function view() of Class Schedule are:
DD, MM, YYYY, ID
(iii) Member functions directly accessible through the object S of class Schedule are:
Start(), View(), Initiate(), Display(), Enter(), Show ()
(iv) The order of execuation of constructors, when the object S of Class Schedule is declared inside the main() function is:
Course(), Teacher(), Schedule()

Answer 3.

(a) int Sum1, Sum2;
void SumE0(int VALUES [], int N)
{
for (int i=0; i< N; i++)
{
if (VALUES [i] %2 == 0)
Sum1 = Sum1 + VALUES [i];
else
Sum2 = Sum2 + VALUES [i]:
}
}
(b) UpperHalf(int Mat[4][4])
{
int r, c;
for(r=0; r<4; r++)
{
for(c=0; c < 4; C++)
{
if(c<=r)
cout<<Mat[r][c];
else
cout<<" ";
}
cout<<"\n";
}

(c) Number of rows = 20
Number of columns = 15
Element size = 2
Address of Data [15] [10] = 15000
Lowest row Ir = 0
Lowest column Ic = 0
For row-wise allocation

Data[P] [Q] = B + W [C(P - Ir) + (Q - Ic )]
Data[15][10] = B + 2 [15 (15 - 0 ) + (10 - 0)]
15000 = B +2 [15 x 15 + 10]
15000 = B + 2 [225 + 10]
15000= B + 2 [235]
B = 15000 - 470 B = 14530
Data[i] [j] = B + W [C(i - Ir) + (j - Ic )]
Data[10] [5] = 14530 + 2 [15 (10 - 0) + (5 - 0) ]
= 14530 + 2 [15 x 10 + 5]
= 14530 + 2 [150 + 5]
= 14530 + 2 [155]
= 14530 + 310
= 14840
(d) void AddPacket()
{
Packet *LINK = new Packet;
cout<<"Enter the Packet Id and Address"; cin>>LINK → PID>>LINK → Address;
LINK → Next = NULL;
if(Front == NULL && Rear == NULL)
Front = Rear = LINK;
else
{
Rear → Next = LINK;
Rear = LINK;
}
}

(e) Let us rewrite like : U * V + (W – Z)/ X)
CBSE Sample Papers for Class 12 Computer Science Paper 2 11
Output: UV * WZ – X/+

Answer 4.

(a) void HashDisplay()
{
if stream fin;
fin.open ("MATTER.TXT");
char ch;
while(!fin.eof())
{
fin.get(ch);
cout<<ch<<"#";
}
fin.close();
}
(b) void Total Teachers()
{
ifstream fin;
fin.open("SCHOOLS.DAT", ios :: in | ios :: binary);
SCHOOLS S;
int count = 0;
while(fin.read((char*)&S, sizeof(S)))
{
count++;
S.Display();
}
fin.close();
cout<<"Total number of teachers are"<<count;
}

(c) Output
Record: 2

Answer 5.
(a) Cartesian Product has been used to produce the output.
Degree of the FINAL RESULT = 5
Cardinality of the FINAL RESULT = 9
(b) SQL queries for (i) to (iv):

(i) SELECT * FROM TRANSACT
WHERE TYPE = 'Deposit';
(ii) SELECT ANO, AMOUNT FROM TRANSACT
WHERE DOT LIKE '2017-10-%';
(iii) SELECT MAX (DOT) FROM TRANSACT
WHERE ANO = 103;
(iv) SELECT ANO, ANAME, DOT FROM ACCOUNT, TRANSACT
WHERE ACCOUNT.ANO = TRANSACT. ANO
AND AMOUNT <= 3000;

Outputs for SQL queries (v) to (viii)
CBSE Sample Papers for Class 12 Computer Science Paper 2 12

Answer 6.
(a) In Boolean Algebra, the absorption law or absorption identity is an identity linking a pair of binary operations.
According to this law:
X + X . Y = X
Verify this law using truth table-
CBSE Sample Papers for Class 12 Computer Science Paper 2 13
Both the columns X and X + X . Y are identical.
Hence proved.
(b) Logic circuit for the given Boolean Expression :
(U’ + V) (V’+ W’)
CBSE Sample Papers for Class 12 Computer Science Paper 2 14
CBSE Sample Papers for Class 12 Computer Science Paper 2 15

Answer 7.
(a) Difference between Bus topology and Star topology is as follows:
In bus topology, all nodes are connected to server along a single length of cable. Whereas, in star topology, all nodes are connected to server individually.
Advantages of Star topology over Bus topology are:
(i) Easy to detect faults and remove it.
(ii) Failure of single system will not bring down the entire network.
Disadvantages of Star topology over Bus topology:
(i) Requires more cable length than Bus topology.
(ii) If hub or server fails, the entire network will be disabled.

(b) Client-side scripting from the given Web scripting is as follows:
(i) Java Scripting
(ii) VB Scripting
Server-side scripting from the given Web scripting is as follows:
(iii) ASP
(iv) JSP

(c) Expanded forms :
(i) SMTP – Simple Mail Transfer Protocol
(ii) VoIP – Voice over Internet Protocol
(iii) GSM – Global System for Mobile Communication
(iv) WLL – Wireless Local Loop

(d) (i) The most suitable location to house the server is Administrative office as it has maximum number of computers. Thus, it decreases the cabling cost and increases efficiency of network.
(ii) Best cable layout for effective network connectivity of the building having server with all other building as follows:
CBSE Sample Papers for Class 12 Computer Science Paper 2 16
(iii) Switch is to be installed in each of building to connect all the computers.
(iv) Star topology, co-axial cable.

We hope the CBSE Sample Papers for Class 12 Computer Science Paper 2 help you. If you have any query regarding CBSE Sample Papers for Class 12 Computer Science Paper 2, drop a comment below and we will get back to you at the earliest.