(WWW - Entrance-Exam - Net) - CBSE Class 12 Computer Science Sample Paper 1
(WWW - Entrance-Exam - Net) - CBSE Class 12 Computer Science Sample Paper 1
Instructions :
(i) All questions are compulsory.
(ii) Programming Language : C++
1. (a) Differentiate between a Call by Value and Call by Reference, giving suitable
examples of each. 2
(c) Rewrite the following program after removing the syntactical error(s), if any.
Underline each correction. 2
#include <iostream.h>
const int Multiple 3;
void main ()
{
Value=15;
for (int Counter = 1;Counter=<5;Counter++,Value-=2)
if (Value%Multiple==0)
cout<<Value * Multiple;
cout<<endl;
else
cout<<Value+Multiple<<endl;
}
(d) Find the output of the following program: 3
#include<iostream.h>
struct MyBox
{
int Length, Breadth, Height;
};
void Dimension (MyBox M)
{
261
cout<<M.Length<<"x"<<M.Breadth<<"x";
cout<<M.Height<<endl;
}
void main()
{
MyBox B1={10,15,5}, B2, B3;
++B1.Height;
Dimension(B1);
B3 = B1;
++B3.Length;
B3.Breadth++;
Dimension(B3);
B2 = B3;
B2.Height+=5;
B2.Length--;
Dimension(B2);
}
#include<iostream.h>
#include<string.h>
#include<ctype.h>
void Convert(char Str[],int Len)
{
for (int Count =0; Count<Len; Count++ )
{
if (isupper (Str [Count] ) )
Str[Count]= tolower(Str[Count]);
else if (islower (Str [Count] ) )
Str[Count]= toupper(Str[Count]);
else if (isdigit (Str [Count]))
Str[Count]= Str[Count] + 1;
else Str[Count] = ‘*’;
}
}
262
void main ()
{
char Text [] = “CBSE Exam 2005”;
int Size=strlen(Text);
Convert(Text,Size);
cout<<Text<<endl;
for (int C = 0,R=Size-l;C<=Size/2; C++,R--)
{
char Temp = Text[C];
Text [C] = Text [R] ;
Text [R] = Temp;
}
cout<<Text<<endl;
}
(f) Observe the following program SCORE.CPP carefully, if the value of Num entered
by the user is 5, choose the correct possible output(s) from the options from (i) to
(iv), and justify your option. 2
//program : SCORE.CPP
#include<stdlib.h>
#include<iostream.h>
void main()
{
randomize();
int Num, Rndnum;
cin>>Num;
Rndnum = random(Num) + 5;
for (int N = 1; N<=Rndnum; N++)
cout<<N<<“ “;
}
Output Options:
(i) 1234
(ii) 1 2
(iii) 1 2 3 4 5 6 7 8 9
(iv) 1 2 3
263
2. (a) Define the term Data Hiding in the context of Object Oriented Programming. Give a
suitable example using a C++ code to illustrate the same. 2
(b) Answer the questions (i) and (ii) after going through the following class: 2
class Test
{
char Paper[20];
int Marks;
public:
Test() // Function 1
{
strcpy(Paper, “Computer”)
Marks = 0;
}
Test(char P[] ) // Function 2
{
strcpy(Paper,P);
Marks = 0;
}
Test(int M) // Function 3
{
strcpy(Paper,”Computer”);
Marks = M;
}
Test(char P[], int M) // Function 4
{
strcpy(Paper, P);
Marks = M;
}
};
264
Public Members:
A constructor to assign initial values of Plan Code as 1001, Place as “Agra”,
Number_of_travellers as 5, Number_of_buses as 1
(d) Answer the questions (i) to (iv) based on the following code: 4
class Medicines
{
char Category[lO];
char Date_of_manufacture[lO];
char Company[20];
public:
Medicines();
void entermedicinedetails();
void showmedicinedetails();
} ;
class Capsules: public Medicines
{
protected:
char capsule_name[30];
char Volume_label[20];
public:
float Price;
Capsules();
void entercapsuledetails();
void showcapsuledetails();
};
class Antibiotics: public Capsule
{
int Dosage_units;
char Side_effects[20];
int Use_within_days;
public:
Antibiotics() ;
void enterdetails();
void showdetails();
};
(i) How many bytes will be required by an object of class Medicines and an object
of class Antibiotics respectively?
265
(ii) Write names of all the member functions accessible from the object of class
Antibiotics.
(iii) Write names of all the members accessible from member functions of class
Capsules.
(iv) Write names of all the data members, which are accessible from objects of class
Antibiotics.
3. (a) Write a function in C++ which accepts an integer array and its size as
arguments/parameters and exchanges the values of first half side elements with the
second half side elements of the array. 3
Example:
If an array of eight elements has initial content as
2,4,1,6,7,9,23,10
The function should rearrange the array as
7,9,23,10,2,4,1,6
(b) An array Arr[15][35] is stored in the memory along the column with each of its
elements occupying 8 bytes. Find out the base address and the address of an
element Arr[2][5], if the location Arr[5][10] is stored at the address 4000. 4
(d) Write a function in C++ to print the sum of all the values which are either divisible
by 2 or are divisible by 3 present in a two-dimensional array passed as the
argument to the function. 3
(e) Evaluate the following postfix notation of expression: 2
10 20 + 25 15 - * 30 /
266
4. (a) Observe the program segment given below carefully, and answer the question that
follows: 1
class Book
{
int Book no;
char Book_name[20];
public:
//function to enter Book details
void enterdetails();
// function to display Book details
void showdetails();
//function to return Book_no
int Rbook_no(){return Book_no;}
} ;
void Modify(Book NEW)
{
fstream File;
File.open(“BOOK.DAT”,ios::binary|ios::in|ios::out);
Book OB;
int Recordsread = 0, Found = 0;
while (!Found && File.read((char*)&OB, sizeof(OB)))
{
Recordsread ++ ;
if (NEW.RBook_no() == OB.RBook_no))
{
______________ //Missing Statement
File.write((char*)&NEW, sizeof (NEW));
Found = 1;
}
else
File.write((char*)&OB, sizeof(OB));
}
if (!Found)
cout<<" Record for modification does not exist”;
File.close();
}
If the function Modify( ) is supposed to modify a record in file BOOK.DAT with the
values of Book NEW passed to its argument, write the appropriate statement for
Missing Statement using seekp( ) or seekg( ), whichever needed, in the above code
that would write the modified record at its proper place.
267
(b) Write a function in C++ to count and display the number of lines starting with
alphabet ‘A’ present in a text file “LINES.TXT”. 2
Example:
If the file “LINES.TXT” contains the following lines,
A boy is playing there.
There is a playground.
An aeroplane is in the sky.
Alphabets and numbers are allowed in the password.
The function should display the output as 3
(c) Given a binary file STUDENT.DAT, containing records of the following class
Student type 3
class Student
{
char S_Admno[lO]; //Admission number of student
char S_Name[30]; //Name of student
int Percentage; //Marks Percentage of student
public:
void EnterData()
{
gets(S_Admno);gets(S_Name);cin>>Percentage;
}
void DisplayData()
{
cout<<setw(12)<<S_Admno;
cout<<setw(32)<<S_Name;
cout<<setw(3)<<Percentage<<endl;
}
int ReturnPercentage(){return Percentage;}
};
Write a function in C++, that would read contents of file STUDENT.DAT and display
the details of those Students whose Percentage is above 75.
5. (a) What do you understand by the terms Primary Key and Degree of a relation in
relational database? 2
268
(b) Consider the following tables EMPLOYEES and EMPSALARY. Write SQL
commands for the statements (i) to (iv) and give outputs for SQL queries (v) to (viii). 6
EMPLOYEES
EMPID FIRSTNAME LASTNAME ADDRESS CITY
010 George Smith 83 First Street Howard
105 Mary Jones 842 Vine Ave. Losantiville
152 Sam Tones 33 Elm St. Paris
215 Sarah Ackerman 440 U.S. 110 Upton
244 Manila Sengupta 24 Friends Street New Delhi
300 Robert Samuel 9 Fifth Cross Washington
335 Henry Williams 12 Moore Street Boston
400 Rachel Lee 121 Harrison St. New York
441 Peter Thompson 11 Red Road Paris
EMPSALARY
EMPID SALARY BENEFITS DESIGNATION
010 75000 15000 Manager
105 65000 15000 Manager
152 80000 25000 Director
215 75000 12500 Manager
244 50000 12000 Clerk
300 45000 10000 Clerk
335 40000 10000 Clerk
400 32000 7500 Salesman
441 28000 7500 Salesman
(i) To display Firstname, Lastname, Address and City of all employees living in
Paris from the table EMPLOYEES.
(ii) To display the content of EMPLOYEES table in descending order of
FIRSTNAME.
(iii) To display the Firstname, Lastname, and Total Salary of all Managers from
the tables EMPLOYEES and EMPSALARY, where Total Salary is calculated as
Salary + Benefits.
269
(iv) To display the Maximum salary among Managers and Clerks from the table
EMPSALARY.
(v) SELECT FIRSTNAME, SALARY
FROM EMPLOYEES, EMPSALARY
WHERE DESIGNATION = ‘Salesman’ AND
EMPLOYEES.EMPID=EMPSALARY.EMPID;
(vi) SELECT COUNT(DISTINCT DESIGNATION)FROM EMPSALARY;
(viI) SELECT DESIGNATION, SUM(SALARY)
FROM EMPSALARY
GROUP BY DESIGNATION HAVING COUNT(*)>2;
(viii) SELECT SUM(BENEFITS)
FROM EMPLOYEES
WHERE DESIGNATION = ’Clerk’;
(c) Write the SOP form of a Boolean Function F, which is represented by the following
truth table: 1
A B C F
0 0 0 1
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 1
270
7. (a) What is the difference between Message Switching technique and Packet Switching
technique? 1
(b) Expand the following terminologies : 2
(i) TCP/IP
(ii) XML
(iii) CDMA
(iv) WLL
(c) Write two application of Cyber Law. 1
(d) The Great Brain Organisation has set up its new Branch at Srinagar for its office
and web based activities. It has 4 Wings of buildings as shown in the diagram :
Number of Computers
Wing X 50
Wing Z 30
Wing Y 150
Wing U 15
(i) Suggest a most suitable cable layout of connections between the Wings, and
topology. 1
271
(ii) Suggest the most suitable place (i.e. Wing) to house the server of this
organisation with a suitable reason, with justification. 1
(iv) The organization is planning to link its head office situated in Delhi with the
offices at Srinagar. Suggest an economic way to connect it; the company is
ready to compromise on the speed of connectivity. Justify your answer. 1
1. (a) Differentiate between a default constructor and copy constructor, giving suitable
examples of each. 2
(c) Rewrite the following program after removing the syntactical error(s), if any.
Underline each correction. 2
#include <iostream.h>
const int Dividor 5;
void main()
{
Number=15;
for (int Count = l;Count=<5;Count++,Number-=3)
if (Number%Dividor==0)
cout<<Number / Dividor;
cout<<endl;
else
cout<<Number + Dividor<<endl;
}
272
(d) Find the output of the following program : 3
#include<iostream.h>
struct Package
{
int Length, Breadth, Height;
};
void Occupies(Package M)
{
cout<<M.Length<<“x“<<M.Breadth<<”x“;
cout<<M.Height<<endl;
}
void main()
{
Package Pl={100,150,50}, P2, P3;
++P1.Length;
Occupies(P1);
P3 = P1;
++P3.Breadth;
P3.Breadth++;
Occupies(P3);
P2 = P3;
P2.Breadth+=50;
P2. Height--;
Occupies(P2);
}
(e) Find the output of the following program : 2
#include<iostream.h>
#include<string.h>
#include<ctype.h>
void Change(char Msg[],int Len)
{
for (int Count =0; Count<Len; Count++ )
{
if (islower(Msg[Count]))
Msg[Count]= toupper{Msg[Count]);
else if (isupper(Msg[Count]))
Msg[Count]= tolower(Msg[Count]);
else if (isdigit(Msg[Count]))
Msg[Count]= Msg[Count] + 1;
else Msg[Count] = ‘*’ ;
}
273
}
void main()
{
char Message[] = "2005 Tests ahead";
int Size = strlen(Message);
Change(Message,Size);
cout<<Message<<endl;
for (int C = 0,R=Size-l;C<=Size/2; C++,R--)
{
char Temp = Message[C];
Message[C]= Message[R];
Message[R]= Temp;
}
cout<<Message<<endl;
}
(f) Observe the following program GAME.CPP carefully, if the value of Num entered by
the user is 14, choose the correct possible output(s) from the options from (i) to (iv),
and justify your option. 2
//Program : GAME.CPP
#include<stdlib.h>
#include<iostream.h>
void main()
{
randomize();
int Num, Rndnum;
cin>>Num;
Rndnum = random(Num) + 7;
for (int N = 1; N<=Rndnum ; N++)
cout<<N<<" ";
}
Output Options :
(i) 1 2 3
(ii) 1 2 3 4 5 6 7 8 9 10 11
(iii) 1 2 3 4 5
(iv) 1 2 3 4
274
2. (a) Define the term Data Encapsulation in the context of Object Oriented Programming.
Give a suitable example using a C++ code to illustrate the same. 2
(b) Answer the questions (i) and (ii) after going through the following class : 2
class Exam
{
int Marks;
char Subject[20];
public:
Exam() //Function 1
{
Marks = 0;
strcpy (Subject,”Computer”);
}
Exam(char S[]) //Function 2
{
Marks = 0;
strcpy(Subject,S);
}
Exam(int M) //Function 3
{
Marks = M;
strcpy(Subject,”Computer”);
}
Exam(char S[], int M) //Function 4
{
Marks = M;
strcpy(Subject,S);
}
};
(i) Write statements in C++ that would execute Function 3 and Function 4 of
class Exam.
275
Public Members :
A constructor to assign initial values of TravelCode as 201, Place as “Nainital”,
No_of_travellers as 10, No_of_buses as 1
A function NewTravel() which allows user to enter TravelCode, Place and
No_of_travellers. Also, assign the value of No_of_buses as per the following
conditions :
No_of_travellers No_of_buses
Less than 20 1
Equal to or more than 20 and less than 40 2
Equal to 40 or more than 40 3
A function ShowTravel( ) to display the content from all the data members on screen.
(d) Answer the questions (i) to (iv) based on the following code : 4
class Drug
{
char Category[10];
char Date_of_manufacture[10];
char Company[20];
public:
Drug();
void enterdrugdetails();
void showdrugdetails{);
};
class Tablet : public Drug
{
protected:
char tablet_name[30];
char Volume_label[20];
public:
float Price;
Tablet();
void entertabletdetails();
void showtabletdetails();
};
class PainReliever : public Tablet
{
int Dosage_units;
char Side_effects[20];
int Use_within_days;
public:
PainReliever();
void enterdetails();
void showdetails();
};
(i) How many bytes will be required by an object of class Drug and an object of
class PainReliever respectively ?
276
(ii) Write names of all the data members which are accessible from the object of
class PainReliever.
(iii) Write names of all the members accessible from member functions of class
Tablet.
(iv) Write names of all the member functions which are accessible from objects of
class PainReliever.
3. (a) Write a function in C++ which accepts an integer array and its size as
arguments/parameters and exchanges the values of first half side elements with the
second half side elements of the array. 3
Example :
If an array of eight elements has initial content as
8, 10, 1, 3, 17, 90, 13, 60
The function should rearrange the array as
17, 90, 13, 60, 8, 10, 1, 3
(b) An array Arr[35][15] is stored in the memory along the row with each of its element
occupying 4 bytes. Find out the base address and the address of an element
Arr[20][5], if the location Arr[2][2] is stored at the address 3000. 4
(d) Write a function in C++ to print the sum of all the values which are either divisible
by 3 or are divisible by 5 present in a two dimensional array passed as the
argument to the function. 3
(e) Evaluate the following postfix notation of expression :
20 10 + 5 2 * – 10 / 2
277
4. (a) Observe the program segment given below carefully, and answer the question that
follows : 1
class Member
{
int Member_no;
char Member_name[20];
public :
//function to enter Member details
void enterdetails{) ;
// function to display Member details
void showdetails();
//function to return Member_no
int RMember_no() {return Member_no; }
};
void Update(Member NEW)
{
fstream File;
File.open(“MEMBER.DAT”,ios::binary|ios::in|ios::out);
Member OM;
int Recordsread = 0, Found = 0;
while (!Found && File.read((char*)&OM, sizeof(OM)))
{
Recordsread ++;
if (NEW.RMember_no() == OM.RMember_no())
{
___________________//Missing Statement
File.write((char*)&NEW, sizeof(NEW));
Found = 1;
}
else
File.write((char*)&OM, sizeof(OM));
}
if (!Found)
cout<<“Record for modification does not exist”;
File.close();
}
278
(b) Write a function in C++ to count and display the number of lines not starting with
alphabet ‘A’ present in a text file ‘STORY.TXT”. 2
Example :
If the file “STORY.TXT” contains the following lines,
(c) Given a binary file APPLY.DAT, containing records of the following class Applicant
type 3
class Applicant
{
char A_Rno[10]; //Roll number of applicant
char A_Name[30]; //Name of applicant
int A_Score; //Score of applicant
public:
void Enrol()
{
gets(A_Rno); gets(A_Name) ; cin>>A_Score;
}
void Status()
{
cout<<setw(12)<<A_Admno;
cout<<setw(32)<<A_Name;
cout<<setw(3)<<A_Score<<endl;
}
int ReturnScore(){return A_Score;}
};
Write a function in C++, that would read contents of file APPLY.DAT and display the
details of those Students whose A_ Score is below 70.
5. (a) What do you understand by the terms Candidate Key and Cardinality of a
relation in relational database ? 2
279
(b) Consider the following tables WORKERS and DESIG. Write SQL commands for the
statements (i) to (iv) and give outputs for SQL queries (v) to (viii) : 6
WORKERS
W_ID FIRSTNAME LASTNAME ADDRESS CITY
102 Sam Tones 33 Elm St. Paris
105 Sarah Ackerman 440 U.S. 110 New York
144 Manila Sengupta 24 Friends Street New Delhi
210 George Smith 83 First Street Howard
255 Mary Jones 842 Vine Ave. Losantiville
300 Robert Samuel 9 Fifth Cross Washington
335 Henry Williams 12 Moore Street Boston
403 Ronny Lee 121 Harrison St. New York
451 Pat Thompson 11 Red Road Paris
DESIG
W_ID SALARY BENEFITS DESIGNATION
102 75000 15000 Manager
105 85000 25000 Director
144 70000 15000 Manager
210 75000 12500 Manager
255 50000 12000 Clerk
300 45000 10000 Clerk
335 40000 10000 Clerk
400 32000 7500 Salesman
451 28000 7500 Salesman
(i) To display W_ID, Firstname, Address and City of all employees living in
New York from the table WORKERS.
(ii) To display the content of WORKERS table in ascending order of LASTNAME.
(iii) To display the Firstname, Lastname, and Total Salary of all Clerks from
the tables WORKERS and DESIG, where Total Salary is calculated as
Salary + Benefits.
(iv) To display the Minimum salary among Managers and Clerks from the table
DESIG.
(v) SELECT FIRSTNAME, SALARY
FROM WORKERS, DESIG
WHERE DESIGNATION = ‘Manager’ AND
WORKERS.W_ID=DESIG.W_ID;
280
(vi) SELECT COUNT(DISTINCT DESIGNATION) FROM DESIG;
(vii) SELECT DESIGNATION, SUM(SALARY)
FROM DESIG
GROUP BY DESIGNATION HAVING COUNT(*)<3;
(viii) SELECT SUM(BENEFITS)
FROM WORKERS
WHERE DESIGNATION = ‘Salesman’;
(c) Write the POS form of a Boolean Function F, which is represented by the following
truth table : 1
X Y Z F
0 0 0 1
0 0 1 1
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 1
1 1 0 0
1 1 1 0
281
(e) The Cyber Mind Organisation has set up its new Branch at Mizoram for its office
and web based activities. It has 4 Wings of buildings as shown in the diagram :
Number of Computers
Wing X 50
Wing Z 130
Wing Y 40
Wing U 15
(el) Suggest a most suitable cable layout of connections between the Wings and
topology. 1
(e2) Suggest the most suitable place (i.e. Wing) to house the server of this
organization with a suitable reason with justification. 1
(e3) Suggest the placement of the following devices with justification : 1
(i) Repeater
(ii) Hub/Switch
(e4) The organization is planning to link its head office situated in Delhi with the
offices as Mizoram. Suggest an economic way to connect it; the company is
ready to compromise on the speed of connectivity. Justify your answer. 1
282
Marking Scheme --- Computer Science
General Instruction :
1. The answers given in the marking scheme are merely suggestive;
Examiners are requested to consider all alternative correct answers conveying the
similar meaning.
2. All programming questions -have to be answered with respect to C++ language only.
3. In SQL related questions - both ways text i.e. character entries should be acceptable.
(For example: ‘Amar’ or “Amar”)
4. In SQL related questions - ignore semicolon / termination for queries.
5. In SQL related questions - ignore case sensitivity.
6. In C++ questions — Ignore case sensitivity for function names and variable names.
283
(c) #include <iostream.h>
const int Multiple=3;
void main ()
{
int Value=15;
for (int Counter = 1;Counter<=5;Counter++,Value-=2)
if (Value%Multiple==O)
cout<<Value * Multiple<<endl;
else
cout<<Value+Multiple<<endl;
}
OR
#include <iostream.h>
const int Multiple=3;
void main ()
{
int Value=15;
for (int Counter = 1;Counter<=5;Counter++,Value-=2)
if (Value%Multiple==O)
{ 4
cout<<Value * Multiple;
cout<<endl;
}
else
cout<<Value+Multiple<<endl;
}
[1/2 Mark for each correction]
OR
[Only 1/2 for only identifying all the errors]
(d) 10×15×6
11×16×6
10×16×11
[1 Mark for each line of correct output]
OR
[½ mark for partial answers i.e, upto two correct numbers in each line]
Note: Deduct ½ mark for not considering endl from the total marks obtained in this question.
(e) cbse*eXAM*3116
6113*MXAe*esbc
[1 Mark for each line of correct output]
OR
[½ mark for partial answers in each line for any
two sets of strings cbse*eXAM OR eXAM*3116 OR 6113*MXAe OR MXAe*esbc]
Note: Deduct ½ mark for not considering endl from the total marks obtained in this question
284
(f) (iii) 1 2 3 4 5 6 7 8 9
OR
(iii)
2. (a) Data hiding is a method of keeping the data in private or protected visibility modes to avoid
their access From outside its scope.
For example:
class Sample
{
int Data; //Data will not be accessible from the object
public:
void Function( );
} ;
Note : If a student mentions about error (i.e. missing ;) give 1 mark out of
2 marks.
285
(c) class TravelPlan
{
long PlanCode;
char Place[20];
int Number_of_travellers;
int Number_of_buses;
public:
TravelPlan();
void NewPlan();
void ShowPlan()
};
TravelPlan::TravelPlan()
{
PlanCode=1001;
strcpy(Place,”Agra”);
Number_of_travellers=5;
Number_of_buses=1;
}
void TravelPlan::NewPlan()
{
cin>>PlanCode;
gets(Place);
cin>>Number_of_travellers;
if (number_of_travellers<20)
numer_of_buses=1;
else if (number_of_travellers<40)
numer_of_buses=2;
else numer_of_buses=3;
}
void TravelPlan::ShowPlan()
{
cout <<PlanCode<<endl<<Place<<endl
<<Number_of_travellers<<endl
<<Number_of_buses<<endl;
}
[½ Mark for using the correct syntax of the class including private (the default one)
and public visibility modes]
[1 Mark for declaring all the data members in private]
[1 Mark for correct constructor function]
[1 Mark for correct definition of NewPlan() function with appropriate if condition]
[½ Mark for correct definition of ShowPlan() function]
OR
[1 Mark if only Function Prototypes are mentioned]
286
(d) (i) class Medicines : 40
class Antibiotics : 118
[½ mark for writing each correct answer]
(ii) entermedicinedetails ( )
showmedicinedetaiDs ( )
entercapsuledetails ( )
showcapsuledetails ( )
enterdetails ( )
showdetails ( )
287
OR
void Exchange(int A[], int N)
{
int M=(N%2==0)?N:N+l;
for (int I=0; I<M/2; I++)
{
int Temp=A[I];
A[I]=A[M/2+I];
A[M/2+I]-Temp;
}
}
OR
Any other equivalent logic producing the correct result
[1 Mark for function header]
[1 Mark for correct formation of loop]
[1 Mark for exchanging the content correctly]
(b) LOC(Arr[I][J] )=Base(Arr)+W*(I + No.of Rows * J )
LOC(Arr[5][10]) =Base(Arr)+8*(5+15*10)
4000 =Base(Arr)+8*(155)
4000 =Base(Arr)+1240
Base(Arr) =4000-1240
Base(Arr) =2760
LOC(Arr[2][5]) =Base(Arr)+8* (2 + 15*5)
=2760+8*(77)
=2760+616
=3376
OR
LOC(Arr[I][J]) =Base(Arr)+W*( (I-1) + No. of Rows * (J-l) )
LOC(Arr[5][10]) =Base(Arr)+8*[(5-1)+15* (10-1)]
4000 =Base(Arr)+8*(139)
4000 =Base(Arr)+1112
Base(Arr) =4000-1112
Base(Arr) =2888
288
(c) void STACK::PUSH()
{
Node*Temp;
Temp = new Node;
cin>>Temp->X>>Temp->Y;
Temp->Link=Top;
Top=Temp;
}
OR
Any other equivalent code
[1 Mark for correct function header i.e. using :: scope resolution operator]
[1 Mark for creating an empty node and assigning its address to a pointer]
[1 Mark for assigning values to X and Y]
[½ Mark each for assigning correct value to the Link and updating Top]
(d) void Div2or3(int A[][5],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+=A[I][J];
cout<<Sum; //Ignore
}
OR
int Div2or3(int A[][5],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+=A[I][J];
return Sum; //Ignore
}
OR
Any other equivalent code
[½ Mark for correct function header]
[½ Mark for initializing Sum]
[½ Mark for each of the loop]
[½ Mark for divisibility check for 2 and 3]
[½ Mark for finding the sum]
289
(e) 10 20 + 25 15 - * 30 /
1. 0
10
2. 0
20
10
3. 0 OP2=20 OP1=10
0 +
0 OP2=20
20
10 30
4. 0
25
30
5. 0
15
25
30
290
6. 0 OP2=15 OP1=25
0 -
0 OP2=15
25 10
10 30 30
7. 0 OP2=10 OP1=30
0 *
0 OP2=10
25 10
30 30 300
8. 0
0
0
30
300
9. 0 OP2 = 30 OP1=300
0 /
0 OP2=30
25 10
300 30 10
10. Pop
0 Result
0 10
30
300
291
OR
Operand/Operator Stack Status
10 10
20 10,20
+ 30
25 30,25
15 30,25,15
- 30,10
* 300
30 300,30
/ 10
Result : 10
[½ Mark each for any three operators operation using stack]
[½ Mark for final result as 10]
4. (a) File.seekp((Recordsread-1)*sizeof(NEW));
OR
File.seekp(-sizeof(NEW), ios::curr);
OR
File.seekp(File.tellg()-sizeof(NEW) );
OR
Any other equivalent code
[1 mark for writing the correct statement as above or any equivalent]
(b) void counter( )
{
char Aline[80];
int Count=0;
ifstream Fin (“LINES.TXT”);
while(Fin.getline(Aline,80, ‘\n’))
if (Aline[0]== ‘A’)
Count++;
Fin.close( );
cout<<Count<<endl;
}
[½ mark for reading a line from the text file]
[½ mark for checking the beginning alphabet as ‘A’ ]
[½ mark for correctly incrementing the counter]
[½ mark for correctly displaying/returning the counter]
292
(c) void Distinction()
{
Student S;
fstream Fin;
Fin.open(“STUDENT.DAT”, ios::binary|ios::in);
while(Fin.read((char*)&S, sizeof(Student))
if (S.ReturnPercentage()>75)
S.DisplayData();
Fin.close();
}
[½ Mark for opening the file or initializing the object of file stream]
[1 Mark for checking eof & performing read operation from the binary file]
[1 Mark for checking the required condition i.e. >75]
[½ Mark for displaying the content of the required record]
5. (a) Primary Key: The attribute (Column) or set of attributes (Columns) which is used to identify
a tuple/row uniquely are known as Primary Key.
Degree of a relation: Number of attribute or column in a table form cardinality of a relation.
[1 Mark each for giving correct definition]
OR
[1 Mark each for explaining the concept using suitable example]
[½ Marks for each part (here parts are separated into lines for
convenience) of correct SQL Command]
[½ Marks for each part (here parts are separated into lines for
convenience) of correct SQL Command]
[½ Marks for each part (here parts are separated into lines for
convenience) of correct SQL Command]
293
(iv) Select Max(SALARY) From EMPSALARY
Where DESIGNATION = ‘Manager’ OR DESIGNATION = ‘Clerk’;
[½ Marks for each part (here parts are separated into lines for
convenience) of correct SQL Command]
294
OR
Verification of A+(B+C) = (A+B)+C
X + Y'
Y'
X'
X'+Y
(X+Y').(X'+Y').(X'+Y')
X'
X'+Y'
Y'
295
A'B' A'B A.B A.B'
C'D' 0 4 1 12 1 8
C'D 1 5 1 13 1 9
C.D 3 1 7 15 11
C.D' 2 1 6 1 14 10
OR
C'D' C'D C.D C.D'
A'B' 0 1 3 2
A'B 4 5 1 7 1 6
A.B 1 12 1 13 15 1 14
A.B' 1 8 1 9 11 10
OR
A+B A+B' A'+B' A'+B
C+D 0 0 0 4 12 8
C+D' 0 1 0 5 13 9
⎝
C'+D' 0 0 ⎛ 0
⎜
⎜
⎜ 3 7 15 11
⎜ ⎜
C'+D 0 2 6 14 ⎜ 0 10
⎝
⎛
OR
C+D C+D' C'+D' C'+D
A+B 0 0 0 0
⎛
⎜
⎜
⎜
⎝
0 1 3 2
A+B' 0 4 0 5 7 1 6
A'+B' 12 13 0 15 14
⎝
⎜
⎜
⎜
⎛
A'+B 8 9 0 11 0 10
296
[½ mark for placing the 1s/0s at correct positions]
[½ Mark for grouping in the K-Map]
[½ Mark for each reduced term]
Note : Deduct ½ Mark for extra redundant term(s)/grouping(s)
7. (a) Message switching: The saurce computer sends data (message) to the
switching office, which stores data in a buffer. It then looks for a free link
to another switching office and sends data to that office. This process
continues until data is delivered to the destination computer. This type of
switching technique is also known as ‘store and forward’ switching.
(c) Cyber law encompasses a wide variety of political and legal issues related
to the Internet and other communications technology, including intellectu \\
property, privacy, freedom of expression, and jurisdiction.
297
(d) (i) [½ Mark for drawing / mentioning any suitable cable layout]
[½ Mark for mentioning the topology]
298
class STUDENT
{
int Rno;
char Name[20];
public:
STUDENT(); //Default Constructor
STUDENT(STUDENT &S); //Copy Constructor
:
:
};
299
(d) 101×150×50
101×152×50
101×202×49
(1 Mark for each line of correct output)
OR
(½ mark for partial answers in each line upto two correct numbers)
Note: Deduct ½ mark for not considering endl from the total marks
obtained in this question, Deduct ½ mark for not mentioning ‘X’ in between
the numbers.
(e) 3116*tESTS*AHEAD
DAEHA*SSTEt*6113
300
(b) (i) Exam E(90);
OR
E.Exam::Exam(45);
Exam F(“Physics”,50);
OR
E.Exam::Exam(“Hindi”,40);
(½ Mark for each statement)
(ii) Constructor Overloading (Most suitable answer)
OR
Polymorphism
OR
Function Overloading
(1 Mark for mentioning any of the above)
(c) class Travel
{
long TravelCode;
char Place[25];
int No_of_travellers,No_of_buses;
public:
Travel();
void NewTravel();
void ShowTravel();
};
Travel::Travel()
{
TravelCode=201;
strcpy(Place,”Nainital”);
No_of_travelers=10;
No_of_buses=l;
}
void Travel::NewTravel()
(
cin>>Travelcode;
gets(Place);
cin>>No_of_travellers;
if (No_of_travellers<20)
301
No_of_buses=l;
else if (No_of_travellers<40)
No_of_buses=2;
else
No_of_buses=3;
}
void Travel::ShowTravel()
{
cout<<”Travel Code=”<<TravelCode;
cout<<”Place=”; puts(Place);
cout<<”No of travellers=”<<No_of_travellers;
cout<<”no of buses=”<<No__of_buses;
(½ Mark for using the correct syntax of the class including private
[the default one] and public visibility modes)
(1 Mark for declaring all the data members in private)
(1 Mark for correct constructor function)
(1 Mark for correct definition of NewTravel( ) function)
(½ Mark for correct definition of ShowTravel( ) function)
(d) (i) Class Drug 40 bytes
Class PainReliever 118 bytes
(½ Mark for each answer)
(ii) price
(1 Mark for the correct answer)
(iii) entertabletdetails( )
showtabletdetaiis( )
enterdrugdetails( )
showdrugdetails( )
tablet_name
volume_label
price
Note: Ignore mention of Constructors
(1 Mark for the correct answer- Only if all the data members
and member functions are correct)
302
(iv) entertabletdetails()
showtabletdetails()
enterdrugdetails()
showdrugdetails()
enterdetails();
showdetails();
OR
void Exchange(int A[],int N)
{
for (int I=0,J=N/2;I<N/2;I++,J++)
{
int Temp=A[J];
for (int K=J;K>I;K--)
A[K]=A[K-1];
A[I]=Temp;
}
}
OR
void Exchange(int A[],int N)
{
int M=(N%2=0)?N:N+l;
for (int I=0;I<M/2;I++)
{
int Temp=A[I];
303
A[I]=A[M/2+I];
A[M/2+I]=Temp;
}
}
OR
Any other equivalent logic producing the correct result
(1 Mark for function header)
(1 Mark for correct formation of loop)
(1 Mark for exchanging the content correctly)
(b) LOC(Arr[I][J]) =Base(Arr)+W*(No. of Cols*I+J)
LOC(Arr[2][2]) =Base(Arr)+4*(15*2+2)
3000 =Base(Arr)+4*(32)
3000 =Base(Arr)+128
Base(Arr) =3000-128
Base(Arr) =2872
LOC(Arr[20][5])=Base(Arr)+4*(15*20+5)
=2872+4*(300+5)
=2872+4*305
=2872+1220
=4092
OR
LOC(Arr[I][J]) =Base(Arr)+W*(No. of Cols*(I-1)+(J-1)
LOC(Arr[2][2]) =Base(Arr)+4*(15*(2-1)+(2-1))
3000 =Base(Arr)+4*(16)
3000 =Base(Arr)+64
Base(Arr) =3000-64
Base(Arr) =2936
LOC(Arr[20][5])=Base(Arr)+4*(15*(20-1)+(5-1))
=2936+4*(289)
=2936+1156
=4092
304
(c) void QUEUE::DELETE()
{
if (Front!=NULL)
{
Node *Temp=Front;
Cout<<Temp->U<<Temp->V<<endl; //Ignore
Front=Front->Link;
delete Temp;
if (Front==NULL) Rear=NULL; //Ignore
}
else
cout<<"Queue is Empty"<<endl; //Ignore
}
OR
Any other equivalent code
(½ Mark for correct function header i.e. using :: scope resolution
operator)
(1 Mark for checking Queue Empty/Non-Empty condition)
(1 Mark for assigning the Front)
(1 Mark for updating the front by moving it to the next node i.e.,
using Link)
(½ Mark for using delete operator)
(d) void Div3or5(int A[][3],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]%3==0 || A[I][J]%5==0)
Sum+=A[I][J];
cout<<Sum; //Ignore
}
OR
int Div3or5(int A[ ][3],int N,int M)
{
int Sum=0;
305
for (int I=0;I<N;I++)
for (int J=0;J<M;J++)
if (A[I][J]%3==0 || A[I][J]%5==0)
Sum+=A[I][J];
return Sum; //Ignore
}
OR
Any other equivalent code
(½ Mark for correct function header)
(½ Mark for initializing Sum)
(½ Mark for each of the loop)
(½ Mark for divisibility check for 3 and 5)
(½ Mark for finding the sum)
(e) 20 10 + 5 2 * -10 /
1. 0
0
0
0
20
2. 0
0
0
10
20
3. 0 OP2=10 OP1=20
0 +
0 OP2=10
20
20 30
306
4. 0
0
0
30
5. 0
0
2
5
30
6. 0 OP2=2 OP1=5
0 *
0 OP2=2
5 10
30 30 30
7. 0 OP2=10 OP1=30
0 -
0 OP2=10
25 10
30 30 20
8. 0
0
0
10
20
307
9. 0 OP2=10 OP1=20
0 /
0 OP2=10
25 10
20 30 2
10. Pop
0 Result
0 2
30
300
OR
20 20
10 20,10
+ 30
5 30,5
2 30,5,2
+ 30,10
- 20
10 20,10
/ 2
Result : 2
(½ Mark for each for evaluation of any three operators using stack)
(½ Mark for final result as 2)
4. (a) File.seekp((Recordsread-1)*sizeof(OM));
OR
File.seekp(Recordsread*sizeof(OM));
OR
File.seekp(-l*sizeof(OM),ios::curr);
OR
308
File.seekp(file.tellg()-sizeof(OM));
OR
Any other equivalent
Note : sizeof(OM) OR sizeof(Member) OR sizeof(NEW)are
equivalents
309
(½ Mark for opening the file or initializing the object of fife stream)
(1 Mark for checking eof & performing read operation from the
binary file)
(½ Mark for displaying the content of the required record)
(1 Mark for checking the required condition with A.ReturnScore()
function <70)
OR
(½ Mark for checking the required condition with A.Score <70)
5. (a) Candidate Key: The attribute (Column) or set of attributes (Columns)
which can identify a tuple/row uniquely are known as Candidate Key(s).
OR
Candidate Key: The attribute (Column) or set of attributes (Columns),
which are capable of acting as candidate for primary key.
Cardinality of a relation: Number of rows in a table form cardinality of a
relation.
(1 Mark each for giving correct definition)
OR
(1 Murk each for explaining the concept using suitable example)
(b) (i) SELECT W_ID,FIRSTNAME,ADDRESS,CITY FROM
WORKERS WHERE CITY='New York';
(½ Mark for correct SELECT FROM)
(½ Mark for correct WHERE clause)
(ii) SELECT * FROM WORKERS ORDER BY LASTNAME;
(½ Mark for correct SELECT FROM)
(½ Mark for correct ORDER BY clause)
(iii) SELECT FIRSTNAME, LASTNAME, SALARY+BENEFITS
FROM WORKERS.DESIG WHERE DESIGNATION=’CLERK’
AND WORKERS,W_ID=DESIG.W_ID;
OR
SELECT FIRSTNAME,LASTNAME,SALARY+BENEFITS AS
TOTAL SALARY FROM WORKERS.DESIG WHERE
DESIGNATION=’CLERK’ AND
WORKERS.W_ID=DESIG.W_ID;
(½ Mark for correct SELECT FROM)
(½ Mark for correct WHERE clause)
310
(iv) SELECT MIN(SALARY), DESIGNATION FROM DESIG WHERE
DESIGNATION IN ('Manager'.'Clerk') GROUP BY DESIGNATION;
OR
SELECT MIN(SALARY), DESIGNATION FROM DESIG WHERE
DESIGNATION= ‘Manager’ OR DESIGNATION='Clerk' GROUP BY
DESIGNATION;
OR
SELECT MIN(SALARY) FROM DESIG WHERE DESIGNATION=
‘Manager’ OR DESIGNATION='Clerk';
OR
SELECT MIN(SALARY) FROM DESIG WHERE DESIGNATION IN
(‘Manager’,‘Clerk’);
(½ Mark for correct SELECT FROM)
(½ Mark for correct MIN function and WHERE clause)
(v) Sam 75000
Manila 70000
George 75000
311
X+X’.Y=X+Y
OR
X.(X’+Y)=X.Y
X Y X.Y X+X.Y
0 0 0 0
0 1 0 0
1 0 0 1
1 1 1 1
OR
X Y X+Y X.(X+Y)
0 0 0 0
0 1 1 0
1 0 1 1
1 1 1 1
OR
OR
1 1 0 0 1 1
312
OR
Algebraic Verification:
X+X.Y =X
X.1+X.Y =X
X.(1+Y) =X
X.1 =X
X =X
OR
X.(X+Y) =X
XX+X.Y =X
X.1+X.Y =X
X.(1+Y) =X
X.1 =X
X =X
OR
X+X’. Y =X+Y
(X+X’)(X+Y) =X+Y
1.(X+Y) =X+Y
X+Y =X+Y
OR
X(X’+Y) =X.Y
XX’+X.Y =X.Y
0+X.Y =X.Y
X.Y =X.Y
(b) U.V’+U’.V+U’.V
(½ Mark for each term - full marks if all the terms are correct)
(c) (X+Y'+Z)(X'+Y+Z).(X'+Y'+Z)(X'+Y'+Z')
(1/2 Mark for each two terms)
313
(d) A'B' A'B A.B A.B'
C'D' 1 0 1 4 12 8
C'D 1 1 1 5 13 9
C.D 1 3 7 1 15 1 11
C.D' 1 2 6 14 1 10
A'B 1 4 1 5 7 6
A.B 12 13 1 15 14
A.B' 8 9 1 11 1 10
F(A,B,C,D)=A’C’+B’.C+A.C.D
314
(d) Cookies: A small piece of information that a server sends to a client When
you visit a Web site with cookie capabilities, its server sends certain
information about you to your browser, which is stored on your hard drive
as a text file. At some later time (such as returning to the site the next day),
the server retrieves the cookie. It’s a way toi the server to remember
things about you.
Firewall: Any of a number of security schemes (hardware/software) that
prevent unauthorized users from gaining access to a computer network or
that monitor transfers of information to and from the network.
(½ Mark each for mentioning the key terms from the above or
equivalent)
315