You are on page 1of 20

KENDRIYA VIDYALAYA SANGATHAN CHENNAI REGION

Class XII- COMMON PRE – BOARD EXAMINATION- 2013-14


MARKING SCHEME
SUBJECT : COMPUTER SCIENCE TIME : 3 HRS MAX MARKS : 70
Instructions :
(i) All questions are compulsory.
(ii) Programming language C++.

1. (a) What is a reference variable? Illustrate it with one suitable example in C++. 2

Answer :
A reference is an alternative name for an object. A reference variable provides an alias for
a previously defined variable. A reference declaration consists of a base type , an &
(ampersand), a reference variable name equated to a variable name (previously defined).
The general format of declaring a reference variable is :
Type & reference-variable = variable name.
Example :
void main() {
int a = 10;
int & r = a;
r = 20;
cout<<a;
}
Output will be 20 because r is reference of a so when we assign 20 in r actually is change
the value of a.
1 marks for definition
1 marks for example
(b) Observe the following C++ code and write the name(s) of the header file(s), which will be 1
essentially required to run is in a C++ compiler:

void main(){
int n,i;
for (i=1;i<10;i++) {
n = random(100);
cout<<endl<<n;
if(n==50)
exit(0);
}
}

Page 1 of 20

Page 1 of 20
Answer :
#include<stdlib.h>
#include<iostream.h>
½ marks for each header file
(c) Rewrite the following program after removing the syntactical errors (if any). Underline 2
each correction.
structure Student
{
int rollno;
char name(20);
float marks;
}

void main(){
Student st(10);
}

Answer :
struct Student
{
int rollno;
char name[20];
float marks;
};

void main(){
Student st[10];
}
½ marks for each correction.

(d) Find the output of the following program: 3


#include<iostream.h>
#include<string.h>
#include<ctype.h>
void show(char s[]){
int l = strlen(s);
int i;
for(i=0;i<l;i++){
if(s[i]%2) {
Page 2 of 20

Page 2 of 20
s[i] = tolower(s[i]);
}
else {
s[i] = toupper(s[i]);
}
}
}
void main(){
char s[10] = "Computer";
show(s);
cout<<s;
}

Answer :
comPuTeR
3 marks for correct answer.
(e) Find the output of the following program: 2
#include<iostream.h>
#include<string.h>
#include<ctype.h>
struct point {
int x;
int y;
};

void change(point p,int ix,int iy){


p.x += ix;
p.y+=iy;
}
void show(point p){
cout<<"\nX : "<<p.x;
cout<<"\nY : "<<p.y;
}
void main() {
point p1={10,20};
change(p1,3,6);
show(p1);
change(p1,-5,-10);
show(p1);
}
Answer :
Page 3 of 20

Page 3 of 20
X : 10
Y : 20
X : 10
Y : 20
½ marks for each correct answer.

(f) Go through the C++ Code shown below & find the possible output from the suggested 2
output options (i) to (iv).
#include<iostream.h>
#include<stdlib.h>
void main( )
{
randomize( );
int num, max = 5;
num = 20 + random(max);
for(int n = num; n <= 25; n++)
cout<<n<<”*”;
}
i) 20*21*22*23*24*25 ii) 22*23*24*25* iii) 23*24* iv)
21*22*23*24*25

Answer :
ii) 22*23*24*25*
2 marks for correct answer.

2. (a) What is copy constructor? Explain it with suitable example in C++. 2


Answer :
1 marks of definition of copy constructor
1 marks for example
(b) Answer the questions (i) and (ii) after going through the following class: 2
class keyboard {
int noofkey;
char type[10];
public:
keyboard(); // function 1
keyboard(int n,char * s); // function 2
keyboard(keyboard t); // function 3
}
(i) Write the complete definition of function 3
(ii) Write the main program to call the function 2

Answer :

Page 4 of 20

Page 4 of 20
(i) Keyboard(keyboard t) {
Noofkey = t.noofkey;
strcpy(type,t.type);
}
(ii) void main() {
keyboard(101,”Multimedia”);
}
(c) Define a class Sales in C++ with the description given below : 4
private members
tid integer
cname array of 20 characters
rate float
qty integer
discount float variable
netamt float variable
calcr() a function which will calculate discount amount and net
amount based on following discount rate:
S. No. Sales upto Discount in %
1 10000 5
2 50000 10
3 200000 12
4 500000 15
5 >500000 20

public members
newsales () function to ask and store the values of tid, cname,
rate and qty and call the calc() to calculate the
discount amount and net sales amount.
display() function to which will display the details.

Also create main() function which will invoke all the public member functions.
Answer :
#include <iostream.h>
#include <stdio.h>
class sales {
int tid;
char cname[20];
int qty;
float rate;
float discount;
float netamt;
void calc() {
Page 5 of 20

Page 5 of 20
float t;
t = rate * qty;
if(t<=10000){
discount = t*.05;
}
else if(t<=50000){
discount = t*.1;
}
else if(t<=200000){
discount = t*.12;
}
else if(t<=500000){
discount = t*.15;
}
else {
discount = t*.2;
}
netamt = t-discount;
}
public:
void newsales() {
cout<<"\n Enter transaction ID";
cin>>tid;
cout<<"\n Enter customer name";
gets(cname);
cout<<"\n Enter quantity";
cin>>qty;
cout<<"\n Enter rate";
cin>>rate;
calc();
}
void show() {
cout<<"\n Transaction ID : "<<tid;
cout<<"\n Customer Name : "<<cname;
cout<<"\n Quantity : "<<qty;
cout<<"\n Rate : "<<rate;
cout<<"\n Discount Amount : "<<discount;
cout<<"\n Net Sales : "<<netamt;
}

};
Page 6 of 20

Page 6 of 20
void main (){
sales s;
s.newsales();
s.show();
}

(d) Answer the questions (i) to (iv) based on the following code : 4
class Employee
{
int id;
protected :
char name[20];
char doj[20];
public :
Employee();
~Employee();
void get();
void show();
};
class Daily_wager : protected Employee
{
int wphour;
protected :
int nofhworked;
public :
void getd();
void showd();
};
class Payment : private Daily_wager
{
char date[10];
protected :
int amount;
public :
Payment();
~Payment();
void show();
};
Page 7 of 20

Page 7 of 20
(i) Name the type of Inheritance depicted in the above example.
Answer :
Multi Level

(ii) Name the member functions accessible through the object of class Payment.

Answer :
Payment(), ~Payment, void show().
(iii) From the following, Identify the member function(s) that can be called directly from
the object of class Daily_wager class
show()
getd()
get()
answer :
getd()

(iv) What is the size of object of class Payment?

Answer :
(42+4+12) = 58 Bytes
3. (a) Given two arrays of integers x and y of sizes m and n respectively. Write a function named 3
MERGE( ) which will produce a third array named z, such that the following sequence is
followed:
(i) All odds numbers of x from left to right are copied into z from left to right.
(ii) All even number of x from left to right are copied into z from right to left.
(iii)All odd numbers of y from left to right are copied into z from left to right.
(iv)All even number of y from left to right are copied into z from right to left.
Eg: x is{3,2,1,7,6,3}
And y is {9,3,5,6,2,8,10}
Then z = {3,1,7,3,9,3,5,10,8,2,6,6,2}

Answer :

#include<iostream.h>
int const m=6;
int const n=7 ;
int x[m] = {3,2,1,7,6,3};
int y[n] = {9,3,5,6,2,8,10};
int z[m+n];

Page 8 of 20

Page 8 of 20
void merge() {
int i,j=(m+n)-1,k=0;

for(i=0;i<m;i++){
if(x[i]%2==0){
z[j]=x[i];
j--;
}
else{
z[k]=x[i];
k++;
}
}
for(i=0;i<n;i++){
if(y[i]%2==0){
z[j]=y[i];
j--;
}
else{
z[k]=y[i];
k++;
}
}
}
void main(){
merge();
int i;
for(i=0;i<m+n;i++){
cout<<endl<<z[i];
}
}
(b) An array ARR[15][20] is stored in the memory, along the row with each element 3
occupying 4 bytes . Find out the base address and the address of the element ARR[3][2] if
the element ARR[5][2] is stored at the address 1500.

Answer :
(I)
B+W(C(I-LR)+(J-LC))
ARR[5][2] = 1500
1500 = B+4(20(5-0)+(2-0))
1500 = B+4(20(5)+2)
Page 9 of 20

Page 9 of 20
1500 = B+4(100+2)
1500 = B +4*102
1500 = B+408
B=1500-408
B=1092
(II)
B+W(C(I-LR)+(J-LC))
1092+4(20(3-0)+(2-0))
1092+4(20*3+2)
1092+4(60+2)
1092+4*62
1092+248
ANSWER : 1340

(c) An array of a structure Student, S is required to be arranged in descending order of marks. 2


Write a C++ function to arrange the same with the help of bubble sort. The array and its
size are required to be passed as parameters to the function.
Definition of structure student is as follows
struct Student
{
int rollno;
char name[20];
float marks;
};

Answer :
void sort(Student t[],int s){
int i,j;
Student tmp;
for(i=0;i<s;i++){
for(j=0;j<s-(i+1);j++) {
if(t[j].marks<t[j+1].marks){
tmp = t[i];
t[i] = t[j];
t[j] = tmp;
}
}
}
}
(d) Evaluate the expression 5, 6, 2, +, *, 12, 4, /,- in tabular form showing stack after every 2
step.
Page 10 of 20

Page 10 of 20
Answer :
Step Data Stack Output
1. 5 5
2 6 5,6
3 2 5,6,2
4 + 5 6+2 = 8
5 5,8
6 * 5x8 = 40
7 40
8 12 40,12
9 4 40,12,4
10 / 40, 12/4=3
11 40,3
12 - 40-3=37
13 37
14 37 result
(e) Define member functions push() to insert nodes and pop() to delete nodes of the linked 4
list implemented class stack, where each node has the following structure :
struct node {
char name[10];
int age;
node * link;
};
class stack{
node * top;
public:
stack(){top = NULL;}
void push();
void pop(); };

Answer :
#include<iostream.h>
struct node {
char name[10];
int age;
node * link; };
class stack{
node * top;
public:
stack(){top = NULL;}
void push();

Page 11 of 20

Page 11 of 20
void pop();
void show();};
void stack :: push(){
node * n = new node;
if(n==NULL){
cout< <"\n Over flow"; }
else {
cout<<"\n Enter name";
cin>>n->name;
cout<<"\n Enter age";
cin>>n->age;
n->link = NULL;
if(top == NULL){ top = n; }
else {
n->link = top;
top = n; } } }

void stack :: pop() {


if(top==NULL){
cout<<"\n Under flow"; }
else {
cout<<endl<<"Delete";
cout<<top->name<<" ";
cout<<top->age;
top = top->link; }}
void stack :: show() {
node * t = new node;
t = top;
if(t==NULL) { cout<<"\n Under flow"; }
else {
cout<<endl<<"SHOW";
while(t!=NULL){
cout<<t->name;
cout<<" "<<t->age<<endl;
t = t->link; } }}

void main() {
stack s1;
s1.pop();
s1.push();
s1.push();
Page 12 of 20

Page 12 of 20
s1.push();
s1.show();
s1.pop();
s1.show();
s1.pop();
s1.show();
s1.pop();
s1.show();
s1.pop(); }
4. (a) Observe the program segment carefully and answer the question that follows: 1
class item
{
int item_no;
char item_name[20];
public:
void enterDetail( );
void showDetail( );
int getItem_no( ){ return item_no;}
};
void modify(item x, int y )
{
fstream File;
File.open( “item.dat”, ios::binary | ios::in | ios::out) ;
item i;
int recordsRead = 0, found = 0;
while(!found && File.read((char*) &i , sizeof (i)))
{
if(i . getItem_no( ) = = y )
{
_________________________//Missing statement
File.write((char*) &x , sizeof (x));
found = 1;
}
recordsRead++;
}
if(! found)
cout<<”Record for modification does not exist” ;
File.close() ;
}
If the function modify( ) is supposed to modify a record in the file “ item.dat “, which
item_no is y, with the values of item x passed as argument, write the appropriate
Page 13 of 20

Page 13 of 20
statement for the missing statement using seekp( ) or seekg( ), whichever is needed, in
the above code that would write the modified record at its proper place.

Answer :
File.seekp(recordRead*sizeof(x),ios::beg);

(b) Write a function in C++ to print the count of the word “and” in the text file “Myfile.txt”. 2

Answer :

#include<iostream.h>
#include<fstream.h>
#include<ctype.h>
#include<string.h>

void main() {

ifstream fin;
fin.open("myfile.txt");
if(fin==NULL){
cout<<"\n Unable to open the file";
}
else {
char w[100];
int n=0;
while(fin){
fin.getline(w,100,' ');
if(strlen(w)==3){
if(strcmp(w,"and")==0)
n++;
}
}
cout<<endl<<n;
fin.close();
}
}

(c) Given the binary file TELEPHONE.DAT , containing the records of the following class 3
Directory:
Page 14 of 20

Page 14 of 20
class Directory
{
char name[20];
char address[30];
char areaCode[5];
char phone_no[15];
public:
void reg( );
void show( );
int checkCode( char AC[] )
{
return strcmp(areaCode, AC);
}
};
Write a function COPYABC( ) in C++ , that would copy only those records having areaCode
as “123” from TELEPHONE.DAT to TELEBACK.DAT.

Answer :
void copyabc(){
ifstream fin("telephone.dat",ios::binary);
ofstream fout("teleback.dat",ios::binary);
if((fin==NULL)||(fout==NULL)) {
cout<<"\n Unable to open the file";
}
else {
Directory d;
while(fin){
fin.read((char *)&d,sizeof(d));
if(d.checkCode("123")==0){
fout.write((char *)&d,sizeof(d));
}
}
fin.close();
fout.close();
}
}
void main(){
copyabc();
}
5. (a) What do you understand by DOMAIN and TUPLE of a RELATION? 2

Page 15 of 20

Page 15 of 20
Answer :
Domain : a domain is a set of values from which the actual values appearing in a given
column are drawn.
Tuple : the rows of table are generally referred to as tuples.
1 marks for each.

(b) (i) SELECT GameName, Name,GAMES.GCode, Type from GAMES, PLAYER where 4
ScheduleDate BETWEEN ‘2003-12-31’ AND ‘2004-02-20’;

(ii) Select * from GAMES where PrizeMoney> 7000;

(iii) Select * from GAMES order by ScheduleDate;

(iv) Select SUM(PrizeMoney), Type from GAMES group by Type;

1 mark for each correct answer

(c) (i) Indoor 9000 2

Outdoor 25000

(ii) 3

(iii) Table Tennis

Lawn Tennis

(iv) Indoor

Indoor

1/2 mark for each correct answer


(a) Prove (x+y)(x+z) = x+yz by using truth table. 2
6. Answer :
x y z x+y x+z (x+y)(x+z) yz x+yz
0 0 0 0 0 0 0 0
0 0 1 0 1 0 0 0
0 1 0 1 0 0 0 0
0 1 1 1 1 1 1 1
1 0 0 1 1 1 0 1
1 0 1 1 1 1 0 1
1 1 0 1 1 1 0 1
1 1 1 1 1 1 1 1

Page 16 of 20

Page 16 of 20
2

z
(b)
Draw the Logical circuit of the following expression with the help of NOR gate only :
x + y’. z

(c) Obtain the simplified form of a Boolean expression using K-Map. 3


answer : F(A,B,C,D)= ∏(0,1,2,3,4,7,11,12,14)

ANSWER :

C+D 00 C+D’ 01 C’+D’ 11 C’+D 10


A+B 00 0 0 0 0
A+B’ 01 0 1 0 1
A’+B’ 11 0 1 1 0
A’+B 10 1 1 0 1

(A+B) .(A+C’+D’). (B+C’+D’) .(B’+C+D).(A’+B’+D)

(½ Mark for representing the terms in K-Map)

(½ Mark for obtaining each reduced term i.e. 5X ½ = 2½ Marks for reducing

to the correct minimal form)

(d) 1
Write the POS and the SOP forms of a Boolean function F, which is represented in a truth
table as follows:

Page 17 of 20

Page 17 of 20
X Y Z F
0 0 0 0
0 0 1 1
0 1 0 0
0 1 1 1
1 0 0 1
1 0 1 0
1 1 0 1
1 1 1 1

Answer :

SOP : x’y’z + x’yz+xy’z’+xyz’+xyz


POS : (x+y+z).(x+y’+z).(x’+y+z’)
½ marks for each correct answer.
7. (a) Expand the following terminology 1
(i) XML
(ii) GSM
Answer :
XML : Extensible Markup Language
GSM : Global System for Mobile

½ marks for each.


(b) Describe any two Cyber Crime. 1
Answer :
1. Tampering with computer source documents.
2. Hacking
3. Publishing of information, which is obscene in electronic form
4. Child pornography
5. Accessing protected system
6. Breach of confidentiality and privacy

½ marks for each total 2.

(c) What is FLOSS and OSS software? 2


Answer :
OSS : Open Source Software which refers to software whose source code is available to
Page 18 of 20

Page 18 of 20
customers and it can be modified an redistributed without any limitation.
FLOSS : refers to free libre and open source software or to free livre and open source
software. The term FLOSS is used to refer to a software which is both free software
as well as open source software.
(d) Write the name of domain for listed companies and businesses. 2

Answer :
co : for listed companies
biz : for business
1 marks for each
(e) “Paras and Mahaveer Development” is doing construction work in various parts in
country. It’s head office is in Delhi, and regional offices are in different parts of country
which detail and distance from head office is as follow :
1. Jaipur office 500 KM
2. Mumbai office 1200 KM
3. Chennai Office 2500 KM
4. Bangalore office 2600 KM

In head office it has following blocks :


S.No. Block No. of Distance from main
Computer office in meters
1. Financial Block 50 120
2. Customer Welcome block 10 50
3. Legal consultancy Block 25 130
4. Main Block 15 0 mts

(i) Suggest a cable layout of connection between the blocks in head office. 1
Answer :
1 marks for correct layout.
(ii) Suggest the most suitable place( i.e building) to house the server. Also 1
provide suitable reason for your suggestion.
Answer :
In financial block because there are 50 computers.
½ marks for location
½ marks for the reason

(iii) Suggest the placement of the following devices with justification in head 1
office :
(a) Repeater
(b) Hub/Switch

Page 19 of 20

Page 19 of 20
Answer :
(a) Repeater will be placed between the financial block and main block, and
financial block and legal consultancy block.
(b) In each block
½ marks for each correct answer
(iv) Write the name of communication link which it will use to connect it all 1
regional offices to connect with head office.
Answer : satellite or lease line or optical fiber cable or coaxial cable.
1 marks for correct answer.

Page 20 of 20

Page 20 of 20

You might also like