0% found this document useful (0 votes)
110 views

CBSE Class 12 Computer Science Question Paper 2010 With Solutions

The document is a previous year question paper for Class 12 Computer Science from 2010. It contains 7 questions with multiple subparts. The questions test concepts in C++ programming like call by value vs call by reference, header files, classes, inheritance, arrays and functions. It provides code snippets and asks students to find outputs, identify errors, define classes and functions, and justify answers. The question paper follows the standard format for a Computer Science exam, with instructions, duration and marking scheme.

Uploaded by

Maha Maha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
110 views

CBSE Class 12 Computer Science Question Paper 2010 With Solutions

The document is a previous year question paper for Class 12 Computer Science from 2010. It contains 7 questions with multiple subparts. The questions test concepts in C++ programming like call by value vs call by reference, header files, classes, inheritance, arrays and functions. It provides code snippets and asks students to find outputs, identify errors, define classes and functions, and justify answers. The question paper follows the standard format for a Computer Science exam, with instructions, duration and marking scheme.

Uploaded by

Maha Maha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

CBSE Class 12

Computer Science
Previous Year Question Paper 2010
Series: OSS Code no. 91

● Please check that this question paper contains 16 printed pages.


● Code number given on the right hand side of the question paper should
be written on the title page of the answer-book by the candidate.
● Please check that this question paper contains 7 questions.
● Please write down the Serial Number of the question before
attempting it.
● 15 minutes time has been allotted to read this question paper. The
question paper will be distributed at 10.15 a.m. From 10.15 a.m. to
10.30 a.m., the students will read the question paper only and will not
write any answer on the answer-book during this period.

COMPUTER SCIENCE

Time Allowed: 3 hours Maximum Marks: 70


Instructions:
(i) All questions are compulsory.
(ii) Programming Language : C++

1. (a) What is the difference between call by value and call by reference?
Also, give a suitable C++ code to illustrate both. 2 Marks
Ans: Call by Value: A replica of the actual parameter is created by the formal
parameter. It has no effect on the actual parameter. If the modifications are made
using formal parameters.
Call by reference: Actual parameter is an alias for the formal parameter. The
formal parameter changes are reflected in the real parameter. & comes before it.

Class XII Computer Science www.vedantu.com 1


void Calculate (int A, int &B) //A is all by value,
{ //B is call by reference
A++;
a+=A;
}
(b) Which C++ header file(s) will be essentially required to be included to
run/execute the following C++ code: 1 Mark
void main ()
{
int Rno=24; char Name []="Amen Singhania";
cout<<setw(10)<<Rno<<setw(20)<<Name<<endl;
}
Ans: iostream.h
iomanip.h
(c) Rewrite the following C++ program code after removing the syntax
error(s) (if any). Underline each correction: 2 Mark
include <iostream.h>
class FLIGHT
{
long FlightCode;
char Description[25];
public
void Addinfo ()
{
cin>>FlightCode; gets(Description);
}
void Showinfo ()
}
cout<<FlightCode<<":"<<Description<<endl;

Class XII Computer Science www.vedantu.com 2


}
};
void main ()
{
FLIGHT F;
Addinfo. F (); Showinfo. F ();
}
Ans: # include <iostream.h> //Error 1
# include <stdio.h> //Error 2
class FLIGHT
{
long FlightCode;
char Description[25];
public: //Error 3
void Addinfo ()
{
cin>>FlightCode; gets(Description);
}
void Showinfo ()
}
cout<<FlightCode<<":"<<Description<<endl;
}
};
void main ()
{
FLIGHT F;
F.AddInfo (); F.Showinfo; //Error 4
}
(d) Find the output of the following program: 3 Marks

Class XII Computer Science www.vedantu.com 3


#include <iostream.h>
struct THREE D
{int X,Y,Z;};
void Movein(THREE_D &T, int Step=l)
{
T.X+=Step;
T.Y-=Step;
T.Z+=Step;
}
void MoveOut(THREE_D &T, "int Step =1)
{
T.X-=Step;
T.Y+=Step;
T.Z-=Step;
}
void main ()
{
THREE D Tl = {10, 20, 5}, T2= {30, 10, 40};
Movein (Tl);
Move0ut (T2, 5);
cout<<Tl.X<<", "<<T1.Y<<", "<<T1.Z<<endl;
cout<<T2. X<<", "<<T2. Y<<", "<<T2.Z<<endl;
Movein (T2, 10);
cout<<T2.X<<", 11 <<T2.Y<<", 11 <<T2.Z<<endl;
}
Ans: 11, 19, 6
25, 15, 35
35, 4, 45
(e) Find the output of the following program: 2 Marks

Class XII Computer Science www.vedantu.com 4


#include <iostream.h>
#include <ctype.h>
void MyCode(char Msg[],char CH)
{
for (int Cnt=O;Msg [Cnt] !=' \0' ;Cnt++)
{
if (Msg [Cnt]>='B' && Msg [Cnt]<='G')
Msg [Cnt] = tolower (Msg [Cnt]);
else
if (Msg [Cnt] =='A' I I t-1sg [Cnt] =='a')
Msg[Cnt]=CH;
else
if (Cnt%2==0)
Msg [Cnt] = toupper(Msg[Cnt]);
else
Msg [Cnt] = Msg[Cnt-1];
}
}
void main ()
{
char MyText [] =" ApEACeDri VE";
MyCode (MyText, '@');
cout<<"NEW TEXT: "<<MyText<<endl;
}
Ans: NEW TEXT: @@e@ccddlle
(f) The following code is from a game, which generates a set of 4 random
numbers. Praful is playing this game, help him to identify the correct
option(s) out of the four choices given below as the possible set of such
numbers generated from the progratn code so that he wins the game. Justify
your answer. 2 Marks

Class XII Computer Science www.vedantu.com 5


#include <iostream.h>
#include <stdlib.h>
const int LOW=25; -
void main ()
{
randomize();
int POINT=S, Number;
for (int I=l;I<=4;I++)
{
Nurnber=LOW+random(POINT);
cout<<Nurnber<<":";
POINT--;
}
}
(i) 29:26:25:28:
(ii) 24:28:25:26:
(iii) 29:26:24:28:
(iv) 29:26:25:26:
Ans: (iv) 29:26:25:26:
Justification:
I POINT Number
Minimum Maximum
1 5 15 19
2 4 15 18
3 3 15 17
4 2 15 16

Option is the only one that meets these criteria (iv).

2. (a) What do you understand by Data Encapsulation and Data Hiding?


Also, give an example in C++ to illustrate both. 2 Marks

Class XII Computer Science www.vedantu.com 6


Ans: Data Encapsulation: Data encapsulation is the process of combining data
and functions into a single entity. In a class, the data and functions are combined
into a single entity.
Data Hiding: Data hiding is the process of keeping data in the class's
private/protected visibility mode to prevent it from being accidentally changed.
(b) Answer the questions (i) and (ii) after going through the following class:
2 Marks
class Exam
{
int Rno,MaxMarks,MinMarks,Marks;
public:
Exam () I /Module 1
Rno=101; MaxMarks = lOO;MinMarks=4 0 ;Marks=7 5 ;
Exam (int Prno, int Pmarks) I /Modul e 2
Rn o=Prno; MaxMarks=lOO;MinMarks=40 ;Marks=Pmarks;
-Exam () I /Module 3
cout<<"Exam Over" <<endl;
void Show () I /Module 4
cout<<Rno<<":"<<MaxMarks<<":"<<MinMarks<<endl;
cout<<" [Marks Got] " <<Marks<<endl;
(i) As per Object Oriented Programming, which concept is illustrated by
Module 1 and Module 2 together?
Ans: Polymorphism
(ii) What is Module 3 referred as? When do you think, Module 3 will be
invoked/called?
Ans: Destructor, It is called as soon as the object's scope expires.
(c) Define a class STOCK in C++ with following description: 4 Marks
Private Members
● I Code of type integer (Item Code)
● Item of type string (Item Name)

Class XII Computer Science www.vedantu.com 7


● Price of type float (Price of each item)
● Qty of type. integer (Quantity in stock)
● Discount of type float (Discount· percentage on the itedi)
● A member function FindDisc() to calculate discount per the following
rule:
If Qty<=50 Discount is 0
If 50<Qty<=100 Discount is 5
If Qty>lOO Discount is 10
Public Members
● A function Buy () to allow user to enter values for ICode, Item, Price,
Qty and call function FindDisc () to calculate the Discount.
● A function ShowAll () to allow user to view the content of all the data
members.
Ans: class STOCK
{
int ICode, Qty;
char Item[20];
float Price, Discount;
void FindDisc ();
public:
void Buy ();
void ShowAll ();
};
void STOCK::Buy ()
{
cin>>ICode;
gets (Item);
cin>>Price;
cin>>Qty;
FindDisc ();

Class XII Computer Science www.vedantu.com 8


}
void STOCK::FindDisc ()
{
if (Qty<=50)
Discount = 0;
else if (Qty<=100)
Discount = 5; // = 0.05;
else
Discount = 10; // = 0.1;
}
void STOCK::ShowAll ()
{
cout<<ICode<< ‘\t’ <<Item<< ‘\t’<< Price<< ‘\t’ <<Qty
<< ‘\t’<<Discount<<endl;
}
(d) Answer the questions (i) to (iv) based on the following: 4 Marks
class Director
{
long DID; //Director Identification Number
char Name[20];
protected:
char Description [40] ;
void Allocate ();
public:
Director ();
void Assign () ;
void Show () ;
}
class Factory:public Director

Class XII Computer Science www.vedantu.com 9


{
int FID; I / Factory ID
char Address[20];
protected:
int NOE; //No. of Employees
public:
Factory();
void Input () ;
void Output () ;
};
class ShowRoom:private Factory
{
int SID; //Showroom ID
char City[20];
public:
ShowRoom ();
void Enter () ;
void Display ();
};
(i) Which type of inheritance out of the following is illustrated in the above
C++?
a) Single Level Inheritance
b) Multilevel Inheritance
c) Multiple Inheritance
Ans: (b) Multilevel Inheritance
(ii) Write the names of members, which are accessible objects of class type
ShowRoom.
Ans: None
(iii) Write the names of all member functions which are accessible by data
type ShowRoom.

Class XII Computer Science www.vedantu.com 10


Ans: Enter (), Display ()
(iv) Write the names of alfmembers, which accessible member functions of
Factory.
Ans: FID, Address, NOE, Description, Input (), Output (), Assign (), Show (),
Allocated ()

3. (a) Write a function REASSIGNO () in C++, which accepts an array


integers and its size as parameters and divide all those elements by 5 which
are divisible by 5 and multiply other array elements by 2. 3 Marks
Sample Input Data of the array
A[0] A[1] A[2] A[3] A[4]
21 12 35 42 18

Content of the array after Calling REASSIGN () function


A[0] A[1] A[2] A[3] A[4]
4 24 3 12 64

Ans: void REASSIGN (int Arr[], int Size)


{
for (int i=0; i<Size; i++)
if (Arr[i]%5==0)
Arr[i]/= 5;
else
Arr[i]*= 2;
}
(b) An array T [90][100] is stored in the memory along the column with each
of the elements· occupying 4 bytes. Find out the memory location for the
element T[l0][ 40], if the Base Address of the array is 7200. 3 Marks
Ans: Loc (T [I][J]) = Base (T) + W (I + J * N)
(where N is the number of rows, LBR = LBC = 0)
= 7200 + 4[10 + 40 × 90]385
= 7200 + 4[10 + 3600]

Class XII Computer Science www.vedantu.com 11


= 7200 + 4 × 3610
= 7200 + 14440
= 21640
(c) Write a complete program in C++ to implement a dynamically allocated
Queue containing names of Cities. 4 Marks
Ans: # include <iostream.h>
# include<conio.h>
struct NODE
{
char City[20];
NODE * Next;
};
class Queue386
{
NODE * Rear, *Front;
puplic:
Queue () {Rear= NULL; Front = NULL ;}
void Qinsert ();
void Qdelete ();
void Qdisplay ();
~ Queue ();
};
void Queue:: Qinsert ()
{
NODE *Temp;
Temp = new NODE;
cout<< “Data:”;
gets (Temp->City);
Temp->Next = NULL;

Class XII Computer Science www.vedantu.com 12


if (Rear = NULL)
{
Rear = Temp;
Front = Temp;
}
else
{
Rear->Next = Temp;
Rear = Temp;
}
}
void Queue::Qdelete ()
{
if (Front!= NULL)
{
NODE * Temp = Front;
cout<<Front->City<< “Deleted\n”;
Front = Front->Next;
delete Temp;
if (Front = NULL) Rear = NULL;
}
else
cout<< “Queue Empty.”;
}
Queue:: Qdisplay ()
{
NODE *Temp = Front;
while (Temp!= NULL)
{

Class XII Computer Science www.vedantu.com 13


cout<<Temp->City<<endl;
Temp = Temp->Next;
}
}
Queue:: ~ Queue () //Destructor Function
{
while (Front! = NULL)
{
NODE *Temp = Front;
Front = Front->Next; delete Temp
}
}
void main ()
{
Queue QU; char Ch;
do
{
:
:
} while (Ch! = ‘Q’);
}
(d) Write a function int ALTERSUM (int B [][5 ], int N, int M in C++ to find
and return the sum of elements from all alternate elements of a two-
dimensional array starting from B[0][0]. 2 Marks
Hint:
If the following is the content of the array
B[0][0] B[0][1] B[0][2]
4 5 1
B[1][0] B[1][1] B[1][2]
2 8 7

Class XII Computer Science www.vedantu.com 14


B[2][0] B[2][1] B[2][2]
9 6 3

The function should add elements B[0][0], B[0][2], B[l][l], B[2][0] and
B[2][2].
Ans: // Sample Code 1
int ALTERSUM (int B[][5], int N, int M)
{
int Sum = 0;
for (int I=0; I<N; I++)
for (int J= (I%2==0) ?0:1; J<M; J+=2)
Sum+= B[I][J];
return Sum;
}
(e) Evaluate the following postfix notation of expression: 2 Marks
(Show status of Stack after each operation)
True, False, NOT, OR, False, True, OR, AND
Ans:

Element Scanned Stack


True True
False True, False
NOT True, True
OR True, False
False True
True True, False, True
OR True, True
AND True

4. (a) Observe the program segment given below carefully and fill the blanks
marked as Statement 1 and Statement 2 using tellg() and seekp() functions
for performing the required task. 1 Mark
#include <fstream.h>
class Customer

Class XII Computer Science www.vedantu.com 15


{
long Cno;char Name [20] ,Mobile [12] ;
public:
/ /Function to all ow user to enter the Cno, Name,
Mobile
void Enter ();
//Function to allow user to enter (modify) mobile number void Modify ();
// Function to return value of Cno
long GetCno() {return Cno ; }
};
void ChangeMobile()
{
Customer C;
fstream F;
F. open (“CONTACT. DAT’’, ios: :binary |ios: :in| ios: :out) ;
long Cnoc; //Customer no. whose mobile number needs to be changed
cin>>Cnoc;
while (F.read((char*)&C,sizeof(C)))
{
if (Cnoc==C.GetCno())
{
C.Modify();
//Statement 1
int Pos= _____________//To finq the current position of file pointer
//Statement 2
//To move the file pointer to write the
//modified record back onto the file
//for the desired Cnoc ·
F.write((char*)&C,sizeof(C));

Class XII Computer Science www.vedantu.com 16


}
}
F.close();
}
Ans: Statement 1:
File.tellg ();
Statement 2:
File.seekp (Pos-sizeof (C));
(b) Write a function in C++ to count the words “to” and “the” present in a
text file “POEM.TXT”. 2 Marks
[Note that the words “to” and “the” are complete words]
Ans: void COUNT ()
{
ifstream File;
File. open (POEM.TXT);
char Word[80] ;
int Cl = 0, C2 = 0;
while(!File.eof())
{
File>>Word;
if (strcmp (Word, to) ==0)
Cl++;
else
if (strcmp (Word, the) ==0)
C2++;
}
cout<<”Count of -to- in file:" <<C1;
cout<<”Count of -to- in file:" <<C2;
File.close (); //Ignore

Class XII Computer Science www.vedantu.com 17


(c) Write a function in C++ to search and display details of all trains, whose
destination is “Delhi” from a binary file “TRAIN.DAT”. Assuming the
binary file is containing the objects of the following class. 3 Marks
class TRAIN
{
in Tno; //Train Number
charFrom[20]; //Train Starting Point
charTo[20]; //Train Destination
public:
char* GetFrom () {return From;}
char* GetTo () {return To;}
void Input () {cin>>Tno;gets (From);gets (To);}
Show () {cout<<Tno<< “:”<<From<< “:”<<To<<endl;}
};
Ans: void Read ()
{
TRAIN T;
ifstream fin;
fin.open (“TRAIN.DAT”, ios::binary);
while (fin.read ((char*)&T, sizeof (T)))
{
if (strcmp (T.GetTo (), “Delhi”)==0)
T.Show (); 399
}
fin.close (); //Ignore
}

5. (a) What do you understand by Primary Key? Give a suitable example of


Primary Key from a table containing some meaningful data.
2 Marks

Class XII Computer Science www.vedantu.com 18


Ans: Primary Key refers to an attribute or collection of attributes that are used to
uniquely identify a tuple.
Table: Item
Ino Item Qty
101 Pen 300
102 Pencil 780
104 CD 450
109 Floppy 700

(b) Consider the following tables STOCK and DEALERS and answer (b1)
and (b2) parts of this question:
Table: STOCK
Item No Item Dcode QTY UnitPrice StockDate
5006 Ball Pen 0.5 102 100 16 31-Mar-10
5003 Ball Pen 0.25 102 150 20 01-Jan-10
5002 Gel Pen Prenium 101 125 14 14-Feb-10
5006 Gel Pen Classic 101 200 22 10-Jan-09
5001 Eraser Small 102 210 5 19-Mar-09
5004 Eraser Big 102 60 10 12-Dec-09
5009 Sharpener Classic 103 160 8 23-Jan-09

Table: DEALERS
Dcode Dname
101 Reliable Stationers
103 Classic Plastics
102 Clear Deals

(b1) Write SQL commands for the following statements: 4 Marks


(i) To display details of all Items in the Stock table in ascending order of
StockDate.
Ans: SELECT* FROM STOCK ORDER BY StockDate;
(ii) To display ItemsNo and Item name of those items from Stock table whose
UnitPrice is more than Rupees 10.
Ans: SELECT ItemNo, Item FROM STOCK WHERE UnitPrice>10;
(iii) To display the details of those Items whose dealer code (Dcode) is 102 or
Quantity in Stoc (Qty) is more than 100 from the table Stock.

Class XII Computer Science www.vedantu.com 19


Ans: SELECT* FROM STOCK WHERE Dcode = 101 OR Qty>100;
(iv) To display Maximum UnitPrice of Items for each dealer individually as
per Dcode from the table Stock.
Ans: SELECT Dcode, MAX (UnitPrice) FROM STOCK GROUP BY Dcode;
(b2) Give the output of the following SQL queries: 2 Marks
(i) SELECT COUNT (DISTINCT Dcode) FROM Stock;
Ans: Count (DISTINCT Dcode)
(ii) SELECT Qty* UnitPrice FROM Stock WHERE ItemNo = 5006;
Ans: Qty*UnitPrice
4400
(iii) SELECT Item, Dname FROM Stock S, Dealers D
WHERE S.Dcode = D.Dcode AND ItemNo = 5004;
Ans: Item Dname
Eraser Big Clear Deals
(iv) SELECT MIN (StockDate) FROM Stock;
Ans: MIN (StockDate)
01-Jan-09

6. (a) Verify the following algebraically: 2 Marks


X’.Y + X.Y’ = (X’ + Y’). (X+ Y) 402
Ans: R.H.S
(X’ + Y’). (X+ Y)
= X’. (X + Y) + Y’. (X + Y)
= X.X’ + X’.Y + Y’.X + Y’.Y
= X’.Y + Y’.X
= X’.Y + X.Y’
So L.H.S. = R.H.S.
(b) Write the equivalent Boolean Expression for the following Logic Circuit:
2 Marks

Class XII Computer Science www.vedantu.com 20


Ans: (U’ + V).(V’ + W)
(c) Write the SOP form of a Boolean function G, which is represented in a
truth table as follows:
P Q R G
0 0 0 0
0 0 1 0
0 1 0 1
0 1 1 1
1 0 0 1
1 0 1 0
1 1 0 1
1 1 1 1

Ans: G (P, Q, R) = P’.Q.R’+P’.Q.R+P.Q’.R’+P.Q.R’+P.Q.R


(d) Reduce the following Boolean Expression using K-Map: 3 Marks
F (A, B, C, D) = Σ (3, 4, 5, 6, 7, 13, 15)
Ans: G (P, Q, R) = Σ (2, 3, 4, 6, 7)
F (A, B, C, D) = A’B + BD + A’CD

7. (a) What was the role of ARPANET in the Computer Network? 1 Mark
Ans: Advanced Research Project Agency Network (ARPANET) is an acronym
for Advanced Research Project Agency Network. It is a project started in 1969
by the US Department of Defense to connect computers at various institutions
and the US Department of Defense. NSFnet was founded in the 1980s with the
goal of creating a high-capacity network that could outperform ARPANET.
ARPANET, NSFnet, and other private networks interconnected in the 1990s to
form the internet.

Class XII Computer Science www.vedantu.com 21


(b) Which of the following is not a unit for data transfer rate? 1 Mark
(i) mbps
(ii) kbps
(iii) sbps
(iv) gbps
Ans: (iii) sbps
(c) What is the difference between Virus and Worms in the computers?
1 Mark
Ans: Virus: A virus is a malicious programme that corrupts data and files while
also causing damage to the computer system.
Worms: Worms disrupt services and cause issues with system management.
Worms can, in rare situations, install viruses that harm the system.
(d) What term do we use for a software/hardware device, which is used to
block unauthorized access while permitting authorized communications?
This term is also used for a device or set of devices configured to permit,
deny, encrypt, decrypt, or proxy all (in and out) computer traffic between
different security domains based upon a set of rules and other criteria.
1 Mark
Ans: Firewall
(e) “Vidya for All” is an educational NGO. It is setting up its new campus at
Jaipur for its web-based activities. The campus has four buildings as shown
in the diagram below: 4 Marks

enter to center distances between various buildings as per architectural


drawings (in meters) follows:
Main Building to Resources Building 120 m
Main Building to Resources Building 40 m

Class XII Computer Science www.vedantu.com 22


Main Building to Accounts Building 135 m
Resources Building to Training Building 125 m
Resources Building to Accounts Building 45 m
Training Building to Accounts Building 110 m

Expected Number of Computers in each Building is as follows:


Main Building 15
Resources Building 25
Training Building 250
Accounts Building 10

(e1) Suggest a cable layout of connections between the buildings.


Ans:

(e2) Suggest the most suitable place (i.e. building) to house the server for this
NGO. Also, provide a suitable reason for your suggestion.
Ans: Because it has the most computers, the Training Building is the best option.
(e3) Suggest the placement of the following devices with justification:
(i) Repeater
(ii) Hub/Switch
Ans: (i) Repeater: When the distance between any two connecting buildings
reaches 70 metres, a Repeater should be installed.
(ii) Hub/Switch: Every building will require one Hub/Switch to provide signals
to all connected workstations.
(e4) The NGO is planning to connect its International office situated in Delhi.

Class XII Computer Science www.vedantu.com 23


Which out of the following wired communication links, will you suggest for
a very high speed connectivity?
(i) Telephone Analog Line
(ii) Optical Fibre
(iii) Ethernet Cable
Ans: (iii) Optical Fibre
(f) Write the full forms of the following: 1 Mark
(f1) FTP
(f2) FSF
Ans: (f1) File Transfer Protocol
(f2) Free Software Foundation
(g) Name any two common Web browsers. 1 Mark
Ans: Internet Explorer, Chrome

Class XII Computer Science www.vedantu.com 24

You might also like