CBSE Solved Papers For Class 12 Computer Science (C++) Paper 3

SECTION A

Question 1.
(a) Out of the following, find those identifiers, which cannot be used for naming variable, Constants or Functions in a C++ program :

_Cost, Price*Qty, float, Switch,
 Address One, Delete, Numberl2, do

(b) Jayapriya has started learning C++ and has typed the following program. When she complied the following code written by her, she discovered that she needs to include some header files to successfully compile and execute it. Write the names of those header files, which are required to be included in the code.

void main ()
 {
 float A, Number, outcome;
 cin>>A>>Number ;
 outcome=pow (A, Number);
 cout<<outcome<<endl;
 }

(c) Find the output of the following program:

#include
#include
 void main ()
 {
 char Text [] = {"Mind 0 Work
 for (int I = 0; Text [I] ! = '/O', I++)
 {
 if (!isalpha (Text [I]))
 Text [I]='*';
 else if (isupper (Text [I]))
 Text [I]=Text [I] +1;
 else
 Text [I]=Text [1+1];
 puts (text);
 }
 }

(d) Rewrite the following program after removing the syntactical error(s), if any. Underline each correction.

#include<iostream.h>
 const int size=5,
 void main ()
 {
 int Array (size);
 Array={50, 40, 30, 20, 10);
 for int (ctr=0; ctr<size; ctr++); 
cout>>Array [ctr]; }

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

class market
 {
 long int code;
 float Rate;
 int DD;
 public:
 market () { code = 1000; Rate = 100; DD = 1:}
 void Getcode (long int C, float R)
 {
 code = C;
 Rate = R;
 }
 void Update (int change, int D)
 {
 Rate + = Change;
 DD = D;
 }
 void Status ()
 {
 cout < < "Date : " < < DD < < endl;
 cout < < code < < "#" < < Rate < < endl;
 }
 };
 void main ()
 {
 Market S, T, U;
 S. Getcode (1324, 350);
 T. Getcode (1435, 250);
 S. Update (50, 28);
 U. Update (-25, 26);
 S. Status ();
 T. Status ();
 U. Status ();
 }

(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’.

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$

Answer:

 (a) Price*Qty,
 float,
 Address one,
 do_cost

(b) iostream.h or iomanip.h
math.h
Note:
Ignore any other header files, if mentioned.
complex. h is acceptable in place of match.h
(c) The output of the above program is:
ind ***or k**
(d) The correct program is as follows:

#include
 const int size=5;
 void main ()
 {
 int Array [size];
 Array [ ]={50, 40, 30, 20, 10}
 for (int ctr=0; ctr<size; ctr++)
 cout << Array [ctr];
 }

(e) Date: 28
1324#400
Date : 1
1435#250
Date : 26
1000#75

(f) iv is the correct option.
Minimum value of Go = 2
Maximum value of Go = 3

Question 2.
(a) What is function overloading ? Write an example using C++ to illustrate the concept of function overloading.
(b) Observe the following C++ code and answer the question (i) and (ii):

class E and I
 {
 int Temperature, Humidity;
 char city[30];
 public :
 E_and_I() //Function 1
 {
 Temperature=0; Humidity=0;
 cout<<"set to Zero"<<endl;
 }
 void E and I (int T, int H, char c[]) //Function2
 {
 Temperatrue T; .
 Humidity H;
 strcpy(city, c) ;
 }
 void show() //Function3
 (
 cout«"Temperature«"; "<<Humidity«endl;
 puts(city);
 }
 ~E_and_I //Function4
 ' {
 cout<<"Data Removed! "<<endl;
 }
 }

(i) Fill in the blank lines as Statement 1 and Statement 2 to execute Functions 2 and 3 respectively in the following code:

void main()
 {
 E and I E;
 ............... //Statement 1
 .............. //Statement 2
 } //The end of main function here

(ii) Which function will be executed at the point where “//The end of main()function here” is written in the above code ? What is this function called and executed here is known as ?
(c) Answer the questions (i) to (iv) based on the following code:

class Teacher
 {
 char TNo [50], TName [20], Dept [10];
 int Workload;
 protected:
 float Salary;
 void AssignSal (Float);
 Teacher ();
 void TEntry ();
 void TDisplay ();
 };
 class student
 {
 char Admno [10],
 SName [20],
 Stream [10];
 protected:
 int Attendence, Totmarks;
 public:
 student ();
 void SEntry ();
 void SDisplay () ;
 };
 class School: public student, public Teacher
 {
 char SCode [10], SchName [20];
 public:
 School ();
 void SchEntry ();
 void SchDisplay ();
 };

(i) Which type of inheritance is depicted by the above example?
(ii) Identify the member function(s) that cannot be called directly from the object of the class School from the following:
TEntry ()
SDisplay ()
SchEntry ()
(iii) Write name of all the member(s) accessible from member function of class School.
(iv) If class school was derived privately from class Teacher and privately from class Student, then, name the member function (s) that could be accessed through object of class school.
(d) Define a class TEACHER with the following specifications:
Private Members:
name: 20 characters
subject 10 characters
basic, da, hra float
Salary float
calculate () A function that computes the salary and returns it. Salary is sum of basic, da and hra.
Public Members:
readata () A function that accept data values and invokes the calculate function,
displaydata () A function that prints the data on the screen.

Answer:
(a) C++ enables us to create more than one function with the same name. This is called function overloading. The functions must differ in their parameter list, with a different type of parameter, different number of parameters, or both.

int double(intA)
 {
 return(2*A);
 long Double(long A)
 {
 return(2*A);
 }
 float Double (float A)
 {
 return (2*A);
 }

(b) (i) Statement 1: E.E_and_I(32,5, “Indore”);
Statement 2 : E. Show ();
(ii) Function 4 will be executed. This function is called as destructor, which is excuted when object goes out of scope. [1]
(c) (i) Multiple Inheritence is depicted by the given example. [1]
(ii) TEntry (), as it is declared protected, write, other two are public.

(iii) Teacher ()
 Tentry ()
 TDisplay ()
 Student ()
 SEntry ()
 SDisplay ()
 School ()
 SchEntry ()
 SchDisplay ()
 Salary ()
 Assign Sal ()
 Attendence
 Totmarks
 SCode
 SchName

(iv) The member functions are:

SchEntry ()
 SchDisplay ()

(d) class TEACHER
 {
 char name [20];
 char subject [10];
 float basic, da, hra;
 float salary;
 float calculate ()
 {
 return (basic + da + hra);
 }
 public:
 void readata ( )
 {
 cout<<"\n Enter the teacher name:";
 gets(name);
 cout<<"\n Enter the Subject;";
 gets(subject);
 cout<<"\n Enter the basic salary:"; cin>>basic;
 cout<<"\n Enter the HRA:"; cin>>hra;
 salary=calculate ();
 }
 void displaydata ()
 {
 cout <<"\n Teacher's name is : ";puts (name) ;
 cout<<"\n Subject taught is:";puts(subject);
 cout<<"\n Basic salary is:"<<basic;
 cout<<"\n Da is"<<da;
 cout<<"\n HRA is;"<<hra;
 cout<<"\n Total salary is:"<<salary;
 }
 } ;

Question 3.
(a) Write a C+ + program to sort an array of 10 integers. Sort array showing status of the array after each pass. Assume 10 integers.
(b) An integer array A [40] [30] is stored along the row in the memory. If the element A[20] [25} is stored at 50000. Find out the location of A [7] [10].
(c) Write a function in C++ to print the sum of all the values which are either divisible by 2 or divisible by 3, present in a two dimensional array passed as the argument to the function.
(d) Write a function in C++ to delete an element from a dynamically allocated queue where each node contains a real number as data. Assume the following definition of MYNODE for the same

struct MYNODE
 {
 float NUM;
 MYNODE * Link;
 };

(e) Evaluate the following postfix notation of expression (show status of stack after execution of each operation);
5, 20, 15, -, *, 25, 2, *, +

Answer:

(a) /* Sorting Array and Showing Status of Array After Each Pass*/
 #include
 #include
 void main ()
 {
 int i, array [10], n, j, temp,small, pos;
 clrscr ();n=10;/given in question
 cout<<"Enter size of an array"; cin>>n;
 for (i=0; i<n;i++)
 {
 //Inserting array elements.
 cout<<"Insert"<>array [i];}
 for (i=0;i<10;i++)//program code to sort array
 {small=array[i];
 pos=i;
 for(j=0;j<g;j++)
 {if(array[j]<small)
 {small=array[j];pos=j;}
 }
 tmp=atray[i];
 array[i]=array[pos];
 array[pos]=tmp;
 cout<<"\nArray other pass-"< for(j=0;<10;j ++)
 cout<<array[j]
 }
 //Displaying sorted array.
 cout<<"\n Sorted Array Element Are";
 for (i=0; i<n; i++)
 cout<< array [i] ;
 getch ();
 }
(b)A[i J [ j ] =B+Wx[No.of columns (I-Lr) + (J-Lc ]
 A [ 2 0 ] [ 25 ]=B+2x[ 30x(20-0)+(25-0)]
 5000=B+2x[3Ox (20-0) + (25-0) ]
 B=48750
 A[7][10]=4875Q+2x[30x(7-0)+(10-0)]
 =49190
(c) void Div_2_or_3 (int A [ ] [ ] , int N, int M)
 {
 int Sum=0;
 for (int i=0; i<N; i++)
 for (int j=0; j<M; j++)
 if (A [i] [ j ] %2= = 0 || A[i] [ j ] %3= =0)
 Sum=Sum+A[i][j];
 cout<<Sum;
 }

(d) void QueDel(MyNode*front)
 {
 MYNODE*temp;
 if (front==NULL)
 cout<<"Queue empty" else { temp=front; front=front—>Link;
 delete temp;
 }
 }

(e) Postfix expression :
5, 20, 15, -, *, 25, 2, *, +

Step Input Operation Stack Status
1 5 PUSH 5 5
2 20 PUSH 20 5   20
3 15 PUSH 15 5 20   15
4 POP 15
POP 20
Calculate:
20-15=5
PUSH 5 5 5
5 * POP 5
POP 5
Calculate:
5*5=25
PUSH 25 25
6  25 PUSH 25 25 25
7 2 Push 2 25 25 2
8 * POP2
POP 25
Calculate:
25*2=50
PUSH 50 25 50
9  + POP 50
POP 25
Calculate:
25 +50 = 75
PUSH 75 75

Ans. 75

Question 4.
(a) Write a definition for function Economic () in C++ to read each record of a binary file ITEMS. DAT, find and display those items, which costs less than 2500. Assume that the file is created with the help of objects of class ITEMS, which is defined below :

class ITEMS
 {
 int ID; char GIFT [20] ;float cost;
 public :
 void Get ()
 {
 cin>>ID;gets (GIFT) ;cin>>cost;
 }
 void See()
 {
 cout<<ID<<": "GIFT<<": "<<Cost<<endl;
 }
 float Get Cost()
 {
 return Cost;
 }
 }

(b) Write function definition for lower() in C++ to read the content of a text file Book.txt, and count all those leters which are in lowercase.
(c) Find the output of the following C++ code considering that the binary file CLIENTS.DAT exists on the hard disk with records of 100 members.

class Clients
 {
 int cno;charName[20];
 public:
 void In();void out();
 void main()
 {
 fstream CF;
 CF.open("CLIENTS.DAT",ios::binary : ios::in);
 CLIENTS C; ,
 CF.read((char*)&c;sizeof (c));
 CF.read ((char*) &c; sizeof (c) ) ;
 CF.read((char*)&C, sizeof (c));
 int P0S=CF.tellg()/sizeof (c);
 cout<<"PRESENT RECORD: "<<P0S<<endl;
 CF.close();
 }

Answer:

(a) void Economic()
 {
 ifstream f;
 f.open("ITEMS.DAT",ios::binary);
 ITEMS i;
 while(f.read((char*)&i, size of (i))
 {
 if(i.GetCost()<2500)
 i.See ();
 }
 f.close ();
 }

(b) Function in C++ to count the number of lowercase letters in a text file “Book. Txt”:

void lower()
 {
 char ch;
 int count =0;
 ifstream infile;
 infile.open ("Book.Txt") ;
 if (! infile)
 {
 cout << "can't open the file";
 exit ( ) ;
 }
 (while infile, get (ch) !=0)
 {
 if (islower(ch))
 {
 count ++;
 }
 }
 cout <<count;
 }

(c) POS=66/22 = 3
Ans:
Present Record: 3

SECTION B

Question 5.
(a) Give some advantages of DBMS.
(b) Consider the following tables consignor and consignee. Write SQL commands for the statements (i) to (iv) and give the outputs for SQL queries (v) to (viii):
Table: Consignor

CnorlD Cnor Name Cnor Address  City
ND 01 R singhal 24, ABC Enclave New Delhi
ND 02 Amit Kumar 133, Palm Avenue New Delhi
MU 15 R Kohli 5/A, South street Mumbai
MU 50 S Kaur 27-K, Westend Mumbai

Table: Consignee

Cnee ID Cnor ID Cnee Name Cnee Address Cnee City
MU 05 ND 01 Rahul Kishore 5, Park Avenue Mumbai
ND 08 ND 02 P Dhingra 16/J, Moore Enclave New Delhi
K 019 MU 15 APRoy 24, Central Avenue Kolkata
MU 32 ND02 S Mittal , P-254, AB Colony Mumbai
ND48 MU 50 BP Jain B, Block D, A vihar New Delhi

(i)To display the name of all consignors from Mumbai
(ii) To display the Cnee ID, Cnor Name, Cnor Address, Cnee Name, Cnee Address for every Consignee
(iii) To display consignee details in ascending order of Cnee Name
(iv) To display number of consignors from each city

(v) SELECT DISTINCT City FROM CONSIGNEE
 (vi) SELECT A. Cnor Name, B. Cnee Name
 FROM CONSIGNOR A, CONSIGNEE B
 WHERE A. Cnor ID=B. Cnor ID AND
 B. Cnee City='Mumbai';
 (vii) SELECT Cnee Name, Cnee Address
 FROM CONSIGNEE
 Where Cnee City Not ( 'Mumbai' , 'Kolkata' ) ;
 (viii) SELECT Cnee ID, Cnee Name
 FROM CONSIGNEE
 WHERE Cnor ID='MU 15' or Cnor ID='ND01'

Answer:
(a) Some of the advantages of DBMS are:
(i) DBMS helps to make the data management more efficiently and effectively.
(ii) DBMS provides end users better access to more and better managed data.
(iii) DBMS provides user security and data privacy within the database.
(iv) DBMS provides back up and recovery procedures to ensure data safety and integrity.

(b) (i) SELECT Cnor Name from CONSIGNOR WHERE CITY="Mumbai";
 (ii) SELECT B. Cneee.ID, A. Cnor Name, A.Cnor Address, B.Cnee Name, B.Cnee Address FROM CONSIGNOR A, CONSIGNEE B WHERE B. Cnor ID=A Cnor ID;
 (iii) SELECT * FROM CONSIGNEE
 ORDER BY Cnee Name;
 (iv) SELECT COUNT (City)
 FROM CONSIGNOR
 GROUP BY CITY;

(v) Mumbai
New Delhi
Kolkata
(vi) R Singhal
Rahul Kishore
Amit Kumar
S. Mittal
(vii) P Dhingra
16/j, Moore Enclave
BP Jain
13, Block D, A Vihar
(viii) K019
APROY
MU 05
Rahul Kishore

Question 6.
(a) Verify the following using Boolean Laws
X + Y’ = X.Y + X.Y’ + X’.Y’
(b) Write the Boolean Expression for the result of the Logic Circuit as shown below :
cbse-solved-papers-for-class-12-computer-science-c-paper-3-1
(c) Write the SOP form of a Boolean function F, which is represented in a truth table as follows:

A B C D
0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 1
1 1 0 0
1 1 1 0

(d) Reduce the following Boolean expression using K-map.
F (A, B, C, D) = I (0, 1, 2, 4, 5, 8, 9, 10, 11)

Answer:
(a) X + Y’ = X.Y + X.Y’ + X’.Y’
Taking R.H.S.
X.Y + X.Y’ + X’.Y’
= X (Y + Y’) + X’.Y’ (grouping)
= X (1) + X’.Y’ (X + X’ = 1)
= X + Y’ (Absorption law)
Hence Verified.

(b) ( (U+V’ ) . (U+W) ) . (V+W’ )
OR
(U+V’).(U+W).(V+W’)

(c) F=A’B’C+A’BC’+AB’C’+AB’C

(d) F (A,B,C,D) = X (0,1,2,4,5,8,9,10,11)
K-Map is as following:
cbse-solved-papers-for-class-12-computer-science-c-paper-3-2
F (A,B,C,D) = AC + AB + BD

Question 7.
(a) Explain one difference between circuit switching and packet switching.
(b) Write the following abbreviations in their full form:
FTP, WAN, WWW
(c) What is NFS?
(d) Write two advantages and two disadvantages of following topologies in network:
(i) BUS Topology
(ii) STAR Topology

Answer:
(a) Packet switching: Packet switching is a combination of both circuit and message switching and it divides the lengthy message in small parts known as Packets.
Circuit Switching: Circuit Switching establishes a communication path between sending and receiv¬ing computers. The path is connected sequence of links between different Switching Nodes.

(b) FTP stands for File Transfer Protocol WAN stands for Wide Area Network WWW stands for World Wide Web.

(c) NFS: NFS stands for Network File System. It is an operating system which allows all network users to access the shared files stored on different types of computers.
(d) Advantages of Bus Topology:
(a) Requirement of short length cable.
(b) Economical, cost of communication media is minimum.
(c) It is flexible and it is quite easy to add new nodes or delete node from the network.
Disadvantages of Bus Topology:
(a) Difficulty in detection of faults because of no centralize control.
(b) Fault in the backbone cable can disrupt the functioning of the whole network.
Advantages of Star Topology:
(a) One device per connection.
(b) Easy to access.
Disadvantages of Star Topology:
(a) Long Length Cables.
(b) Dependency on central node.
(e) (i) Suitable topology is-STAR Topology
cbse-solved-papers-for-class-12-computer-science-c-paper-3-3
(ii) The server should be paced in wing A as it has the maximum number of computers. According to 80 : 20 rule also, server should be placed on A wing.
(iii) The Hub should be placed at each wing of network.
cbse-solved-papers-for-class-12-computer-science-c-paper-3-4
(iv) (a) Private cloud : Private cloud is a cloud infrastructure operated only for a single organization whether managed internally or by a third party & hosted internally or externally.
(b) Public cloud: A cloud is called a public cloud when the services vendered over a network is open for public use. This is not confined to a particular organization or business.