264
COMPUTER SCIENCE
Time allowed : 3 hours Maximum Marks : 70
Instructions :
(i) All questions are compulsory.
(ii) Programming Language : C++
QUESTION PAPER CODE 91/1
1. (a) Nametheheaderfiletowhichthefollowingbelong 1
(i) abs( ) (ii) isupper( )
(b) Illustrate the use of #define in C++ to define a macro. 2
(c) Rewritethefollowingprogramafterremovingthesyntacticalerror(s),if
any.Underlineeachcorrection. 2
#include<iostream.h>
voidmain()
{ struct STUDENT
{ charstu_name[20];
charstu_sex;
intstu_age=17;
} student;
gets(stu_name);
gets(stu_sex);
}
(d) Findtheoutputofthefollowingprogram: 3
#include<iostream.h>
#include<string.h>
class state
{ char*state_name;
intsize;
public:
state( ); { size=0; state_name=new char[size+1]; }
state(char *s)
265
{ size = strlen(s) ; state_name = new char[size+1];
strcpy(state_name,s);
}
voiddisplay(){cout<<state_name<<endl;}
void Replace (state & a, state & b)
{ size = a.size + b.size;
deletestate_name;
state_name=newchar[size+l];
strcpy(state_name,a.state_name);
strcat(state_name,b.state_name);
}
};
voidmain()
{ char*temp=“Delhi”;
state state1 (temp), state2(“Mumbai”), state3(“Nagpur”), S1, S2;
S1.Replace(state1, state2);
S2. Replace(S1, state3);
S1.display();
S2.display();
}
(e) Findtheoutputofthefollowingprogram: 2
#include<iostream.h>
voidmain()
{ long NUM= 1234543;
int F=0, S=0;
do
{ int Rem = NUM% 10 ;
if (Rem % 2 !=0)
F+=R;
else
S+=R;
NUM /=10;
}while(NUM>0);
cout<<F-S;
}
(f) What are Nested Structures ? Give an example. 2
266
2. (a) DefineMultilevelandMultipleinheritanceincontextofObjectOrientedProgramming.
Givesuitableexampletoillustratethesame. 2
(b) Answerthequestions(i)and(ii)aftergoingthroughthefollowingclass:
classInterview
{ intmonth;
public:
Interview(inty) {month=y;} //Constructor 1
Interview(Interview&t); //Constructor 2
};
(i) Create an object, such that it invokes Constructor 1 1
(ii) WritecompletedefinitionforConstructor2 1
(c) DefineaclassnamedADMISSIONinC++withthefollowingdescriptions: 4
Privatemembers:
AD_NO integer (Ranges 10 - 2000)
NAME Arrayofcharacters(String)
CLASS Character
FEES Float
PublicMembers:
• Function Read_Data( ) to read an object ofADMISSION type
• Function Display( ) to display the details of an object
• Function Draw-Nos( ) to choose 2 students randomly.
Anddisplaythedetails.Userandomfunctiontogenerateadmission
nos. to match withAD_NO.
(d) Answer the questions (i) to (iii) based on the following code :
classstationary
{
charType;
charManufacturer[10];
public:
stationary();
void Read_sta_details( );
voidDisp_sta_details();
};
classoffice:publicstationary
{
267
intno_of_types;
floatcost_of_sta;
public:
voidRead_off_details();
voidDisp_off_details();
};
classprinter:privateoffice
{
intno_of_users;
char delivery _date [10];
public:
voidRead_pri_details();
voidDisp_pri_details();
};
voidmain()
{ printer MyPrinter; }
(i) Mention the member names which are accessible by MyPrinter declared in
main()function 1
(ii) What is the size of MyPrinter in bytes ? 1
(iii) Mention the names of functions accessible from the member function
Read_pri_details( ) of class printer. 2
3. (a) Write a function in C++ which accepts an integer array and its size as
arguments/parameters and assign the elements into a two dimensional array of
integersinthefollowingformat
If the array is 1, 2, 3, 4, 5, 6 If the array is 1, 2, 3 3
Theresultant2Darrayisgiven The resultant2Darrayisgiven
below below
1 2 3 4 5 6 1 2 3
1 2 3 4 5 0 1 2 0
1 2 3 4 0 0 1 0 0
1 2 3 0 0 0
1 2 0 0 0 0
1 0 0 0 0 0
268
(b) An array MAT[30][10] is stored in the memory column wise with each
element occupying 8 bytes of memory. Find out the base address and the
address of element MAT[20][5], if the location of MAT[5][7] is stored at
the address 1000. 4
(c) classqueue 4
{ intdata[10];
intfront,rear;
public:
queue( ) {front = -1; rear=-1;}
voidadd(); // to add an element into the queue
voidremove(); // to remove an element from the queue
voidDelete(intITEM); //To deleteallelementswhichareequal
// to ITEM
};
CompletetheclasswithallfunctiondefinitionsforacirculararrayQueue.Use
another queue to transfer data temporarily
(d) WriteafunctioninC++toperformPushoperationonadynamicallyallocated
stackcontainingrealnumber. 3
(e) Writetheequivalentinfixexpressionfor
a, b, AND, a, c, AND, OR 2
4. (a) voidmain()
{ char ch='A';
fstreamfileout(“data.dat”,ios::out);
fileout<<ch;
intp=fileout.tellg();
cout<<p;
Whatistheoutputifthefilecontentbeforetheexecutionoftheprogramisthe
string “ABC” (Note that “ ” are not part of the file)
(b) Write a function to count the number of words present in a text file
named “PARA.TXT”. Assume that each word is separated by a single
blank/space character and no blanks/spaces in the beginning and end of
thefile. 2
269
(c) Following is the structure of each record in a data file named
“COLONY.DAT”. 3
struct COLONY
{ char Colony_Code[10];
charColony_Name[10];
intNo_of_People;
};
WriteafunctioninC++toupdatethefilewithanewvalueofNo_of_People.Thevalue
of Colony_Code and No_of_People are read during the execution of the program.
5. (a) What is anAlternate Key ? 2
(b) Study the following tables DOCTOR and SALARY and write SQL commands
for the questions (i) to (iv) and give outputs for SQL queries (v) to (vi): 6
TABLE : DOCTOR
ID NAME DEPT SEX EXPERIENCE
101 John ENT M 12
104 Smith ORTHOPEDIC M 5
107 George CARDIOLOGY M 10
114 Lara SKIN F 3
109 K George MEDICINE F 9
105 Johnson ORTHOPEDIC M 10
117 Lucy ENT F 3
111 Bill MEDICINE F 12
130 Morphy ORTHOPEDIC M 15
TABLE : SALARY
ID BASIC ALLOWANCE CONSULTATION
101 12000 1000 300
104 23000 2300 500
107 32000 4000 500
114 12000 5200 100
109 42000 1700 200
105 18900 1690 300
130 21700 2600 300
270
(i) Display NAME of all doctors who are in “MEDICINE” having more than 10
years experience from the table DOCTOR.
(ii) Displaytheaveragesalaryofalldoctorsworkingin“ENT”departmentusing
the tables DOCTOR and SALARY. Salary = BASIC +ALLOWANCE
(iii) DisplaytheminimumALLOWANCEoffemaledoctors,
(iv) Displaythehighestconsultationfeeamongallmaledoctors,
(v) SELECT count(*) from DOCTOR where SEX = “F”
(vi) SELECT NAME, DEPT, BASIC from DOCTOR, SALARY
where DEPT= “ENT” and DOCTOR.ID = SALARY.ID
6. (a) StateandverifyDistributiveLaw. 2
(b) WritetheequivalentexpressionforthefollowingLogicalCircuit: 2
(c) Express P + Q’R in canonical SOP form. 1
(d) ReducethefollowingBooleanexpressionusingK-Map.
F(P, Q, R, S) = ÿ (0, 3, 5, 6, 7, 11, 12, 15) 3
7. (a) DifferentiatebetweenInternetandIntranet. 1
(b) Expandthefollowingterms
(i) CDMA (ii) URL (iii) HTTP (iv) WAN 2
(c) Write one advantage of STAR topology as compared toTBUS topology. 1
(d) UNIVERSITY OF CORRESPONDENCE in Allahabad is setting up the
network between its different wings. There.are 4 wings named as Science (S),
Journalism (J),ARTS (A) and Home Science(H).
271
Distancebetweenvariouswingsaregivenbelow
Wing A to Wing S 100 m
Wing A to Wing J 200 m
Wing A to Wing H 400 m
Wing S to Wing J 300 m
Wing S to Wing H 100 m
Wing J to Wing H 450 m
Number of Computers
Wing A 150
Wirig S 10
Wing J 5
Wing H 50
(i) SuggestasuitableTopologyfornetworkingthecomputerofallwings 1
(ii) Name the wing where the Server to be installed. Justify your answer, 1
(iii) SuggesttheplacementofHub/Switchinthenetwork. 1
(iv) Mention an economic technology to provide internet accessibility to all
wings. 1
QUESTION PAPER CODE 91
1. (a) Nametheheaderfiletowhichthefollowingbelong: 1
(i) pow()
(ii) random()
(b) IllustratetheuseofinlinefunctioninC++withthehelpofanexample. 2
(c) Rewrite the followingprogram afterremovingthe syntactical error(s), ifany.
Underlineeachcorrection. 2
#include<idstream.h>
voidmain()
{ structmovie
{ charmovie_name[20];
charmovie_type;
int ticket_cost = 100;
272
}MOVIE;
gets(movie_name);
gets(movie_type);
}
(d) Findtheoutputofthefollowingprogram: 3
#include<iostream.h>
#include<string.h>
classstudent
{ char*name;
intl;
public:
student() { 1=0; name=new char[1+1]; }
student(char*s)
{ 1=strlen(s);name=newchar[1+1];
strcpy(name,s);
}
voiddisplay(){cout<<name<<endl;}
void manipulate(student & a, student & b)
{ 1=a.1 + b.1;
deletename;
name=newchar[l+l];
strcpy(name,a.name);
strcat(name,b.name);
}
};
voidmain()
{ char * temp =''Jack'';
student name1(temp), name2('' Jill''), name3('' John'' ),S1,S2;
S1.manipulate(name1,name2);
S2.manipulate(S1,name3);
S1.display();
S2.display();
}
273
(e) Findtheoutputofthefollowingprogram: 2
#include<iostream.h>
voidmain()
{ long Number = 7583241;
int First=0, Second=0;
do
{ int R = Number%10;
if(R%2==0)
First+=R;
else
Second+=R;
Number /=10;
}while(Number>0);
cout<<First-Second;
}
(f) What is a default constructor ? How does it differ from destructor ? 2
2. (a) What is “this” pointer ? Give an example to illustrate the use of it in C++. 2
(b) Answerthequestions(i)and(ii)aftergoingthroughthefollowingclass:
classExam
{ intyear;
public:
Exam(inty) {year=y;} //Constructor1
Exam(Exam&t); //Constructor 2
};
(i) Create an object, such that it invokes Constructor 1. 1
(ii) WritecompletedefinitionforConstructor2. 1
(c) DefineaclassnamedHOUSINGinC++withthefollowingdescriptions: 4
Privatemembers
REG_NO integer(Ranges 10 - 1000)
NAME Arrayofcharacters(String)
TYPE Character
COST Float
274
PublicMembers
• Function Read_Data() to read an object of HOUSING type
• FunctionDisplay()todisplaythedetailsofanobject
• Function Draw_Nos()to choose and display the details of 2 houses
selected randomly from an array of 10 objects of type HOUSING. Use
randomfunctiontogeneratetheregistrationnos.tomatchwithREG_NO
fromthearray.
(d) Answer the questions (i) to (iii) based on the following code :
classfurniture
{
charType;
char Model[10];
public:
furniture();
voidRead_fur_details();
voidDisp_fur_details();
};
classsofa:publicfurniture
{
intno_of_seats;
floatcost_of_sofa;
public:
voidRead_sofa_details();
voidDisp_sofa_details();
};
classoffice:privatesofa
{
intno_of_pieces;
chardelivery_date[10];
public:
voidRead_office_details();
voidDisp_office_details();
};
voidmain()
{ officeMyFumiture; }
275
(i) MentionthemembernameswhichareaccessiblebyMyFumituredeclaredin
main()function. 1
(ii) WhatisthesizeofMyFumiture inbytes? 1
(iii) Mention the names of functions accessible from the member function
Read_office_details()ofclassoffice. 2
3. (a) Write a function in C++ which accepts an integer array and its size as arguments/
parameters and assign the elements into a two dimensional array of integers in the
followingformat: 3
If the array is 1, 2, 3, 4, 5, 6 If the array is 1, 2, 3
The resultant 2 D array is given below The resultant 2 D array is given below
1 0 0 0 0 0 1 0 0
1 2 0 0 0 0 1 2 0
1 2 3 0 0 0 1 2 3
1 2 3 4 0 0
1 2 3 4 5 0
1 2 3 4 5 6
(b) An array MAT[20][10] is stored in the memory along the row with each element
occupying 4 bytes of memory. Find out the base address and the address of element
MAT[10][5], if the location of MAT[3][7] is stored at the address 1000. 4
(c) Introduction class stack
{ int data[10];
int top;
public:
stack() {top=-l)
void push(); // to push an element into the stack
void pop(); // to pop an element from the stack
void Delete(int ITEM); // To delete all elements which are equal to ITEM
};
Complete the class with all function definitions. Use another stack to transfer data
temporarily. 4
(d) WriteafunctioninC++toperformInsertoperationindynamicallyallocatedQueue
containingnamesofstudents. 3
(e) Writetheequivalentinfixexpressionfor 2
10, 3, *, 7, 1, -, *, 23, +
276
4. (a) voidmain()
{ char ch='A';
fstreamfileout(“data.dat”,ios::app);
fileout<<ch;
intp=fileout.tellg();
cout<<p;
}
Whatistheoutputifthefilecontentbeforetheexecutionoftheprogramisthestring?
“ABC” (Note that “”are not part of the file) 1
(b) Write a function to count the number of blanks present in a text file named
“PARA.TXT. 2
(c) Following is the structure of each record in a data file named PRODUCT.DAT”.
struct PRODUCT
{ char Product_Code[10];
charProduct_Description[10];
intStock;
};
Write a function in C++ to update the file with a new value of Stock. The Stock and
the Product_Code, whose Stock to be updated, are read during the execution of the
program. 3
5. (a) What are DDL and DML ? 2
(b) Study the following tables FLIGHTS and FARES and write SQLcommands for the
questions (i) to (iv) and give outputs for SQL queries (v) to (vi).
TABLE : FLIGHTS
FL_NO STARTING ENDING NO_FLIGHTS NO_STOPS
IC301 MUMBAI DELHI 8 0
IC799 BANGALORE DELHI 2 1
MC101 INDORE MUMBAI 3 0
IC302 DELHI MUMBAI 8 0
AM812 KANPUR BANGALORE 3 1
IC899 MUMBAI KOCHI 1 4
AM501 DELHI TRIVANDRUM 1 5
MU499 MUMBAI MADRAS 3 3
IC701 DELHI AHMEDABAD 4 0
277
TABLE : FARES
FL_NO AIRLINES FARE TAX%
IC701 IndianAirlines 6500 10
MU499 Sahara 9400 5
AM501 JetAirways 13450 8
IC899 IndianAirlines 8300 4
IC302 IndianAirlines 4300 10
IC799 IndianAirlines 10500 10
MC101 DeccanAirlines 3500 4
(i) Display FL_NO and NO_FLIGHTS from “KANPUR” to
“BANGALORE”fromthetableFLIGHTS.
(ii) Arrange the contents of the table FLIGHTS in the ascending order of
FL_NO.
(iii) Display the FL_NO and fare to be paid for the flights from DELHI to
MUMBAI using the tables FLIGHTS and FARES, where the fare to be
paid=FARE+FARE*TAX%/100.
(iv) Display the minimum fare “IndianAirlines” is offering from the table
FARES.
(v) SELECTFL_NO,NO_FLIGHTS,AIRLINESfromFLIGHTS,FARES
whereSTARTING=“DELHI”andFLIGHTS.FL_NO=FARES.FL_NO.
(vi) SELECTcount(distinctENDING)fromFLIGHTS.
6. (a) StateandverifyAssociativeLaw. 2
(b) Writetheequivalentexpressionforthefollowinglogicalcircuit: 2
278
(c) Express P + Q'R in POS form. 1
(d) ReducethefollowingBooleanexpressionusingK-Map: 3
F(P, Q, R, S) =
π
(0, 3, 5, 6, 7, 11, 12, 15)
7. (a) Nametwotransmissionmediafornetworking. 1
(b) Expandthefollowingterms: 1
(i) XML
(ii) GSM
(iii) SMS
(iv) MAN
(c) Differentiate between Hackers and Crackers.
(d) INDIANPUBLICSCHOOLinDarjeelingissettingupthenetworkbetweenits
differentwings.Thereare4wingsnamedasSENIOR(S),JUNIOR(J),ADMIN(A)
and HOSTELCH).
Distancebetweenvariouswingsaregivenbelow:
WingAtoWingS 100 m
WingAtoWingJ 200 m
WingAtoWingH 400 m
Wing S toWing J 300 m
WingStoWingH 100 m
WingJtoWingH 450 m
Number of Computers
WingA 10
WingS 200
WingJ 100
WingH 50
(i) SuggestasuitableTopologyfornetworkingthecomputerofallwings. 1
(ii) Name the wing where the Server is to be installed. Justify your answer. 1
(iii) SuggesttheplacementofHub/Switchinthenetwork. 1
(iv) Mentionaneconomictechnologytoprovideinternetaccessibilitytoallwings. 1
279
Marking Scheme --- Computer Science
General Instruction :
1. Theanswersgiveninthemarkingschemearemerelysuggestive;
Examiners are requested to consider all alternative correct answers conveying the
similarmeaning.
2. Allprogrammingquestions-havetobeansweredwithrespecttoC++languageonly.
3. In SQL related questions - both ways text i.e. character entries should be acceptable.
(Forexample:‘Amar’or“Amar”)
4. InSQLrelatedquestions-ignoresemicolon / terminationforqueries.
5. In SQLrelated questions - ignore case sensitivity.
6. InC++questions—Ignorecasesensitivityforfunctionnamesandvariablenames.
QUESTION PAPER CODE 91/1
EXPECTEDANSWERS/VALUEPOINTS
1. (a) (i) math.h (ii) ctype.h
( ½ Marks for each correct Header File)
(b) #defineisapreprocessordirectivethatisusedtodefineasymbolicconstant.
The symbolic constant defined, replaces the word / statement wherever it
appears in the program as a macro substitution.
Syntax: #definesymbolic_namevalue
Example: #define Pi 3.14
#defineWELCOME cout<<”HelloWorld !n”;
(Full 2 marks for illustrating the concept of #define using example)
OR
(1 mark if only definition is written)
(c) Corrected Program:
#include<iostream.h>
#include<stdio.h> // Error 1
void main()
{ struct STUDENT
{ char stu_name[20];
char stu_sex;
int stu_age; //Error 2
280
} student;
gets(student.stu_name); //Error 3
cin>>student.stu_sex; //Error 4
student.stu_age = 17; //Ignored
}
( ½ mark each for removing four errors)
OR
(1 Mark to be given for only identification of all the errors without
rectification)
Note: If student replaces gets by cin>> or cin.getline( )and does not
mention <stdio.h> then full marks to be given if other errors are
corrected.
(d) DelhiMumbai
DelhiMumbaiNagpur
(3 full marks for identifying error in definition of the constructor
state() in Line 7)
OR
(3 marks for the correct lines of output)
OR
(2 marks for any one correct line of output)
OR
(1 Mark for showing the output starting with Delhi)
(e) 2 (assumingRasRem)
(2 marks for correct output as 2)
OR
(2 marks for identifying error as R is not declared)
OR
(Full 2 marks to be awarded to the students who have scored at least
1 mark in the entire Q. No. 1 i.e. from 1(a) to 1(f))
(f) —
Note: Students are exposed to the concept of “Structures” and “Nested
Loops”,butnotexposedspecificallytotheconceptof “Nestedstructures”.
So benefit of doubt should be given to the students.
(2 marks for correct definition or example)
OR
(Full 2 marks to be awarded to the students who have scored at least
1 mark in the entire Q. No. 1 i.e. from 1(a) to 1(f))
281
2. (a) InMultilevelinheritance,aclassinheritsit’spropertiesfromanotherderived
classtransitively.
InMultipleinheritance,aderivedclassinheritsfrommultiplebaseclasses.
(1/2 mark each for any correct definition)
(1/2 mark each for any correct example – diagrammatic/C++
representation)
OR
(Full 2 marks for explaining the 2 types of inheritance with the help
of suitable examples or diagram)
(b) Interview Ob1(5);
OR
int N=5; Interview Ob1(N);
(1 mark for proper declaration of Object)
Interview(Interview &t)
{
month = t.month;
}
(1 mark for writing proper statements inside definition of Constructor 2)
OR
(1 mark for writing the conceptual definition of the copy constructor)
OR
(Only ½ mark for mentioning the term: copy constructor)
Note: Any valid statement in C++ working with t as an object of
Interview must be accepted while defining the constructor.
BA
A
B
C
C
282
(c) class ADMISSION
{
int AD_NO;
char NAME[20]; //or any constant size
char CLASS;
float FEES;
public:
void Read_Data()
{
do
{
cin>>AD_NO;
}while (AD_NO<10 || AD_NO>2000);
gets(NAME);
cin>>CLASS;
cin>>FEES;
}
void Display()
{
cout<<AD_NO;
cout<<NAME;
cout<<CLASS;
cout<<FEES;
}
void Draw_Nos();
};
(1 mark for proper syntax of class definition with correct class name
and a semicolon to end the class definition)
(1 mark for proper declaration of private members)
(1 mark for proper definition of Read_Data())
(1 mark for proper definition of Display())
Note: No marks should be deducted for
Not checking the range for AD_NO
Not declaring or defining Draw_Nos(). (Mentioned as Draw-
Nos() in the question paper)
283
(d) (i) Read_pri_details(),Disp_pri_details()
(1 mark for correct function names)
(ii) 29 bytes
OR
33 bytes
(1 mark for correct answer)
(iii) Disp_pri_details(),Read_off_details(),Disp_off_details(),
Read_sta_details(),Disp_sta_details()
(2 marks for all correct member functions)
Note:
No partial marks to be given for any of the parts.
Ignore the constructor and function itself
3. (a) const int R = 100, C = 100;
void Arrayconvert(int A1D[], int N)
{
int A2D[R][C]={0};
for(int I = 0; I<N; I++)
for (int J = 0; J <N-I; J++)
A2D[I][J] = A1D[J];
}
OR
const int R = 100, C = 100;
void Arrayconvert(int A1D[], int N)
{
int A2D[R][C];
for(int I = 0; I<N; I++)
for (int J = 0; J <N; J++)
if (J<N-I)
A2D[I][J] = A1D[J];
else
A2D[I][J] = 0;
}
284
OR
const int R = 100, C = 100;
void Arrayconvert(int A1D[], int N)
{
int A2D[R][C], I, J;
for(I = 0; I<N; I++)
for (J = 0; J <N; J++)
A2D[I][J] = 0;
for(I = 0; I<N; I++)
for (J = 0; J <N-I; J++)
A2D[I][J] = A1D[J];
}
OR
Any other equivalent code
(1 mark for function header)
(1 mark for correct use of nested loops)
( ½ mark for correctly assigning the values from 1D array to 2D array)
( ½ mark for assigning 0 to the rest of the elements)
Note: Ignore declaration of the 2D array.
(b) ForColumnwiseallocation
Address ofA[I][J] = BA+ W[ (J –LBC) x M + (I - LBR)]
Where
BA= BaseAddress
W = Size of each element in bytes = 8 bytes (given)
M = No. of rows in the 2DArray = 30 (given)
Address of MAT[5][7] given is 1000.
Assumption 1 : LBR=LBC=0
Therefore
1000 = BA + 8 (7 × 30 + 5)
= BA + 8 × 215
= BA + 1720
BA = 1000 – 1720
= -720
Therefore,
Base Address = - 720
Thus,Address of MAT[20][5] = -720 + 8 ( 5 × 30 + 20)
= -720 + 8 × 170
= -720 + 1360
= 640
285
Assumption 2 : LBR=LBC=1
Therefore
1000 = BA + 8 [(7-1) × 30 +(5-1)]
= BA + 8[6 × 30 + 4]
= BA + 8 ×184
= BA + 1472
BA = 1000 – 1472
= -472
Therefore,
Base Address = - 472
Thus,Address of MAT[20][5] = -472 + 8 ( 4 × 30 + 19)
= -472 + 8 × 139
= -472 + 1112
= 640
(2 marks for writing the correct column major formula or sustitution
of values in the correct formula)
(1 mark for calculating Base Address)
(1 mark for calculating final address of MAT[20][5])
(c) void queue::add( )
{
if ( (rear + 1) % 10 != front )
{
if (rear == -1 )
front = rear = 0 ;
else
rear = (rear + 1) %10;
cin>>data[rear];
}
else
cout<<”Queue full !! Overflow Error !!n”;
}
void queue::remove()
{
if (front != -1)
{
cout<< data[front]<<” deleted ”;
if(front==rear)
front=rear=-1;
else
front = (front+1)%10;
}
else
cout<<”Queue empty ! Underflow Error!!n”;
}
286
OR
void queue::add( )
{
if ( (rear + 1) % 10 != front )//Ignoring –1
initial values
{
rear = (rear + 1) %10;
cin>>data[rear];
}
else
cout<<”Queue full !! Overflow Error !!n”;
}
void queue::remove()
{
if (front != rear) //Ignoring –1 initial values
{
front = (front+1)%10;
cout<< data[front]<<” deleted…”;
}
else
cout<<”Queue empty ! Underflow Error!!n”;
}
OR
void queue::add()
{ int item;
if((front==0 && rear==9) || front==rear+1)
cout<<”nQueue overflow error”;
else
{
cout<<”nEnter an item to add : “;
cin>>item;
if(front= =-1)
{ front=0;rear=0; }
else
rear=rear+1;
if(rear==10)
rear=0;
data[rear]=item;
}
}
287
void queue::remove()
{ if((front==-1 )
cout<<”nQueue Underflow Error”;
else
{ int item=data[front];
if(front==rear)
front=rear=-1;
elseif(front==9)
front=0;
else
front=front+1;
cout<<”nDeleteditemis:“<<item;
}
}
OR
Anyotherequivalentcode
(2 marks for any correct add( )function code)
( ½ mark for checking Overflow condition)
(1 mark for changing the values of rear counter )
( ½ mark for assigning the new value at the correct position)
(2 marks for any correct remove( )function code)
(1 mark for checking Underflow condition)
(1 mark for changing the values of front counter)
Note: There is a conceptual contradiction for the function void
Delete(int ITEM) , thus the benefit of doubt is given to the student
and therefore the definition of the function is to be ignored .
(d) struct Node
{
float Data;Node *Link;
};
class Stack
{
Node *Top;
public:
Stack() { Top = NULL ; }
void Push( );void Pop ( );void Display ( );
};
288
void Stack::Push()
{
Node *Temp = new Node;
cin>>Temp->Data;
Temp->Link = Top;
Top = Temp;
}
OR
Any other code demonstrating proper Push( ) for a dynamic stack.
( ½ mark for creating new node dynamically)
( ½ mark for assigning a real number to the info part)
( 1 mark for linking new node to the Top of the Stack)
( 1 mark for assigning the new value to the Top)
(e) S.No. Element Operation InfixExpression
scanned
1 A Push a a
2 B Push b a, b
3 AND Pop, Pop, Push (a AND b) a AND b
4 A Push a a AND b, a
5 C Push c a AND b, a, c
6 AND Pop, Pop, Push(aANDc) a AND b, a AND c
7 OR Pop, Pop, Push (aAND b OR aAND c
a AND b OR a AND c
Ans: aAND b OR a AND c
(2 marks for writing correct expression)
OR
(2 full marks if any other part of Q3 is correctly attempted as students
are familiar with infix to postfix conversion only)
4. (a) 1
(1 mark for correct output)
OR
(Full 1 mark if error is mentioned due to usage of tellg( ) with out
mode as the students generally associate tellg( ) with only ios::in
mode)
OR
(Full 1 mark if student gets at least 1 Mark in any part of question 4)
289
(b) void countwords( )
{
ifstream fin;
fin.open(“Para.txt”);
char ch ;
int count = 1;
while(!fin.eof())
{
ch = fin.get();
if (ch == ‘ ’)
count ++;
}
cout<<”nNumber of words = “<<count; // Optional
fin.close(); //Optional
}
OR
void countwords( )
{
ifstream fin“Para.txt”);
char str[30] ;
int count = 0;
while(fin)
{
fin>>str;
count++;
}
cout<<”nNumber of words = “<<count; // Optional
fin.close(); //Optional
}
OR
void countwords( )
{
fstream fin;
fin.open(“Para.txt”, ios::in);
char ch[80] ;
int count = 1;
while(fin)
{
290
fin.getline(str,80);
for(int i=0;str[i]!=’0’;i++)
if (ch == ‘ ’)
count++;
}
cout<<”nNumber of words = “<<count; // Optional
fin.close(); //Optional
}
OR
void countwords( )
{
fstream fin(“Para.txt”, ios::in);
char ch[80] ;
int count = 0;
while(fin)
{
fin.getline(str,80, ‘ ’);
count++;
}
cout<<”nNumber of words = “<<count; // Optional
fin.close(); //Optional
}
OR
Anyotherequivalentcode
(1/2 mark for opening file in correct mode either using ifstream or ios::in)
(1/2 mark for correct loop)
(1/2 mark for checking for blank space/equivalent code)
(1/2 mark for counting number of words)
(c) void update()
{
fstream f;
COLONY c;
char C_Code[10];
cout<<”nEnter the Colony Code : “;
cin>>C_Code; // OR gets(C_Code);
f.open(“COLONY.DAT”,ios::binary|ios::in|ios::out);
while(f.read((char*)&c,sizeof(COLONY)))
{
if(strcmp(c.Colony_Code, C_Code)==0)
291
{
cout<<”nEnter the new Number of people : “;
cin>>c.No_of_People;
f.seekp(f.tellg()- sizeof(c));
//OR f.seekp(f.tellg()- sizeof(c), ios::beg);
//OR f.seekp(- sizeof(c), ios::curr);
f.write((char*)&c, sizeof(COLONY));
}
}
f.close();
}
OR
Anyotherequivalentcode
( ½ mark for reading Colony_ Code and No_of_People )
(1 mark for opening the file(s) in correct mode)
(½ mark for correct loop)
(1 mark for read function)
Note: Since search condition is not clearly mentioned in the question,
search and updation to be ignored
5. (a) Candidate key(s), which is not selected as Primary Key, is known as
Alternatekey(s).
(2 marks for any equivalent correct definition)
(b) (i) SELECT NAME FROM DOCTOR
WHERE DEPT = ‘MEDICINE’ AND EXPERIENCE >10;
(½ mark for correct Select statement)
(½ mark for correct Where clause)
(ii) SELECT AVERAGE(S.BASIC + S.ALLOWANCE)
FROM DOCTOR D, SALARY S
WHERE D.DEPT = ‘ENT’ AND D.ID = S.ID;
OR
SELECT AVERAGE(BASIC + ALLOWANCE)
FROM DOCTOR, SALARY
WHERE DEPT = ‘ENT’ AND DOCTOR.ID = SALARY.ID;
(1/2 mark for correct Select statement)
(1/2 mark for correct Where clause)
OR
(1 mark for students who have correctly attempted any two parts of Q5b)
292
(iii) SELECT MIN(S.ALLOWANCE)
FROM DOCTOR D, SALARY S
WHERE D.SEX = ‘F’ AND D.ID = S.ID;
OR
SELECT MIN(ALLOWANCE)
FROM DOCTOR, SALARY
WHERE SEX = ‘F’ AND DOCTOR.ID = SALARY.ID;
(½ mark for correct Select statement)
(½ mark for correct Where clause)
(iv) SELECT MAX(S.CONSULTATION)
FROM DOCTOR D, SALARY S
WHERE D.SEX = ‘M’ AND D.ID = S.ID;
OR
SELECT MAX(CONSULTATION)
FROM DOCTOR , SALARY
WHERE SEX = ‘M’ AND DOCTOR.ID = SALARY.ID;
(1/2 mark for correct Select statement)
(1/2 mark for correct Where clause)
(v) 4
(1 mark for correct answer)
(vi) NAME DEPT BASIC
John ENT 12000
(1 mark for correct answer)
6. (a) DistributiveLawsare:
(a) A (B + C) = A B + A C
(b) A + (B C) = (A + B) (A + C)
293
Verificationoffirstdistributivelawusingtruthtable:
A B C B+C A(B+C) AB AC AB+AC
0 0 0 0 0 0 0 0
0 0 1 1 0 0 0 0
0 1 0 1 0 0 0 0
0 1 1 1 0 0 0 0
1 0 0 0 0 0 0 0
1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1
1 1 1 1 1 1 1 1
ComparingColumnNumbers5and8,Distributivelawisverified.
(1 Mark for writing either of the distributive law)
(1 Mark for verification using truth table)
(b)
(2 Marks for correct expression)
OR
( ½ Mark each for (AC)’, (AB)’,( BC)’ and the final expression)
(c) (P + Q’R)
= P ( Q+Q’)(R+R’) + Q’R(P+P’)
= (PQ +PQ’) (R + R’) + PQ’R + P’Q’R
= PQR + PQ’R + PQR’ + PQ’R’ + PQ’R + P’Q’R
= PQR + PQ’R + PQR’ + PQ’R’ + P’Q’R
(1 mark for the canonical expression)
AC
AB
BC
AC
AB
BC
AC+AB+BC
294
(d) P'O' P'O PO PO'
R'S' 1 1
R'S 1
RS 1 1 1 1
RS' 1
OR
R'S' R'S RS RS'
P'O' 1 1
P'O 1 1 1
PO 1 1
PO' 1
F= RS + P’QS + P’QR + P’Q’R’S’ + PQR’S’
(1 Mark for correct placing of 1s)
(1 Mark for correct grouping)
(1 Mark for final reduced expression)
7. (a) Internet is a network of computer networks which operates world-wide
usingacommonsetofcommunicationsprotocols.
Intranetisaninter-connectednetworkwithinoneorganizationthatusesWeb
technologiesforthesharingofinformationinternally.
(Full 1 Mark for correctly defining internet only as Intranet is not
directly specified in the syllabus)
(b) (i) Code Divison MultipleAccess
(ii) UniformResourceLocator(Location)/UniversalResourceLocator(Location)
(iii) HypeTextTransfer(Transmission)Protocol
(iv) WideArea Network
( ½ mark for each term)
(c) Fault detection is easy.
Faultisolationiseasy.
OR
Anyothervalidadvantage.
(1 mark for any one correct advantage)
295
(d) (i) Star or Bus or any other valid topology or diagram.
(1 mark for mentioning any of the above topologies)
(1 mark for diagrammatic representation of any of the above topologies)
(ii) WingA,becausemaximumnumberofcomputersare locatedatWingA.
(1 mark for the correct answer)
OR
( ½ mark if only Wing A is mentioned without justification)
(ii) Hub/Switchinallthewings.
OR
CorrectdiagramdepictingplacementofHub/Switchinallthewings.
(1 mark for correct placement)
(iv) Coaxial cable / Modem / LAN / TCP-IP / Dialup/ DSL/ Leased Line
ORanyothervalidtechnology(anyone).
Note: Optical fiber, Satellite link and Microwave NOT to be
considered as valid answers.
(1 Mark for any valid technology)
QUESTION PAPER CODE 91
EXPECTEDANSWERS/VALUEPOINTS
1. (a) (i) math.h / complex.h (ii) stdlib.h
(1/2 Marks for each correct Header File)
(b) —
Note:Astheterminlinefunctionisnotmentionedinthecurriculum,benefitof
doubt should be given to the students.
(Full 2 marks to be awarded to the students who have scored at least
1 mark in the entire Q. No. 1 i.e. from 1(a) to 1(f))
(c) #include<iostream.h>
#include<stdio.h> // Error 1 - needed for gets()
void main()
{
struct movie
{
char movie_name[20];
char movie_type;
int ticket_cost = 100; //Error 2 - assignment not
//possible inside structure definition
}MOVIE;
296
gets(MOVIE.movie_name);//Error 3 -members must be
//accessed using object
cin>>MOVIE.movie_type; //Error 4 -cant use gets for
//char variable and member must
//be accessed using object.
}
#include<iostream.h>
void main()
{
struct movie
{
char movie_name[20];
char movie_type;
int ticket_cost = 100; //Error 1 – initialization‘ not
//possible inside structure definition
}MOVIE;
cin.getline(MOVIE.movie_name,20);//Error 2 -members must
//be accessed using object
cin>>MOVIE.movie_type; //Error 3 -cant use gets for
//char variable and member must
//be accessed using object.
}
(1 mark for identifying and correcting any one Error)
(1 ½ mark for identifying and correcting any two errors)
(2 marks for identifying and correcting more than two errors)
OR
(1 mark for only identifying all errors)
(d) JackJill
JackJillJohn
(2 marks for any one correct line)
(Full 3 marks for both lines correct)
(½ mark to be deducted from full 3 marks, if endl is not considered)
(e) -2
(Full 2 marks for correct output)
OR
(Full 2 marks for mentioning values of First as 14 and Second as 16,
as representation of minus sign is not very prominent)
OR
(Full 2 marks for mentioning syntax error with justification as
insertion operator << expected in between First and Second)
297
(f) Aconstructor that accepts no parameters is called the default constructor.
The compiler supplies a default constructor, if a class has no explicit
constructor defined. It initializes the data members by a dummy value. It is
also used to create objects with default values.
Destructorisusedtodestroytheobjectsanddeallocatethememoryresources
that have been allocated by a constructor. It has same name as the class
preceded by tilde (~). It takes no arguments and no return types can be
specified.
(1 mark for each correct definition / example of default constructor)
(1 mark for any difference / correct definition / correct example for
destructor)
2. (a) Studentsareexposedtotheconceptofpointers,butnotexposedspecifically
to the concept of “this” pointer. So benefit of doubt should be given to the
students.
(Full 2 marks to be given to students who have correctly attempted
for at least 1 mark in the entire Q. No. 2 (a) to 2 (d))
(b) (i) Exam E(5);
(1 mark for proper declaration of Object)
(ii) Exam (Exam &t)
{year = t.year;}
OR
Copy constructor: It is an overloaded constructor, in which object of
the same class is passed as parameter.
(1 mark for writing proper statements inside definition of
Constructor 2)
OR
(1 mark for any valid statement in C++ working with t as an
object of Exam)
OR
(1 mark for writing the definition/explanation of the concept of
copy constructor)
OR
(1/2 mark for mentioning only the term copy constructor)
298
(c) class HOUSING
{
int REG_NO;
char NAME[20];
char TYPE;
float COST;
public:
void Read_Data();
void Display();
void Draw_Nos(HOUSING S);
};
void HOUSING::Read_Data()
{
cin>>REG_NO; //Validation not required
cin>>NAME; //OR gets(NAME);
cin>>TYPE; cin>>COST;
}
void HOUSING::Display()
{
cout<<REG_NO<<NAME<<TYPE<<COST<<endl;
}
void HOUSING::Draw_Nos();//Ignore
(1/2 mark for proper syntax of class definition with correct class name
and a semicolon to end the class definition)
(1/2 mark for mentioning the proper visibility modes (private / public))
(1 mark for proper declaration of private data members)
(1 mark for proper definition of Read_Data() with user entry for data
members OR declaring a local object and entering the values of data
members of this object )
(1 mark for proper definition of Display())
Note:As language of Third part of this question has ambiguity, it is
required to be ignored. Moreover, if anyone has partially attempted
thethirdpart(i.e.,Draw_nosfunction)andnotattempted/notcorrectly
attempted Read/Display function, he/she should be given 2 Marks
for Third part taking into consideration the marks for this question
should not exceed the max. marks allocated (i.e. 4 marks) to this
question 2 (c).
299
(d) (i) Read_office_details
Disp_office_details.
(1 mark for correct names)
(ii) 29 bytes
OR
33 Bytes
(1 mark for correct answer)
(iii) Read_fur_details(),
Disp_fur_details,
Read_sofa_details(),
Disp_sofa_details(),
Disp_office_details()
Read_office_details() (Optional)
(2 marks for correct answer)
3. (a) const int R = 100, C = 100;
void Arrayconvert(int A1D[ ], int N)
{
int A2D[R][C]={0};
for(int I = 0; I<N; I++)
for (int J = 0; J <=I; J++)
A2D[I][J] = A1D[J];
}
( 1 mark for proper function header )
( 1 mark for proper use of loops)
( 1 mark for proper assignment of values)
(b) ForRowwiseallocation
Address ofA[I][J] = BA+ W( (I-LBR) x N + (J-LBC))
Where
BA= BaseAddress
W = Size of each element in bytes = 4 bytes (given)
N = No. of columns in the 2DArray = 10 (given)
Address of MAT[3][7] given is 1000.
Therefore
(Assumption 1: LBR = LBC = 0)
MAT[3][7]=100 = BA + 4 (10 (3-0) + (7-0))
= BA + 148
BA = 1000 – 148
= 852
300
Therefore,
Base Address = 852
Thus,Address of MAT[10][5] = 852 + 4 ( 10 (10-0) + (5-0))
= 852+420
= 1272
OR
(Assumption 2: LBR = LBC = 1)
MAT[3][7]=1000 = BA + 4 (10 (3-1) + (7-1))
= BA + 104
BA = 1000 – 104
= 896
Therefore,
Base Address = 896
Thus,Address of MAT[10][5] = 896 + 4 ( 10 (10-1) + (5-1))
= 896+376
= 1272
(1 mark for writing the correct formula / correct substituted values,
for row major properly, for calculating Base Address)
(1 mark for calculating correct Base Address)
(1 mark for writing the correct formula / correct substituted values,
for row major properly, for calculating Address of MAT [10][5] )
(1 mark for calculating correct address of MAT [10][5])
(c) void stack::push()
{
int n;
cout<<”Enter a value”;cin>>n;
if (top==10)
cout<<”Stack Overflow”;
else
data[++top]=n;
}
void stack::pop()
{
if (top==-1)
cout<<”Stack Underflow”;
else
cout<<data[top--];
}
void stack::Delete(int ITEM);//Ignore this part
301
[PushOperation]
(1/2 mark for checking overflow condition)
(1/2 mark for using increment in Top variable)
(1 mark for correct assignment of data in stack)
[PopOperation]
(1/2 mark for checking underflow condition)
(1/2 mark for using decrement in Top variable)
(1 mark for displaying or returning value of the popped element from
the stack)
Note:As language of Third part of this question has ambiguity with
respect to Stack Operation, it is required to be ignored. Moreover, if
anyone has partially attempted the third part (i.e. Delete function)
and not attempted/not correctly attempted Push/Pop should be given
2 Marks for Third part taking into consideration the marks for this
question should not exceed the max. marks allocated (i.e. 4 marks)
to this question 3 (c).
(d) struct Student
{
char Name[20];Student *Link;
};
class Queue
{
Student *FRONT, *REAR;
public:
Queue() { FRONT = NULL ; REAR = NULL}
void Insert( );
};
void Queue::Insert()
{
Student *Temp = new Student;
gets(Temp->Name);
Temp->Link = NULL;
if(REAR==NULL)
{ FRONT=Temp; REAR = Temp; }
else
{
REAR->Link = Temp;
REAR=Temp;
}
}
302
OR
Any other code demonstrating proper Insert() for a dynamic Queue.
(1 mark for creating a dynamic Node and entering / assigning the
value for Name)
(1 mark for creating a Link with the previous Node)
(1 mark for assigning new value of Rear.)
Note:
1. Ignorethestructandclassimplementationwhileawardingmarks
in this question
2. Equivalent code with DynamicArray should also be considered
as correct solution
(e) 10*3*(7-1)+23
(Full 2 marks to be given to students who have correctly attempted
for at least 1 mark in the entire Q. No. 3 (a) to 3 (e))
Note:AsstudentsareexposedtoConversionfromINFIXtoPOSTFIX
and Evaluation of POSTFIX only, he/she may not be able to
comprehend the conversion from POSTFIX to INFIX.
4. (a) 4
(1 mark for correct output)
OR
(1 mark if error mentioned due to usage of tellg() with app mode)
(b) void CountSpace()
{
fstream fin;
fin.open(“PARA.TXT”, ios::in);
OR
ifstream fin(“PARA.TXT”);
char ch ;
int count = 0;
while(!fin.eof())
{
ch = fin.get();
if (ch == ‘ ‘) //(ch==32) OR (ch==255)
count ++;
}
cout<<”Number of spaces = “<<count; //Ignore
fin.close(); //Ignore
}
303
OR
Any equivalent code that counts the number of words from the file
(1/2 Mark for opening the file in right mode)
(1/2 Mark for correct loop structure i.e. with a condition checking for
end of file)
(1/2 Mark for reading a character / line from the file)
(1/2 Mark for checking for space and incrementing the counter)
(c) void modify( )
{
fstream out;
out.open(“PRODUCT.DAT”,ios::binary|ios::in|ios::out);
PRODUCT P1;
int flag=0,stock;char PCode[10];
gets(PCode);
cin>>stock;
while (out.read((char*)&P1, sizeof(P1))
if (strcmp(P1.Product_code,Pcode)==0)
// strcmpi()may also be considered
{
flag=1;
P1.Stock=stock;
int Position=out.tellg( )-sizeof(P1);
out.seekp(Position);
//OR
out.seekp(-sizeof(P1),ios::cur);
out.write((char*)&P1, sizeof(P1);
}
}
if (flag==0) cout<<”Product Code does not match”;
//OR
if (!flag) cout<<”Product Code does not match”;
out.close();
}
OR
Any other equivalent code
(1/2 Mark for opening the file in ‘in’ as well as ‘out’ mode)
(1/2 Mark for declaring object and temporary variables required for
product code and stock)
(1/2 Marks for correct loop, check of end of file and reading of an
object from the file)
(1/2 Mark for correct comparison)
(1/2 Mark for identifying and moving the file pointer to the correct
position)
(1/2 Mark writing the modified/updated data on right position in the
file)
304
5. (a) DDL–DataDefinitionLanguage
DML–DataManipulationLanguage
(1 Mark each for correct full form OR correctly explaining with the
help of examples)
(b) (i) SELECT FL_NO,NO_FLIGHTS FROM FLIGHTS
WHERE STARTING=’KANPUR’ AND ENDING=’BANGALORE’;
(1/2 Mark for using SELECT and FROM correctly)
(1/2 Mark for correct WHERE clause)
(ii) SELECT * FROM FLIGHTS ORDER BY FL_NO;
(1/2 Mark for using SELECT and FROM correctly)
(1/2 Mark for correct ORDER BY clause [ASC is optional])
(iii) SELECT FLIGHTS.FL_NO, FARE+FARE*TAX/100
FROM FLIGHTS, FARES WHERE FLIGHTS.STARTING=’DELHI’ AND
FLIGHTS.ENDING=’MUMBAI’ AND FLIGHTS.FL_NO=FARES.FL_NO;
*Assuming TAX% as TAX
(Full 1 Mark for correctly attempting any part of 5 (b))
(iv) SELECT MIN(FARE) FROM FARES WHERE AIRLINES=’INDIAN AIRLINES’;
(1/2 Mark for using SELECT and FROM with MIN function correctly)
(1/2 Mark for correct WHERE clause)
(v) FL_NO NO_FLIGHTS AIRLINES
IC302 8 IndianAirlines
AM501 1 JetAirways
IC701 4 IndianAirlines
(1 Mark for correct output, Ignore First header line)
(vi) 7
(1 Mark for correct output)
305
6. (a) (i) X+(Y+Z)=(X+Y)+Z
X Y Z Y+Z X+Y X+(Y+Z) (X+Y)+Z
0 0 0 0 0 0 0
0 0 1 1 0 1 1
0 1 0 1 1 1 1
0 1 1 1 1 1 1
1 0 0 0 1 1 1
1 0 1 1 1 1 1
1 1 0 1 1 1 1
1 1 1 1 1 1 1
(ii) X.(Y.Z)=(X.Y).Z
X Y Z Y.Z X.Y X.(Y.Z) (X.Y).Z
0 0 0 0 0 0 0
0 0 1 0 0 0 0
0 1 0 0 0 0 0
0 1 1 1 0 0 0
1 0 0 0 0 0 0
1 0 1 0 0 0 0
1 1 0 0 1 0 0
1 1 1 1 1 1 1
(1 Mark for stating any one of the law)
(1 Mark for verification of any one of the law)
(b) (A+C)’.(A+B)’.(B+C)’
(1/2 Mark each for (A+C)’, (A+B)’, (B+C)’ and final expression)
OR
(Full 2 marks even if students have mentioned the reduced form of
the same expression)
(c) (P+Q’).(P+R)
OR
(P+Q’+R).(P+Q’+R’).(P+Q+R)
(1 Mark for any of the two POS forms of the given expression)
306
(d)
R+S R+S' R'+S' R'+S
P+Q 0 0
P+Q' 0 0 0
P'+Q' 0 0
P'+Q 0
F(P,Q,R,S)= (P+Q+R+S).(P’+Q’+R+S).(P+Q’+R’).(P+Q’+S’).(R’+S’)
(1 mark for representing correct places in K-Maps)
AND
(1/2 mark for grouping and writing minimum 2 Groups)
OR
(1 mark for grouping and writing minimum 3 Groups)
OR
(1 ½ mark for grouping and writing 5 Groups)
OR
(2 mark for grouping and writing final expression in reduced form)
Important: 1/2 Mark to be deducted for redundant group(s)
OR
00 01 11 10
00 1 1
01 1
11 1 1
10 1 1 1
F(P,Q,R,S)=P’QR’S’+PQ’S’+PRS’+PR’S+Q’RS’+Q’R’S
RS
PQ
0
4
12
8
1
5
13
9
7
15
11
3
6
14
16
2
SingleII Pair II
Quad I
Pair I
SingleI
RS
PQ
0
4
12
8
1
5
13
9
7
15
11
3
6
14
16
2
SingleI Pair V
Pair III
Pair II
Pair IV
Pair I
307
(1 mark for representing correct places in K-Maps)
AND
(1/2 mark for grouping and writing minimum 2 Groups)
OR
(1 mark for grouping and writing minimum 4 Groups)
OR
(1 ½ mark for grouping and writing 6 Groups)
OR
(2 mark for grouping and writing final expression in reduced form)
Important: 1/2 Mark to be deducted for redundant group(s)
7. (a) OpticalFiber
Ethernet Cable or twisted pair cable or UTP or STP
Co-axial Cable
Infrared
Radio Link OR Radiowave
Microwave link OR Microwave
Satellite Link
[Any TWO of the mentioned above OR any other correct media]
(1/2 Mark for each correct answer)
(b) (i) XML ExtensibleMarkupLanguage
(ii) GSM GlobalSystemforMobilecommunication {ignorecommunication}
(iii) SMS ShortMessagingService {Message/Messagingbothacceptable}
(iv)MAN MetropolitanArea Network
(1/2 Mark for each correct answer)
(No marks for partially correct answers)
(c) Hackers:Computerenthusiastswhoenjoylearningaboutcomputersystems
andgetintoothersystem/networkforgainingmoreknowledgeormayfind
flawsinthesystemforrectificationpurposes.
Crackers:Maliciousprogrammerswhobreakintosecuresystemsforstealing
andcorrupting/spoilingdata.
(1/2 Mark for definition of each Hacker and Cracker)
OR
(Full 1 Mark for mentioning the difference)
308
(d) (i) StarTopology
OR
BusTopology
(1 Mark for mentioning any one of the two topologies)
OR
(1 Mark for diagramatic representation of any of the above mentioned topologies)
(ii) WingS
asithasthemaximumnumberofcomputers
OR
WingA
asitisplacedintheAdminWing(forsecurityreasons)
(1/2 Mark for identification of the correct Wing)
(1/2 Mark for correct justification)
(iii) Insideallthefourwings
(1 Mark for the correct answer)
(iv) Anyoneofthefollowing:
Dialup,TCP/IP, DSL, Modem, Broadband, Cable, ISDN,Telephone
Line,Co-axial,EthernetCable,Radiowave
(1 Mark for the correct answer)
Important Note: Satellite Link, Optical Fiber, Microwave and
Leased line are not acceptable solution for this question
261
COMPUTER SCIENCE
Time allowed : 3 hours Maximum marks: 70
General Instructions:
(i) All questions are compulsory.
(ii) Programming Language : C++
QUESTION PAPER CODE 91
1. (a) DifferentiatebetweenaLogicalErrorandSyntaxError.Alsogivesuitable
examples of each in C++. 2
(b) Name theheaderfile(s)thatshallbeneeded for successful compilation of
thefollowingC++code: 1
void main( )
{
char Text[40];
strcpy(Text,”AISSCE”);
puts(Text);
}
(c) Rewrite the following program after removing the syntactical error(s),
ifany.Underlineeachcorrection. 2
#include <iostream.h>
const int Size 5;
void main()
{
int Array[Size];
Array = {50,40,30,20,10};
for(Ctr=0; Ctr<Size; Ctr++)
cout>>Array[Ctr];
}
(d) Findtheoutputofthefollowingprogram: 2
#include<iostream.h>
void main()
{
int Numbers[] = {2,4,8,10};
262
int *ptr = Numbers;
for (int C = 0; C<3; C++)
{
cout<< *ptr << “@”;
ptr++;
}
cout<<endl;
for(C = 0; C<4; C++)
{
(*ptr)*=2;
--ptr;
}
for(C = 0; C<4; C++)
cout<< Numbers [C]<< “#”;
cout<<endl;
}
(e) Findtheoutputofthefollowingprogram: 3
#include<iostream.h>
void Indirect(int Temp=20)
{
for (int 1=10; I<=Temp; I+=5)
cout<<I<<” , “ ;
cout<<endl;
}
void Direct (int &Num)
{
Num+=10;
Indirect(Num);
}
void main()
{
int Number=20;
Direct(Number) ;
Indirect();
cout<< “ Number=” <<Number<<endl ;
}
263
(f) In the following C++ program what is the expected value of Myscore from
Options(i)to(iv)givenbelow.Justifyyouranswer. 2
#include<stdlib.h>
#include<iostream.h>
void main( )
{
randomize();
int Score[] = {25,20,34,56, 72, 63}, Myscore;
Myscore = Score[2 + random(2)];
cout<<Myscore<<endl; }
(i) 25
(ii) 34
(iii) 20
(iv) None of the above
2. (a) Differentiate between Protected and Private members of a class in
context ofInheritanceusing C++. 2
(b) Answerthequestions(i)and(ii)aftergoingthroughthefollowingclass: 2
class Science
{
char Topic[20];
int Weightage;
public:
Science ( ) //Function 1
{
strcpy (Topic, “Optics” );
Weightage = 30;
cout<<“Topic Activated”;
}
~Science( ) //Function 2
{
cout’<<”Topic Deactivated”;
}
(i) NamethespecificfeaturesofclassshownbyFunction1andFunction
2 in the above example.
(ii) How would Function 1 and Function 2 get executed ?
264
(c) DefineaclassTravelinC++withthedescriptiongivenbelow: 4
PrivateMembers:
T_Code oftypestring
No_of_Adults oftypeinteger
No_of_Children oftypeinteger
Distance oftypeinteger
TotalFare oftypefloat
PublicMembers:
• Aconstructortoassigninitialvaluesasfollows:
T_Code with the word “NULL”
No_of_Adults as 0
No_of_Children as 0
Distance as 0
TotalFare as 0
• AfunctionAssignFare( )whichcalculatesandassignsthevalue
of the data memberTotalFare as follows :
For each Adult
Fare (Rs) For Distance (Km)
500 >=1000
300 <1000 & >=500
200 <500
For each Child the above Fare will be 50% of the Fare mentioned in
the above table.
Forexample:
If Distance is 750, No_of_Adults = 3 and No_of_Children = 2
ThenTotalFare should be calculated as
No_of_Adults * 300 + No_of_Children * 150
i.e. 3 * 300 + 2 * 150 = 1200
• AfunctionEnterTraveK)toinputthevaluesofthedatamembers
T_Code, No_of_Adults, No_of_Children and Distance; and
invoketheAssignFare()function.
• Afunction ShowTraveK) which displays the content of all the
data members for aTravel.
(d) Answer the questions (i) to (iv) based on the following code : 4
class Teacher
{
char TNo[5], TName[20], DeptflO];
int Workload;
265
protected:
float Salary;
void AssignSal(float);
public:
Teacher( ) ;
void TEntry( ) ;
void TDisplay( );
};
class Student
{
char Admno[10], SName[20], Stream[10];
protected:
int Attendance, 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) Identifythememberfunctiion(s)thatcannotbecalleddirectlyfromthe
objectsofclassSchoolfromthefollowing:
TEntry()
SDisplay()
SchEntry()
(iii) Writenameofallthemember(s)accessiblefrommemberfunctionsof
class School.
(iv) IfclassSchoolwasderivedprivatelyfromclassTeacherandprivately
from class Student, then, name the member function(s) that could be
accessed through Objects of class School.
266
3. (a) Write a function in C++ which accepts an integer array and its size.as
argumentsandreplaceselementshavingevenvalueswithitshalfandelements
havingoddvalueswithtwiceitsvalue. 4
Example:ifanarrayoffiveelementsinitiallycontainstheelementsas
3, 4, 5, 16, 9
then the function should rearrange the content of the array as
6, 2, 10, 8, 18
(b) AnarrayArr[15][20]isstoredinthememoryalongtherowwitheachelement
occupying 4 bytes. Find out the BaseAddress and address of the element
Arr[3][2], if the elementArr[5][2] is stored at the address 1500. 4
(c) WriteafunctioninC++todeleteanodecontainingcustomer’sinformation,
from a dynamically allocated Queue of Customers implemented with
the helpofthefollowingstructure: 4
struct Customer
{
int CNo;
char CName[20];
Customer *Link;
};
(d) Write a functionin C++ whichaccepts a2D arrayofintegers andits size
asargumentsanddisplaystheelementsofmiddlerowandtheelementsof
middlecolumn. 2
[Assuming the 2DArray to be a square matrix with odd dimension
i.e. 3×3, 5×5, 7×7 etc...]
Example,ifthearraycontentis
3 5 4
7 6 9
2 1 8
Outputthroughthefunctionshouldbe:
Middle Row : 7 6 9
Middle Column : 5 6 1
(e) Evaluatethefollowingpostfixnotationofexpression: 2
15 3 2 + / 7 + 2 *
4. (a) Observetheprogramsegmentgivenbelowcarefully,andanswerthequestion
thatfollows: 1
class Labrecord
{
int Expno;
char Experiment[20];
char Checked;
267
int Marks;
public :
//function to enter Experiment details
void EnterExp( );
//function to display Experiment details
void ShowExp ( ) ;
//function to return Expno
char RChecked ( ) {return Checked;}
//function to assign Marks
void Assignmarks(int M)
{ Marks = M;}
};
void MpdifyMarks()
{ fstream File;
File.open(“Marks.Dat”,ios::binary|ios::in|ios::out);
Labrecord L;
int Rec = 0;
while (File.read((char*)&L, sizeof(L)))
{
if(L.RChecked( )== ‘ N ‘ )
L.Assignmarks(0)
else
L.Assignmarks(10)
_____________________ //statement 1
______________________ //statement 2
Rec ++ ;
}
File.close ();
}
IfthefunptionModifyMarks()issupposedtomodifyMarksfortherecords
in the file MARKS.DAT based on their status of the member Checked
(containing value eitherVor ‘N’).Write C++ statements for the statement
1and statement 2, where, statement 1is required to position the file write
pointer to an appropriate place in the file and statement 2 is to perform the
writeoperationwiththemodifiedrecord.
(b) WriteafunctioninC++toprintthecountoftheword theasanindependent
wordinatextfileSTORY.TXT. 2
For example, if the content of the file STORY.TXTis
There was a monkey in the zoo. The
monkeywasverynaughty.
Then the output of the program should be 2.
268
(c) Given a binary file SPORTS.DAT, containing records of the following
structuretype:
struct Sports
{
char Event[20];
char Participant[10][30];
};
WriteafunctioninC++thatwouldreadcontentsfromthefileSPORTS.DAT
andcreatesafilenamedATHLETIC.DATcopyingonlythoserecordsfrom
SPORTS.DATwheretheeventnameis“Athletics”. 3
5. (a) What is the importance of a Primary Key in a table ? Explain with a suitable
example. 2
(b) Consider the following tables Consignor and Consignee. Write SQL
commandsforthestatements(i)to(iv)andgiveoutputsforSQLqueries(v)
to(viii). 6
TABLE : CONSIGNOR
CnorlD CnorName CnorAddress City
ND01 RSinghal 24,ABC Enclave NewDelhi
ND02 AmitKumar 123,PalmAvenue NewDelhi
MU15 RKohli 5/A, South Street Mumbai
MU50 S Kaur 27-K, Westend Mumbai
TABLE : CONSIGNEE
CneelD CnorlD CneeName CneeAddress CneeCity
MU05 ND01 RahulKishore 5, ParkAvenue Mumbai
ND08 ND02 PDhingra 16/J, Moore Enclave NewDelhi
KO19 MU15 APRoy 2A,CentralAvenue Kolkata
MU32 ND02 SMittal P245,AB Colony Mumbai
ND48 MU50 BPJain 13, Block D,AVihar NewDelhi
(i) TodisplaythenamesofallConsignorsfromMumbai.’
(ii) To display the CneelD, CnorName, CnorAddress, CneeName,
CneeAddress for every Consignee.
(iii) To display consignee details in ascending order of CneeName.
(iv) To displaynumberofconsignorsfromeachcity,
269
(v) SELECT DISTINCT City FROM CONSIGNEE;
(vi) SELECTA.CnorName, B.CneeName
FROM ConsignorA, Consignee B
WHEREA.CnorID = B.CnorlDAND B.CneeCity = ‘Mumbai’;
(vii) SELECT CneeName, CneeAddress
FROMConsignee
WHERE CneeCity NOT IN (‘Mumbai’, ‘Kolkata’);
(viii) SELECT CneelD, CneeName
FROMConsignee
WHERE CnorID=’MU15' OR CnorID=’ND01';
6. (a) State De Morgan’sTheorems and verify the same using truth table. 2
(b) WritetheequivalentCanonicalProductofSumExpressionforthefollowing
SumofProductExpression
F(X, Y, Z) = Σ (0, 2, 4, 5) 2
(c) WritetheequivalentBooleanexpressionforthefollowingLogicCircuit. 2
(d) ReducethefollowingBooleanexpressionusingK-Map: 2
F(A, B, C, D) = π(5,6,7,8,9,12,13,14,15)
7. (a) What is the significance of Cyber Law ? 1
(b) ExpandthefollowingtermswithrespecttoNetworking: 2
(i) XML
(ii) WWW
(iii) WLL
(iv) TCP/IP
270
(c) Which of the following units measures the speed with which data can be
transmitted from one node to another node of a network ?Also, give the
expansionofthesuggestedunit. 1
(i) KMph
(ii) Mbps
(iii) MGps
(d) “HindustanConnectingWorldAssociation”isplanningtostarttheirofficesin
fourmajorcitiesinIndiatoprovideregionalITinfrastructuresupportinthe
fieldofEducation&Culture.Thecompanyhasplannedtosetuptheirhead
officeinNewDelhiinthreelocationsandhavenamedtheirNewDelhioffices
as“SalesOffice”,”HeadOffice”and“TechOffice”.Thecompany’sregional
offices are located at ”Coimbatore”, “Kolkata” and “Ahmedabad”.
Aroughlayoutofthesameisasfollows:
Approximate distances between these offices as per network survey team
is asfollows:
Place From PlaceTo Distance
HeadOffice SalesOffice 10 KM
HeadOffice TechOffice 70 Meter
HeadOffice KolkataOffice 1291 KM
HeadOffice AhmedabadOffice 790 KM
HeadOffice CoimbatoreOffice 1952 KM
271
In continuation of the above, the company experts have planned to install
thefollowingnumberofcomputersineachoftheiroffices:
HeadOffice 100
SalesOffice 20
TechOffice 50
KolkataOffice 50
AhmedabadOffice 50
CoimbatoreOffice 50
(i) Suggestnetworktype(outofLAN,MAN,WAN)forconnectingeach
ofthefollowingsetoftheiroffices:
• Head Office andTech Office
• Head Office and Coimbatore Office
(ii) Which device will you suggest to be procured by the company for
connecting all the computers within each of, their offices out of the
followingdevices?
• Modem
• Telephone
• Switch/Hub
(iii) Whichofthefollowingcommunicationmedia,willyousuggesttobe
procured by the company for connecting their local offices in New
Delhiforveryeffectiveandfastcommunication?
• EthernetCable
• OpticalFiber
• TelephoneCable
(iv) Suggestacable/wiringlayoutforconnectingthecompany’slocaloffices
located in New Delhi.Also,, suggest an effective method/technology
for connecting the company’s regional offices at “Kolkata”,
“Coimbatore”and“Ahmedabad”. 4
QUESTION PAPER CODE 91/1
1. (a) DifferentiatebetweenaRunTimeErrorandSyntaxError.Alsogivesuitable
examples of each in C++. 2
(b) Nametheheaderfile(s)thatshallbeneededforsuccessfulcompilationofthe
followingC++code 1
void main ( )
{
char String [20];
gets (String);
strcat (String, “CBSE”);
puts (String);
}
272
(c) Rewritethefollowingprogramafterremovingthesyntacticalerror(s)ifany.
Underlineeachcorrection. 2
# include <iostream.h>
const int Max 10;
void main ( )
{
int Numbers [Max];
Numbers = { 20, 50,10, 30,40 } ;
for (Loc= Max-1 ; Loc > = 0 ; Loc - -)
cout>>Numbers [Loc];
}
(d) Findtheoutputofthefollowingprogram: 2
# include < iostream.h>
void main ()
{
intArray[] = {4,6,10,12};
int *pointer = Array ;
for (int I=1 ; I<=3 ; I++)
{
cout<<*pointer<<#”;
pointer ++;
}
cout<<endl;
for (I=1 ; I<=4 ; I++)
{
(*pointer)*=3 ;
-- pointer;
}
for(I=l; I<5; I + + )
cout << Array [I-1] << “@”;
cout << endl;
}
(e) Findtheoutputofthefollowingprogram: 3
# include < iostream.h>
void Withdef (int HisNum = 30)
{
for (int 1=20 ; I<*= HisNum; I+=5)
cout<<I<<””;
cout<<endl;
}
void Control (int &MyNum)
{
273
MyNum+=10;
Withdef(MyNum);
}
void main ()
{
int YourNum=20;
Control (YourNum);
Withdef();
cout<<”Number=”<<YourNum<<endl;
}
(f) InthefollowingC++programwhatistheexpectedvalueofMyMarksfrom
Options(i)to(iv)givenbelow.Justifyanswer. 2
#include<stdlib. h >
# include<iostream. h>
void main ()
{
randomize ();
int Marks [ ]= {99, 92, 94, 96, 93, 95}, MyMarks;
MyMarks = Marks [1 + random (2) ];
cout<<MyMarks<<endl;
}
(i) 99 (ii) 94
(iii) 96 (iv) None of the above
2. (a) DifferentiatebetweenConstructorandDestructorfunctionincontextof
Classes and Objects using C++ 2
(b) Answerthequestions(i)and(ii)aftergoingthroughthefollowingclass 2
class Maths
{
char Chapter [20];
int Marks;
public:
Maths ( ) //Member Function 1
{
strcpy (Chapter, “Geometry”);
Marks = 10;
cout<<“Chapter Initialised”;
{
~Math () //Member Function 2
}
cout<<”Chapter Over”;
}
};
274
(i) NamethespecificfeaturesofclassshownbyMemberFunction1and
Member Function 2 in the above example.
(ii) HowwouldMemberFunction1andMemberFunction2getexecuted?
(c) Define a classTour in C++ with the description given below : 3
PrivateMembers:
TCode oftypestring
NoofAdults oftypeinteger
NoofKids oftypeinteger
Kilometres oftypeinteger
TotalFare oftypefloat
PublicMembers:
• Aconstructortoassigninitialvaluesasfollows:
TCode with the word “NULL”
NoofAdults as 0
NoofKids as 0
Kilometres as 0
TotalFare as 0
• AfunctionAssignFare ( ) which calculates and assigns the value of
the data memberTotalFare as follows
For each Adult
Fare(Rs) For Kilometres
500 >=1000
300 <1000&>=500
200 <500
Foreach KidtheaboveFarewillbe50%oftheFarementionedinthe
above table
Forexample:
If Kilometres is 850, NoofAdults = 2 and NoofKids = 3
ThenTotalFare should be calculated as
NumofAdults * 300 + NoofKids * 150
i.e. 2*300 + 3*150=1050
• A function EnterTour( ) to input the values of the data members
TCode, NoofAdults, NoofKids and Kilometres; and invoke the
AssignFare()function.
• A function ShowTour( ) which displays the content of all the data
members for aTour.
275
(d) Answer the questions (i) to (iv) based on the following code : 4
class Trainer
{
char TNo [5], TName [20], Specialisation [10];
int Days;
protected :
float Remuneration;
void AssignRem (float);
public :
Trainer ( ) ;
void TEntry ( );
void TDisplay ( );
};
class Learner
{
char Regno [10], LName [20], Program [10];
Protected :
int Attendance, Grade;
public:
Learner ( );
void LEntry ( );
void LDisplay ( );
};
class Institute : public Learner, public Trainer
{
char ICode[10], IName [20]; (
public:
Institute ( );
void IEntry ( );
void IDisplay ( );
};
(i) Which type of Inheritance is depicted by the above example?
(ii) Identifythememberfunction(s)thatcannotbecalleddirectlyfromthe
objectsofclassInstitutefromthefollowing
TEntry()
LDisplay()
IEntry()
276
(iii) Writenameofallthemember(s)accessiblefrommemberfunctionsof
classInstitute.
(iv) IfclassInstitutewasderivedprivatelyfromclassLearnerandprivately
from classTrainer, then, name the member function(s) that could be
accessed through Objects of class Institute.
3. (a) Write a function in C++ which accepts an integer array and its size as
argumentsandreplaceselementshavingoddvalueswiththriceitsvalueand
elementshavingevenvalueswithtwiceitsvalue.
Example:ifanarrayoffiveelementsinitiallycontainstheelementsas
3, 4, 5, 16, 9
then the function should rearrange the content of the array as
9, 8, 15, 32, 27 4
(b) AnarrayArray[20][15]isstoredinthememoryalongthecolumnwitheach
element occupying 8 bytes. Find out the BaseAddress and address of the
elementArray[2][3] if the elementArray [4] [5] is stored at the address
1000. 4
(c) Write a function in C++ to delete a node containing Book’s information,
fromadynamicallyallocatedStackofBooksimplementedwiththehelpof
thefollowingstructure. 4
struct Book
}
int BNo;
char BName[20];
Book *Next;
};
(d) Write a function in C++ which accepts a 2D array of integers and its size as
argumentsanddisplaystheelementswhichlieondiagonals. 2
[Assuming the 2DArray to be a square matrix with odd dimension
i.e. 3×3, 5×5, 7×7 etc.]
Example,ifthearraycontentis
5 4 3
6 7 8
1 2 9
Outputthroughthefunctionshouldbe:
Diagonal One : 5 7 9
Diagonal Two : 3 7 1
277
(e) Evaluatethefollowingpostfixnotationofexpression: 2
25 8 3 - / 6 * 10 +
4. (a) Observetheprogramsegmentgivenbelowcarefully,andanswerthequestion
thatfollows: 1
class PracFile
{
intPracno;
char PracName[20];
int TimeTaken;
int Marks;
public:
// function to enter PracFile details
void EnterPrac( );
// function to display PracFile details
void ShowPrac( ):
// function to return TimeTaken
int RTime() {return TimeTaken;}
// function to assign Marks
void Assignmarks (int M)
{ Marks = M;}
};
void AllocateMarks( )
{ fstreamFile;
File.open(“MARKS.DAT”,ios::binary|ios::in|ios::out);
PracFile P;
int Record = 0;
while (File.read(( char*) &P, sizeof(P)))
{
if(P.RTime()>50)
P.Assignmarks(0)
else
P.Assignmarks(10)
______________ //statement 1
______________ //statement 2
Record + + ;
}
File.close();
}
IfthefunctionAllocateMarks()issupposedtoAllocateMarksfortherecords
in the file MARKS.DAT based on their value of the member TimeTaken.
Write C++ statements for the statement 1 and statement 2, where,
statement 1 is required to position the file write pointer to an appropriate
place in the file and statement 2 is to perform the write operation with the
modifiedrecord.
278
(b) Write afunction in C++ to print the count of the word is as an
independentwordinattextfileDIALOGUE.TXT. 2
For example, if the content of the file DIALOGUE. TXT is
This is his book. Is this book good?
Then the output of the program should be 2.
(c) GivenabinaryfileGAME.DAT,containingrecordsofthefollowingstructure
type 3
struct Game
{
char GameName [20];
char Participant [10] [30];
};
WriteafunctioninC++thatwouldreadcontentsfromthefileGAME.DAT
and creates a file named BASKET.DAT copying only those records from
GAME.DATwherethegamenameis“BasketBall”
5. (a) Differentiatebetweenprimarykeyandalternatekey. 2
(b) Consider the following tables. Write SQL commands for the statements
(i) to (iv) and give outputs for SQL queries (v) to (viii) 6
TABLE:SENDER
SenderlD SenderName SenderAddress SenderCiry
ND01 RJain 2,ABCAppts NewDelhi
MU02 HSinha 12, Newtown Mumbai
MU15 S Jha 27/A, Park Street Mumbai
ND50 T Prasad 122-K, SDA NewDelhi
TABLE : RECIPIENT
RecID SenderlD RecName RecAddress RecCiry
KO05 ND01 R Bajpayee 5, CentralAvenue Kolkata
ND08 MU02 S Mahajan 116,AVihar NewDelhi
MU19 ND01 HSingh 2A,AndheriEast Mumbai
MU32 MU15 P K Swamy B5, C STerminus Mumbai
ND48 ND50 STripathi 13, B1 D, Mayur Vihar NewDelhi
279
(i) TodisplaythenamesofallSendersfromMumbai
(ii) To display the RecID), SenderName, SenderAddress, RecName,
RecAddressforeveryRecipient
(iii) To displayRecipientdetailsinascendingorderofRecName
(iv) TodisplaynumberofRecipientsfromeachcity
(v) SELECT DISTINCT SenderCity FROM Sender;
(vi) SELECTA. SenderName, B.RecName
FROM SenderA, Recipient B
WHEREA. SenderlD = B.SenderlDAND B.RecCity = ‘Mumbai’;
(vii) SELECT RecName, RecAddress
FROMRecipient
WHERE RecCity NOT IN (‘Mumbai’, ‘Kolkata’);
(viii) SELECT RecID, RecName
FROMRecipient
WHERE SenderID=’MU02' ORSenderID=’ND50';
6. (a) StateDistributivelawandverifythesameusingtruthtable. 2
(b) WritetheequivalentCanonicalSumofProductexpressionforthefollowing
ProductofSumExpression 2
F(X,Y,Z) = π (1,3,6,7)
(c) WritetheequivalentBooleanExpressionforthefollowingLogicCircuit. 2
(d) ReducethefollowingBooleanexpressionusingK-Map 2
F(U,V,W,Z) = Σ (0, 1, 2, 3, 4, 10, 11)
7. (a) WhatisthesignificanceofCyberlaw? 1
(b) ExpandthefollowingtermswithrespecttoNetworking: 2
(i) CDMA (iii) FTP
(ii) WLL (iv) HTML
280
(c) Which of the following unit measures the speed with which data can be
transmitted from one node to another node of a network?Also, give the
expansionofthesuggestedunit. 1
(i) Mbps
(ii) KMph
(iii) MGps
(d) “BhartiyaConnectivityAssociation”isplanningtospreadtheirofficesinfour
majorcitiesinIndiatoprovideregionalITinfrastructuresupportinthefield
ofEducation&Culture.Thecompanyhasplannedtosetuptheirheadoffice
in New Delhi in three locations and have named their New Delhi offices as
“Front Office”, “Back Office” and “Work Office”.The company has three
more regional offices as “South Office”, “East Office” and “West Office”
located in other three major cities of India.Arough layout of the same is as
follows: 4
Approximatedistancesbetweentheseofficesaspernetworksurveyteamis
asfollows:
Place From Place To Distance
BackOffice FrontOffice 10KM
BackOffice WorkOffice 70 Meter
BackOffice EastOffice 1291 KM
BackOffice WestOffice 790 KM
BackOffice SouthOffice 1952 KM
281
Incontinuationoftheabove,thecompanyexpertshaveplannedtoinstallthe
followingnumberofcomputersineachoftheiroffices:
BackOffice 100
FrontOffice 20
WorkOffice 50
EastOffice 50
WestOffice 50
SouthOffice 50
(i) Suggestnetworktype(outofLAN,MAN,WAN)forconnectingeach
ofthefollowingsetoftheiroffices:
• Back Office and Work Office
• BackOfficeandSouthOffice
(ii) Which device you will suggest to be procured by the company for
connecting all the computers with in each of their offices out of the
followingdevices?
• Switch/Hub
• Modem
• Telephone
(iii) Whichofthefollowingcommunicationmedium,youwillsuggesttobe
procured by the company for connecting their local offices in New
Delhiforveryeffectiveandfastcommunication?
• TelephoneCable
• OpticalFiber
• EthernetCable
(iv) Suggestacable/wiringlayoutforconnectingthecompany’slocaloffices
located in New Delhi.Also, suggest an effective method/technology
for connecting the company’s regional offices-”East Office”, “West
Office”and“SouthOffice”withofficeslocatedinNewDelhi.
282
Marking Scheme — Computer Science
Important Note
The answers given in the marking scheme are SUGGESTIVE. Examiners are requested to
awardmarksforallalternativecorrectSolutions/Answersconveyingthesimilarmeaning
All programming questions have to be answered with respect to C++ Language only
InC++,ignorecasesensitivityforidentifiers(Variable/Functions/Structures/ClassNames)
InSQLrelatedquestions–bothwaysoftext/characterentriesshouldbeacceptableforExample:
“AMAR” and ‘amar’both are correct.
InSQLrelatedquestions–semicolonshouldbeignoredforterminatingtheSQLstatementsIn
SQLrelatedquestions,ignorecasesensitivity.
QUESTION PAPER CODE 91
EXPECTEDANSWERS/VALUE POINTS
1. (a) LogicalError:
Error occurred due to incorrect logic applied by the programmer.
SyntaxError:
Erroroccurredduetonotfollowingthepropergrammar/syntaxofthelanguage
OR
Erroroccurredduetoviolatingrulesoftheprogramminglanguage
Example:
//Program to find area and perimeter of rectangle
void main()
{
int A,B,AR,P;
A=10;
B=20;
AR=2*(A*B); //Logical Error – Wrong Formula
P=2*(A+B);
cout<<A<<P>>endl; //Syntax Error – Use of >> with cout
}
(½ Mark for each correct explanation of Logical Error and Syntax
Error)
(½ Mark for each correct example of Logical Error and Syntax Error)
OR
(Full 2 Marks for correct examples demonstrating the difference
between Logical Error and Syntax Error)
Note: Only 1 Mark to be awarded if Explanation is given without
supporting example.
283
(b) string.h
stdio.h
(½ Mark for identifying each correct header file)
Note: Marks are not to be deducted if any additional header file is
mentioned
(c) #include<iostream.h>
const int Size =5;
void main( )
{
int Array[Size]={50,40,30,20,10};
for(int Ctr=0;Ctr<Size;Ctr++)
cout<<Array[Ctr];
}
(½ Mark for each correction)
OR
(1 Mark for identifying at least three errors, without suggesting
correction)
(d) 2 @ 4 @ 8 @
4 # 8 # 16 # 20 #
(1 Mark for each correct line of output)
Note:
· ½ Mark to be deducted for missing symbols in each line of output
· ½ Mark to be deducted if endl is not considered in the output
· As Borland C++ Compiler declares for loop variable locally,
the program will result in syntax errors. So, any student
specifying Variable C not declared OR mentioning that the
program will not RUN due to incorrect syntax should be
awarded full 2 Marks
(e) 10, 15, 20, 25, 30,
10, 15, 20,
Number=30
(1 Mark for each correct line of output)
Note:
· ½ Mark to be deducted for missing Commas (,) in each line of
output
· ½ Mark to be deducted if endl is not considered in the output
284
(f) (ii) 34
(1 Mark for the correct answer)
(1 Mark for the correct justification)
2. (a) Base Class AccessSpecifier DerivedClass
Protected Private Private
Protected Protected
Public Protected
Private Private NotAccessible
Protected NotAccessible
Public NotAccessible
(1 mark each for correct explanation of Private and Protected
members)
Note: If the contents of the above table is explained correctly in any
format (with or without example) full 2 marks are to be awarded.
(b) (i) Function1:Constructor/DefaultConstructor
Function2:Destructor
(½ Marks for each correct answer)
(ii) Function 1 is executed or invoked automatically when an object of
class Science is created.
Function 2 is invoked automatically when the scope of an object of
class Science comes to an end.
OR
Example:
{
Science s1;//Constructor is invoked
} // the destructor is invoked
(½ Mark for each correct answer through explanation OR
example)
(c) class Travel
{
char TCode[5]; //OR char *Tcode;
int No_of_Adults;
int No_of_Children;
int Distance;
float TotalFare;
285
public:
Travel();
void AssignFare();
void EnterTravel();
void ShowTravel();
};
Travel::Travel()
{
strcpy(TCode,”NULL”);// OR TCode[0]=’0’ OR strcpy(TCode,”0”)
// OR TCode=NULL if TCode is declared as char pointer
No_of_Adults = 0;
No_of_Children = 0;
Distance = 0;
TotalFare = 0;
}
void Travel::AssignFare()
{
if(Distance>=1000)
TotalFare = 500*No_of_Adults+250*No_of_Children;
else
if (Distance >= 500)
TotalFare = 300*No_of_Adults+150*No_of_Children;
else
TotalFare = 200*No_of_Adults+100*No_of_Children;
}
void Travel::EnterTravel()
{
gets(TCode); // or cin >> TCode;
cin>>No_of_Adults>>No_of_Children>>Distance;
AssignFare();
}
void Travel::ShowTravel()
{
cout<<TCode<<No_of_Adults<<No_of_Children
<<Distance<<TotalFare<<endl;
}
(½ Mark for correct syntax of class header)
(½ Mark for correct declaration of data members)
(1 Mark for correct definition of constructor)
(1 Mark for checking all three conditions and calculating
TotalFare in AssignFare( ))
(½ Mark for correct EnterTravel( ) with proper invocation of
AssignFare( ))
(½ Mark for displaying all data Members including TotalFare
inside ShowTravel( ))
286
(d) (i) MultipleInheritance
(1 Mark for correct answer)
(ii) None
OR
Allthefunctionscanbecalled.
(1 Mark for any of the correct answer)
(iii) Data Members: SCode, SchName, Attendance, TotMarks,
Salary
Member Functions: SchDisplay(), SchEntry(), SEntry(),
SDisplay( ), TEntry( ), TDisplay( ), AssignSal( )
( 1 Mark for all correct members)
NOTE:
· Mention of Constructor functions School(), Student() and
Teacher() to be ignored.
· No marks to be awarded for partially correct answers
(iv) SchEntry( ),SchDisplay( ).
( 1 Mark for all correct member functions)
NOTE:
· Constructor function School() to be ignored.
· No marks to be awarded for partially correct answers
3. (a) void Display(int NUM[],int N)
{
for(int i=0;i<N;i=i+1)
{
if(NUM[i]%2==0)
NUM[i]=NUM[i]/2;
else
NUM[i]=2*NUM[i];
}
}
OR
void Display(int NUM[],int N)
{
for(int i=0;i<N;i=i+1)
NUM[i]=(NUM[i]%2!=0)?2*NUM[i]:NUM[i]/2;
}
(1 Mark for correct Function Header with proper Arguments)
(1 Mark for correct loop)
(1 Mark for checking Even / Odd values)
(1 Mark for replacing array elements with proper values)
287
(b) Assuming LBR=LBC=0
S=4 bytes
Number of Rows(N)=15
Number of Columns(M)=20
LOC(Arr[I][J]).= B +((I-LBR)*M+(J-LBC))*S
LOC(Arr[5][2]).= B +((5-0)*20+(2-0))*4
1500.= B +(100+2)*4
B.= 1500-408
B.= 1092
LOC(Arr[3][2].= 1092+((3-0)*20+(2-0))*4
..= 1092 + (62*4)
. .= 1092+248
.= 1340
OR
Assuming LBR=LBC=1
S=4 bytes
Number of Rows(N)=15
Number of Columns(M)=20
LOC(Arr[I][J]).= B +((I-LBR)*M+(J-LBC))*S
LOC(Arr[5][2]).= B +((5-1)*20+(2-1))*4
1500 .= B +(80+1)*4
B .= 1500-324
B .= 1176
LOC(Arr[3][2]).= 1176+((3-1)*20+(2-1))*4
. .= 1176 + (41*4)
.= 1176+164
.= 1340
(1 Mark for writing correct formula/correct substituted values, for
row major properly, for calculating Base Address)
(1 Mark for calculating correct Base Address)
(1 Mark for writing correct formula/correct substituted values, for
row major properly, for calculating Address of Arr[3][2])
(1 Mark for calculating correct Address of Arr[3][2])
(c) class QUEUE
{
Customer *Rear,*Front;
public:
QUEUE( ) { Rear=NULL; Front=NULL;}
void DELETE( );
~QUEUE( );
};
288
//Function definition DELETE()
void QUEUE::DELETE()
{
if(Front==NULL) // OR if(!Front)
cout<<”n Queue Underflown”;
else
{
Customer *Temp;
Temp=Front;
cout<<Front->Cno<<”:”<<Front->Cname
<<”Deleted”<<endl;//To be ignored
Front=Front->Link;
delete Temp;
if (Front==NULL)
Rear=NULL;
}
}
OR
voidDELETE(Customer*&Front,Customer*&Rear)
{
if(!Front)
cout<<”nQueueUnderflown”;
else
{
Customer*Temp;
Temp=Front;
cout<<Front->Cno<<”:”<<Front->Cname
<<”Deleted”<<endl;//Tobeignored
Front=Front->Link;
deleteTemp;
if(Front==NULL)
Rear=NULL;
}
}
Note: If Front and Rear are declared as Global variables then
parameters are not needed in the above function.
(½ Mark for correct function header)
(½ Mark for declaring Front and Rear as members OR passing them
as arguments OR declaring them as global variables)
(1 Mark for checking Underflow)
(1 Mark for updating Front)
(1 Mark for deleting node)
289
(d) //Function definition
void Display(int A[][100],int N)
{
cout<<”Middle Row:”<<endl;
for(int i=0;i<N;i=i+1)
cout<<A[N/2][i]<<” “;
cout<<endl;
cout<<”Middle Column:”<<endl;
for(i=0;i<N;i=i+1)
for(int i=0;i<N;i=i+1) – For Borland C++
cout<<A[i][N/2]<<” “;
}
OR
Anyothercorrectequivalentfunctiondefinition
(½ Mark for correct function header)
(½ Mark for correct loop)
(½ Mark for checking/printing middle row elements)
(½ Mark for checking/printing middle column elements)
(e) Evaluationofthegivenpostfixexpressionisexplainedbelow
Operator Scanned Stack Content
15 15
3 15, 3
2 15, 3, 2
+ 15, 5
/ 3
7 3, 7
+ 10
2 10, 2
* 20
OR
Anyothermethodofevaluatingthepostfixexpressionisshown.
(½ Mark for each operation correctly evaluated)
(Only 1 Mark is to be awarded if correct answer is given without
steps)
290
4. (a) Statement 1:
File.seekg(-1*sizeof(L),ios::cur);
OR
File.seekg(Rec*sizeof(L));
OR
File.seekp(-1*sizeof(L),ios::cur);
OR
File.seekp(Rec*sizeof(L));
OR
Any equivalent correct method of calculating size of the record in place of
sizeofoperator.
Statement 2:
File.write((char *) &L,sizeof(L));
OR
Any equivalent correct method of calculating size of the record in place of
sizeofoperator.
(½ Mark for each correct statement)
(b) //Function to count the word in STORY.TXT file
void thewordCount()
{
ifstream Fil(“STORY.TXT”);
char String[20];
int C=0;
while(!Fil.eof())
{
Fil>>String;
if(strcmpi(String,”the”)==0)
C=C+1;
}
cout<<C<<endl;
Fil.close();
}
OR
void thewordCount()
{
ifstream Fil(“STORY.TXT”);
char String[20];
int C=0;
while(!Fil.eof())
{
Fil>>String;
if(strcmp(String,”the”)==0 || strcmp(String,”The”)==0)
C=C+1;
291
}
cout<<C<<endl;
Fil.close();
}
OR
void thewordCount()
{
ifstream F(“STORY.TXT”);
char Str[4];
int C=0;
while(F.getline(Str,4,’ ‘))
{
if(strcmp(Str,”the”)==0 || strcmp(Str,”The”)==0)
C=C+1;
}
cout<<C<<endl;
F.close();
}
(½ Mark for opening file in the correct mode)
(½ Mark for reading the content from the file and the loop)
(½ Mark for correct comparison)
(½ Mark for initialization and increment of the counter(variable))
Note:
Ignore case sensitivity in the comparison with “the” or “The”
(c) //Function to copy records from SPORTS.DAT to
//ATHELETIC.DAT
void SP2AT()
{
fstream IS,OA;
Sports S;
IS.open(“SPORTS.DAT”,ios::binary|ios::in);
OA.open(“ATHLETIC.DAT”,ios::binary|ios::out);
while(IS.read((char*) &S,sizeof(S)))
{
if(strcmp(S.Event,”Athletics”)==0)
OA.write((char *)&S,sizeof(S));
}
IS.close();
OA.close();
}
292
OR
void SP2AT()
{
fstream F1,F2;
Sports S;
F1.open(“SPORTS.DAT”,ios::binary|ios::in);
F2.open(“ATHLETIC.DAT”,ios::binary|ios::out);
while(F1.read((char*) &S,sizeof(S)))
{
if(!strcmp(S.Event,”Athletics”))
F2.write((char *)&S,sizeof(S));
}
F1.close();
F2.close();
}
OR
void SP2AT()
{
fstream F1,F2;
Sports S;
F1.open(“SPORTS.DAT”,ios::binary|ios::in);
F2.open(“ATHLETIC.DAT”,ios::binary|ios::out);
while(!F1.eof())
{
F1.read((char*) &S,sizeof(S));
if(!strcmp(S.Event,”Athletics”))
F2.write((char *)&S,sizeof(S));
}
F1.close();
F2.close();
}
(½ Mark for opening each file in the correct mode)
(½ Mark for reading the content from the file)
(½ Mark for the correct loop)
(½ Mark for the correct comparison with “Athletics”)
(½ Mark for writing the content to the second file)
5. (a) The Primary Key is an attribute/set of attributes that identifies a tuple/ row/
recorduniquely.
Example:
RollnumberinthetableSTUDENT
OR
293
AccessionNumberinthetableLIBRARY
OR
EmpNumberinthetableEMPLOYEE
OR
PanNumber in the table INCOMETAX
OR
MemberNumberinthetableMEMBER
OR
AccNumber in the table BANK
OR
Anyothersuitableexample
(1 Mark for correct definition/explanation of Primary Key)
(1 Mark for suitable example)
(b) (i) SELECT CnorN ame FROM CONSIGNOR WHERE
City=’Mumbai’;
(½ Mark for correct use of SELECT and FROM)
(½ Mark for correct use of WHERE clause)
(ii) SELECT B.CneeID, A.CnorName, A.CnorAddress,
B.CneeName , B.CneeAddress
FROM Consignor A, Consignee B
WHERE A.CnorID=B.CnorID;
OR
SELECT Consigner.CneeID, CnorName, CnorAddress,
CneeName, neeAddress
FROM Consignor, Consignee
WHERE Consignor.CnorID= Consignee.CnorID;
(½ Mark for correct use of SELECT and FROM)
(½ Mark for correct use of WHERE clause)
(iii) SELECT * FROM CONSIGNEE ORDER BY CneeName;
(½ Mark for correct use of SELECT and FROM)
(½ Mark for correct use of ORDER BY clause)
(iv) SELECT City,Count(CnorID) FROM CONSIGNOR Group
By City;
OR
SELECT City,Count(*) FROM CONSIGNOR Group By
City;
(½ Mark for correct use of SELECT and FROM)
(½ Mark for correct use of GROUP BY clause)
294
(v) DISTINCT CneeCity
Mumbai
New Delhi
Kolkata
(½ Mark for correct output)
OR
(½ Mark for mentioning Error as CITY not present in the table
CONSIGNEE)
(vi) A.CnorName B.CneeName
R Singhal Rahul Kishore
Amit Kumar S Mittal
(½ Mark for correct output)
OR
(½ Mark for any 2 correct output out of (v),(vii)and (viii) even if
part (vi) not attempted)
(vii) CneeName CneeAddress
P Dhingra 16/J,Moore Enclave
B P Jain 13,Block D,A Vihar
(½ Mark for correct output)
(viii) CneeID CneeName
MU05 Rahul Kishore
KO19 A P Roy
(½ Mark for correct output)
Note: Column Headings for all Outputs may be ignored
6. (a) If X,Y∈B
(X+Y)’=X’.Y’
(X.Y)’=X’+Y’
X Y X’ Y’ X+Y (X+Y)’ X’.Y’
0 0 1 1 0 1 1
0 1 1 0 1 0 0
1 0 0 1 1 0 0
1 1 0 0 1 0 0
295
X Y X’ Y’ X.Y (X.Y)’ X’+Y’
0 0 1 1 0 1 1
0 1 1 0 0 1 1
1 0 0 1 0 1 1
1 1 0 0 1 0 0
(½ Mark for each form of DeMorgan’s Theorem)
(1 Mark for correct verification of any of the form of DeMorgan’s
Theorem using Truth Table)
(b) F(X, Y, Z) = π (1, 3, 6, 7)
OR
F=(X+Y+Z’)(X+Y’+Z’)(X’+Y’+Z)(X’+Y’+Z’)
(½ Mark for each term of POS)
(c) F=A.B’+C’.D
(2 Marks for the correct expression)
OR
(½ Mark for each term of the expression)
(d) A'.B' A'.B A.B A.B'
C'D' 1 1
0 4 12 8
C'.D 1
1 5 13 9
C.D 1 1
3 7 15 11
C.D' 1 1
2 6 14 10
F(A,B,C,D)= A’.B’+B’.C’+A’.C’.D’
OR
296
A + B A+B' A'+B' A'+B
C+D 0 0
0 4 12 8
C+D' 0 0 0
1 5 13 9
C'+D' 0 0 1
3 7 15 11
C'+D 0 0 1
2 6 14 10
F(A,B,C,D)=(A’+C).(B’+D’).(B’+C’)
(½ Mark for representing the terms in K-Map)
(½ Mark for obtaining each reduced term i.e. 1 ½ Marks for reducing
to the correct minimal form)
7. (a) Cyber law encompasses a wide variety of political and legal issues related
totheInternetandothercommunicationstechnology,includingintellectual
property,privacy,freedomofexpression,andjurisdiction.
OR
Restricting unauthorized access to user accounts. Promoting, coordinating
andcontrollinge-business.
(1 Mark for any correct definition/explanation)
(b) (i) XML eXtensible MarkUp Language
(ii) WWW WorldWideWeb
(iii) WLL Wireless in Local Loop
(iv) TCP/IP Transmission Control Protocol/Internet Protocol
(½ Mark for each correct expansion)
(c) (ii) Mbps
Mega bits per second
(½ Mark for correct identification)
(½ Mark for correct expansion)
(d) (i) · Head Office andTech Office: LAN
· Head Office and Coimbatore Office: WAN
(½ Mark for mention of each - LAN and WAN correctly)
(ii) · Switch/Hub
(1 Mark for the correct device)
(iii) · Opticalfiber
(1 Mark for the correct device)
297
(iv) Optical Fiber/StarTopology
Wireless
OR
OpticalFiber/BusTopology
Wireless
(½ Mark for the correct layout)
(½ Mark for the any equivalent correct technology)
QUESTION PAPER CODE 91/1
EXPECTEDANSWERS/VALUE POINTS
1. (a) RunTimeError:Erroroccurringinaprogramduringitsexecution.Program
executionhaltswhensuchanerrorisencountered.
Example:
int A,B,C;
cin>>A>>B;
C=A/B;//Runtime error if value of B is zero.
SyntaxError:Erroroccurredduetowrongsyntaxoflanguagedetectedby
thecompilerduringcompilation.
Example:
cout>>”A C++ Program”;
298
(½ Mark for each correct explanation of Runtime Error and Syntax
Error)
(½ Mark for each correct example of Runtime Error and Syntax Error)
OR
(Full 2 Marks for correct examples demonstrating the difference
between Runtime Error and Syntax Error)
OR
(Only 1 Mark to be awarded if Explanation with out supporting
examples)
(b) stdio.h
string.h
(½ Marks for identifying each correct header file)
Note: Ignore any other header files, if mentioned.
(c) #include<iostream.h>
const int Max = 10; //OR const int Max = 5;
void main()
{
int Numbers[Max]= {20,50,10,30,40};
// OR int Numbers[]= {20,50,10,30,40};
int Loc;
for(Loc=Max-1; Loc>=0; Loc—)
cout<<Numbers[Loc];
}
(½ Marks for each correction)
OR
(1 Mark for identifying at least three errors, without suggesting
correction)
(d) 4 # 6 # 10 #
12 @ 18 @ 30 @ 36 @
(1 Mark for each correct line of output)
Note:
· ½ Mark to be deducted for missing symbols in the output
· ½ Mark to be deducted if endl is not considered in the output
· As Borland C++ Compiler declares for loop variable locally,
the program will result in syntax errors. So, any student
specifying Variable I not declared OR mentioning that the
program will not RUN due to incorrect syntax should be
awarded full 2 Marks
299
(e) 20,25,30,
20,25,30,
Number=30
(1 Mark for each correct line of output)
Note:
· ½ Mark to be deducted for missing Commas (,) in the output
· ½ Mark to be deducted if endl is not considered in the output
(f) (ii) 94
(1 Mark for correct answer)
(1 Mark for correct justification)
2. (a) Constructors:
· Name of the constructor functions is same as the name of the class
· No return type required for constructor function.
· Constructorfunctionsarecalledautomaticallyatthetimeofcreationof
the object
· Constructors can be overloaded
· Constructorfunctionsaredefinedinpublic.
Destructors:
· Name of the destructor is same as the name of the class preceded by ~
· No return type required for destructor function.
· Destructor functions are called automatically when the scope of the
object gets over
· Destructor can not be overloaded
· Destructorfunctionisdefinedinpublic.
(1 Mark for correct explanation of Constructor)
(1 Mark for correct explanation of Destructor)
OR
(1 Mark for any valid example of a Constructor)
(1 Mark for any valid example of a Destructor)
(b) (i) Function1:ConstructorORDefaultConstructor
Function2:Destructor
(½ Marks for each correct answer)
(ii) Function 1 is executed or invoked automatically when an object of
class Maths is created.
Function 2 is invoked automatically when the scope of an object of
class Maths comes to an end.
300
OR
Example:
{
Maths s1; //Constructor is invoked
} //Destructor is invoked
(½ Mark for each correct answer through explanation OR
example)
NOTE: If the error in declaration of the destructor is specified
then marks for the destructor function should be allocated.
(c) class Tour
{
char TCode[10]; //OR char *Tcode;
int NoofAdults;
int NoofKids;
int Kilometres;
float TotalFare;
public:
Tour()
{
strcpy(TCode,”NULL”); //OR TCode[0]=’0’OR strcpy(TCode,”0”)
//OR TCode=NULL if TCode is declared as char pointer
NoofAdults = 0;
NoofKids = 0;
Kilometres = 0;
TotalFare = 0;
}
void AssignFare();
void EnterTour();
void ShowTour();
};
void Tour::AssignFare()
{
if(Kilometres>=1000)
TotalFare = 500*NoofAdults+250*NoofKids;
else if (Kilometres >= 500)
TotalFare = 300*NoofAdults+150*NoofKids;
else
TotalFare = 200*NoofAdults+100*NoofKids;
}
void Tour::EnterTour()
{
gets(TCode); // or cin >> TCode;
cin>>NoofAdults>>NoofKids>>Kilometres;
AssignFare( );
301
}
void Tour::ShowTour()
{
cout<<TCode<<NoofAdults<<NoofKids<<Kilometres<<TotalFare<<endl;
}
(½ Mark for correct syntax for class header)
(½ Mark for correct declaration of data members)
(1 Mark for correct definition of constructor)
(½ Mark for condition checking in AssigFare())
(½ Mark for calculation of correct TotalFare for each condition)
(½ Mark for correct EnterTour() with proper invocation of
AssignFare())
(½ Mark for displaying all data Members including TotalFare inside
ShowTour())
(d) (i) MultipleInheritance
(1 Mark for correct answer)
(ii) None
OR
Alltheabovefunctionscanbecalled.
(1 Mark for correct answer)
(iii) Data Members: ICode, IName, Attendance, Grade,
Remuneration
Member Functions: IEntry( ), IDisplay( ), LEntry(),
LDisplay( ),
AssignRem( ), TEntry( ), TDisplay( )
(1 Mark for correct members)
Note:
· Constructor functions Trainer(), Learner() and Institute()
to be ignored.
· No marks to be awarded for partially correct answers
(iv) IEntry( ), IDisplay( )
(1 Mark for correct answer)
NOTE:
· Constructor function Institute() to be ignored.
· No marks to be awarded for partially correct answers
302
3. (a) void Replace( int Arr[], int Size)
{
for(int i =0; i<Size; i++)
if(Arr[i]%2 != 0 )
Arr[i] *= 3;
else
Arr[i] *= 2;
}
OR
void Replace( int Arr[], int Size)
{
for(int i =0; i<Size; i++)
Arr[i]%2 ? Arr[i] *= 2 : Arr[i] *= 3;
}
(1 Mark for correct Function Header with proper Arguments)
(1 Mark for correct loop)
(1 Mark for checking Even / Odd values)
(1 Mark for replacing with proper values)
(b) AddressofArray[i][j]alongthecolumn=
Base Address + W [( i – L1) + (j – L2) * M]
where,
W = size of each location in bytes = 8
L1 = Lower Bound of rows = 0
L2 = Lower Bound of columns = 0
M = Number of rows per column = 20
Address ofArray[4][5] = Base Address + 8 [ (4 – 0) +(5 – 0) * 20]
1000 = Base Address + 8 [104]
BaseAddress = 1000 – 8 x 104
= 1000 – 832
= 168
Address ofArray[2][3] = 168 + 8 [ (2 – 0) + (3 – 0) x 20]
= 168 + 8 x 62
= 168 + 496
= 664
OR
303
AddressofArray[i][j]alongthecolumn=
Base Address + W [( i – L1) + (j – L2) * M]
where,
W = size of each location in bytes = 8
L1 = Lower Bound of rows = 1
L2 = Lower Bound of columns = 1
M = Number of rows per column = 20
Address ofArray[4][5] = Base Address + 8 [ (4 – 1) +(5 –1) * 20]
1000 = Base Address + 8 [83]
BaseAddress = 1000 – 8 x 83
= 1000 – 664
= 336
Address ofArray[2][3] = 336 + 8 [ (2 – 1) + (3 – 1) x 20]
= 168 + 8 x 41
= 168 + 328
= 496
(1 Mark for writing correct formula/ correct substituted values for
calculating Base Address)
(1 Mark for calculating correct Base Address)
(1 Mark for writing correct formula/ correct substituted values for
calculating Address of Arr[3][2])
(1 Mark for calculating correct Address of Arr[3][2])
(c) class Stack
{
Book *Top;
public:
Book() //Constructor to initialize Top
{ Top = NULL; }
void Push(); //Function to insert a node
void Pop(); //Function to delete a node
void Display(); //Function to display nodes of Stack
~Book(); //Destructor to delete all nodes
};
void Stack::Pop( )
{
if (Top != NULL)
{
Stack *Temp;
Temp = Top;
304
//Ignore the following line while evaluation
cout<<Top->Bno<<Top->Bname<<”deleted”<<endl;
Top = Top ->Next;
delete Temp;
}
else
cout<<”Stack Empty”;
}
OR
void Pop(Book *&Top)
{
if(Top!=NULL)
{
Book *Temp = Top;
Top = Top ->Next;
delete Temp;
}
else
cout<<”Stack Empty”;
}
(½ Mark for declaring Top as member / passing Top to argument/
declaring it as a global variable)
(½ Mark for correct function header)
(1 Mark for checking Underflow)
(1 Mark for reassigning Top)
(1 Mark for deleting node)
(d) void Diagonals(int Arr[][100], int Size)
{
int Row, Col;
cout<<”Diagonal One: “;
for (Row = 0; Row < Size; Row++)
for (Col = 0; Col < Size; Col++)
if (Row == Col)
cout<<Arr[Row][Col];
cout<<”Diagonal Two: “;
for (Row = 0; Row < Size; Row++)
for (Col = 0; Col < Size; Col++)
if (Row + Col == Size - 1)
cout<<Arr[Row][Col];
}
305
OR
void Diagonals(int Arr[][100], int Size)
{
int Loc;
cout<<”Diagonal One: “;
for (Loc = 0; Loc < Size; Loc++)
cout<<Arr[Loc][Loc];
cout<<”Diagonal Two: “;
for (Loc = 0; Loc < Size; Loc++)
cout<<Arr[Loc][Size-Loc-1];
}
OR
Anyothercorrectequivalentfunctiondefinition
(½ Marks for correct function header)
(½ Marks for correct loop(s))
(½ Marks for checking/printing right diagonal elements)
(½ Marks for checking/printing left diagonal elements)
(e) Operator Scanned Stack Content
25 25
8 25, 8
3 25, 8, 3
- 25, 5
/ 5
6 5, 6
* 30
10 30, 10
+ 40
OR
Anyothermethodofcorrectlyevaluatingthepostfixexpressionisshown.
(2 Marks is to be given for correct answer)
OR
(½ Mark for each operation correctly evaluated)
306
4. (a) Statement1:
File.seekp(Record * sizeof(P));
OR
File.seekp(Record * sizeof(PracFile));
OR
File.seekp(-sizeof(P), ios::cur);
OR
File.seekg(Record * sizeof(P));
OR
File.seekg(Record * sizeof(PracFile));
OR
File.seekg(-sizeof(P), ios::cur);
OR
Any equivalent correct method of calculating size of the record in place of
sizeofoperator.
Statement2:
File.write((char*)&P, sizeof(P));
OR
File.write((char*)&P, sizeof(PracFile));
OR
Any equivalent correct method of calculating size of the record in place of
sizeofoperator.
(½ Mark for each correct statement)
(b) void CountIs()
{
ifstream Fil;
Fil.open(“DIALOGUE.TXT”);
char Word[10];
int Count =0;
while(!Fil.eof())
{
Fil>>Word;
if(strcmpi(Word,”is”)==0)
Count++;
}
cout<<Count;
Fil.close(); //Ignore
}
307
OR
void CountIs()
{
ifstream Fil;
Fil.open(“DIALOGUE.TXT”);
char Word[10];
int Count = 0;
while(Fil.getline(Word,10,’ ‘))
{
if(strcmpi(Word,”is”)==0)
Count++;
}
cout<<Count;
Fil.close(); //ignore
}
OR
void CountIs()
{
ifstream Fil;
Fil.open(“DIALOGUE.TXT”);
char ch, Word[10];
int Loc=0, Count = 0;
while(Fil.get(ch))
{
if(ch!=’ ‘)
{
Word[Loc] = ch;
Loc++;
}
else
{
Word[Loc] = ‘0’;
Loc = 0;
if(strcmpi(Word,”is”)==0)
Count++;
}
}
cout<<Count;
Fil.close(); //ignore
}
OR
Anyothercorrectdefinition
(½ Marks for opening DIALOGUE.TXT correctly)
(½ Marks for reading each word from the file)
(½ Marks for comparing with “is” / “Is” )
(½ Marks for printing the count of “is” / “Is”)
308
(c) void CopyBasket()
{
Game G;
ifstream fin;
fin.open(“GAME.DAT”, ios::binary);
ofstream fout;
fout.open(“BASKET.DAT”, ios::binary);
while(fin.read((char*)&G, sizeof(G)))
{
if(strcmp(G.GameName, “Basket Ball”)==0)
fout.write((char*)&G,sizeof(G));
}
fin.close(); //ignore
fout.close(); //ignore
}
(½ Marks for opening GAME.DAT correctly)
(½ Marks for opening BASKET.DAT correctly)
(½ Marks for reading each record from GAME.DAT)
(½ Marks for correct loop / checking end of file)
(½ Marks for comparing GameName with “Basket Ball”)
(½ Marks for writing the record to BASKET.DAT)
5. (a) Allcandidatekeys,whichare notthe primarykeyofthe table are calledthe
alternatekeys.
OR
Primary Key:An attribute/ column used to identify each record in a table
AlternateKey:Allsuchattributes/columns,whichcanactasaprimarykey
but are not the primary key in a table.
(2 Mark for any valid difference/relation between Primary Key and
Alternate Key)
OR
(1 Mark for correct explanation of Primary Key)
(1 Mark for correct explanation of Alternate Key)
(b) (i) SELECT SenderName from Sender WHERE City =
‘Mumbai’;
(ii) SELECT R.RecID, S.SenderName, S.SenderAddress,
R.RecName, R.RecAddress FROM Sender S,
Recipient R
WHERE S.SenderID = R.SenderID;
(iii) SELECT * FROM Recipient ORDER BY RecName;
(iv) SELECT COUNT(*) FROM Recipient GROUP BY RecCity
309
(v) SenderCity
Mumbai
New Delhi
(vi) A.SenderName B.RecName
R Jain H Singh
S Jha P K Swamy
(vii) RecName RecAddress
S Mahajan 116, A Vihar
S Tripathi 13, Bl D, Mayur Vihar
(viii) RecID RecName
ND08 S Mahajan
ND48 STripathi
(Part (i) to (iv) - 1 Mark for each correct query)
(Part (v) to (viii) - ½ Marks for each correct output)
Note:
· Column headings for the output questions to be ignored.
· Since in part (iv) the fieldname RecCity is not mentioned
specifically, so full 1 mark to be given if any part of 5 (b) is
answered correctly.
6. (a) If X,Y,Z are BooleanVariables then
X . ( Y + Z ) = X . Y + X . Z
OR
X + Y . Z = (X + Y) . (X + Z)
X Y Z Y+Z X.(Y+Z) X.Y X.Z X.Y+X.Z
0 0 0 0 0 0 0 0
0 0 1 1 0 0 0 0
0 1 0 1 0 0 0 0
0 1 1 1 0 0 0 0
1 0 0 0 0 0 0 0
1 0 1 1 1 0 1 1
1 1 0 1 1 1 0 1
1 1 1 1 1 1 1 1
VERIFIED
(1 Mark for stating any one of the Distributive Law correctly)
(1 Mark for verification using Truth Table)
310
(b) F(X,Y,Z) = π(0,2,4,5)
= X’.Y’.Z’ + X’.Y.Z’ + X.Y’.Z’ + X.Y’.Z
(2 Marks for correct expression)
OR
(1 Mark, if a reduced non-canonical SOP expression is given)
(c)
F = W.X’ + Y’.Z
(2 Marks for correct expression)
OR
( ½ Mark each for W.X’ and Y’.Z)
(d) U'V' U'V UV UV'
W'Z' 1 1
0 4 12 8
W'Z 1
1 5 13 9
WZ 1 1
3 7 15 11
WZ' 1 1
2 6 14 10
F = U'.V'+W.V'+U'.W'.Z'
(½ Mark for drawing correct K-Map )
(½ Mark for plotting 1’s correctly)
(½ Mark for correct grouping)
(½ Mark for correct Answer)
7. (a) Cyberlawencompassesawidevarietyofpoliticalandlegalissuesrelatedto
the Internet and other communications technology, including intellectual
property,privacy,freedomofexpression,andjurisdiction.
OR
CyberlawhelpspreventCyberCrime,Hacking,Datatheft,SoftwarePiracy
and protects rights of Cyber Users.
(1 Mark for any correct significance / explanation)
W.X’
Y'.Z
W.X’+Y'.Z
311
(b) (i) CodeDivisionMultipleAccess
(ii) WirelessLocalLoop
(iii) FileTransferProtocol
(iv) HyperTextMarkupLanguage
(½ Marks for each correct expansion)
(c) (i) Mbps (Mega Bits Per Second)
(½ Marks for correct choice)
(½ Marks for correct expansion)
(d) (i) Back Office and Work Office – LAN
Back Office and South Office –WAN
(½ Mark for each correct answer)
(ii) Switch/Hub
(1 Mark for correct answer)
(iii) OpticalFiber
(1 Mark for correct answer)
(iv)
OR
Anyothersuitablelayout/topologydrawnorexplained.
Optical Fiber/StarTopology
OR
OpticalFiber/BusTopology
OR
Wireless
(½ Mark for the correct layout)
(½ Mark for the any equivalent correct technology)
308
COMPUTER SCIENCE
Time allowed : 3 hours Maximum Marks : 70
General Instructions:
(i) All questions are compulsory.
(ii) Programming Language: C+ +
QUESTION PAPER CODE 91/1
1. (a) Whatisthedifferencebetween#defineandconst?Explainwithsuitable 2
example.
(b) Name the header files that shall be needed for the following code 1
voidmain()
{
char String [ ] = “Peace”;
cout<<setw (20) << String;
}
(c) Rewritethefollowingprogramafterremovingthesyntacticalerror(s)if
any.Underlineeachcorrection. 2
#include<iostream.h>
voidmain()
{
First = 10, Second = 20;
Jumpto (First; Second);
Jumpto (Second);
}
void Jumpto (int N1, int N2=20)
{
N1 = N1 + N2;
cout<<N1>>N2;
}
(d) Findtheoutputofthefollowingprogram: 3
#include<iostream.h>
#include<ctype.h>
309
voidmain()
{
char Text [ ] = “Mind@Work!”;
for (int I = 0; Text (I)! = ‘0’; 1++)
{
if(!isalpha(Text[I]))
Text [I] = ‘*’;
elseif(isupper(Text[I]))
Text [I] = Text [I] + 1 ;
else
Text (I) = Text [I+ 1];
}
cout<<Text;
}
(e) Findtheoutputofthefollowingprogram: 2
#include<iostream.h>
voidmain()
{
int U = 10, V = 20;
for (int I = 1; 1 < = 2; 1++)
{
cout<<“[1]=”<<U++<<“&”<<V–5<<endl;
cout<<“[2]=”<<++V<<“&”< <U+ 2< <endl;
}
}
(f) Inthefollowingprogram,findthecorrectpossibleoutput(s)fromtheoptions: 2
#include<stdlib.h>
#include<iostream.h>
voidmain()
{
randomize ( ) ;
char City [ ] [10] = {“DEL”, “CHN”, “KOL”, “BOM”, “BNG”};
intFly;
for (int I=0;I<3;I++)
{
Fly=random (2)+ 1;
cout<<City[Fly]<<”:”;
310
}
}
outputs:
(i) DEL:CHN:KOL:
(ii) CHN:KOL:CHN:
(iii) KOL:BOM:BNG:
(iv) KOL:CHN:KOL:
2. (a) Differentiate between public and private visibility modes in context of
ObjectOrientedProgrammingusingasuitableexampleillustratingeach. 2
(b) Answer the questions (i) and (ii) after going through the following
program 2
#include<iostream.h>
#include<string.h>
classBazar
{
charType[20];
char Product[20];
intQty;
floatPrice;
Bazar ( ) //Function 1
{
strcpy(Type,“Electronic”);
strcpy(Product,“Calculator”);
Qty=10;
Price=225;
}
public:
void Disp ( ) / / Function 2
{
cout<<Type<<“-”<<Product<<“:”<<Qty
<<“@”<<Price<<endl;
}
};
voidmain()
{
BazarB; / /Statement 1
311
B. Disp ( ); / / Statement 2
}
(i) Will Statement 1 initialize all the data members for object B with the
values given in the Function I? (Yes OR No). Justify your answer
suggesting the correction(s) to be made in the above code.
(ii) What shall be the possible output when the program gets executed?
(Assuming, if required - the suggested correction(s) are made in the
program)
(c) DefineaclassGarmentsinC++withthefollowingdescriptions: 4
PrivateMembers:
GCode oftypestring
GType oftypestring
GSize oftypeinteger
GFabric oftypestring
GPrice oftypefloat
Afunction Assign ( ) which calculates and assigns the value of GPrice as
follows
For the value of GFabric as “COTTON”,
GType GPrice(Rs)
TROUSER 1300
SHIRT 1100
For GFabric other than “COTTON” the above mentioned
GPrice gets reduced by 10%.
PublicMembers:
Aconstructor to assign initial values of GCode, GType and GFabric
with the word “NOTALLOTTED” and GSize and GPrice with 0
A function Input ( ) to input the values of the data members GCode,
GType, GSize and GFabric and invoke theAssign ( ) function.
AfunctionDisplay()whichdisplaysthecontentofallthedatamembers
for a Garment.
(d) Answer the questions (i) to (iv) based on the following code: 4
classDolls
{
char DCode[5] ;
protected:
floatPrice;
312
voidCalcPrice(float);
public:
Dolls();
void DInput ( ) ;
void DShow ( ) ;
} ;
classSoftDolls:publicDolls
{
char SDName[20] ;
floatWeight;
public:
SoftDolls ( ) ;
void SDInput ( ) ;
void SDShow ( ) ;
} ;
classElectronicDolls:publicDolls
{
char EDName[20] ;
charBatteryType[10];
intBatteries;
public:
ElectronicDolls();
void EDInput ( ) ;
void EDShow ( ) ;
} ;
(i) WhichtypeofInheritanceisshownintheaboveexample?
(ii) How many bytes will be required by an object of the class
ElectronicDolls?.
(iii) Writenameofallthedatamembersaccessiblefrommemberfunctions
oftheclassSoftDolls
(iv) Write name of all the member functions accessible by an object of the
classElectronicDolls.
3. (a) Write a function in C++, which accepts an integer array and its size as
parameters and rearranges the array in reverse. Example: if an array of nine
elementsinitiallycontainstheelementsas
4, 2, 5, 1, 6, 7, 8, 12, 10
313
thenthefunctionshouldrearrangethearrayas
10, 12, 8, 7, 6, 1, 5, 2, 4 4
(b) An arrayArr[40][10] is stored in the memory along the column with each
element occupying 4 bytes. Find out the address of the locationArr[3][6]
if the locationArr[30][10] is stored at the address 9000 4
(c) Write a function in c++ to Insert an element into a dynamically allocated
Queue where each node contains a name (of type string) as data. 4
AssumethefollowingdefinitionofTHENODEforthesame.
structTHENODE
{
char Name[20] ;
THENODE*Link;
} ;
(d) Write a function in C++ to print the product of each column of a two
dimensionalintegerarraypassedastheargumentofthefunction. 2
Explain:ifthetwodimensionalarraycontains
Then the output should appear as :
Product of Column 1 = 24
Product of Column 2 = 30
Product of Column 3 = 240
(e) Evaluatethefollowingpostfixnotationofexpression(ShowstatusofStack
after execution of each operation) : 2
4, 10, 5, +, *, 15, 3, /, –
4. (a) Observetheprogramsegmentgivenbelowcarefully,andanswerthequestion
thatfollows: 1
classApplicant
{
longAId; //Applicant’sId
314
char Name [20] ; //Applicant’sName
floatScore; //Applicant’sScore
public:
voidEnroll();
void Disp ( ) ;
void MarksScore ( ); / /Function to change Score
longR_AId(){retumAId;)
} ;
void ScoreUpdate (long Id)
{
fstreamFile;
File.open(“APPLI.DAT”,ios::binary|ios::in|ios::out);
ApplicantA;
int Record = 0, Found = 0 ;
while (!Found && File.read((char*) &C, sizeof(c)))
{
if(Id ==A.R_AId ( ))
{
cout<<”Enter new Score” ;
A.MarksScore ( );
______________ / / Statement 1
______________ / /Statement 2
Found = 1;
}
Record ++;
}
if (Found ==1) cout<<”Record Updated”;
File.close ( ) ;
}
WritetheStatement1toposition theFilePointeratthebeginningoftheRecordfor
which the Applicant’s ld matches with the argument passed, and Statement2 to
write the updated Record at that position.
(b) Write a function in C++ to count the number of lowercase alphabets
present in a text file “BOOK.TXT”. 2
(c) GivenabinaryfilePHONE.DAT,containingrecordsofthefollowing
structuretype 3
315
classPhonlist
{
char Name [20] ;
charAddress[30];
charAreaCode[5];
char PhoneNo[15] ;
public:
void Register () ;
Void Show ( ) ;
int CheckCode (charAC [ ])
{
return strcmp (AreaCode,AC) ;
}
} ;
Write a functionTRANSFER ( ) in C++, that would copy all those records which
are havingAreaCode as “DEL” from PHONE.DATto PHONBACK.DAT.
5. (a) DifferentiatebetweenCandidateKeyandPrimaryKey incontextofRDBMS 2
(b) Consider the following tables Product and Client.Write SQLcommands for the
statement (i) to (iv) and give outputs for SQL queries (v) to (viii) 6
TABLE: PRODUCT
TABLE:CLIENT
316
(i) TodisplaythedetailsofthoseClientswhoseCityisDelhi
(ii) To display the details of Products whose Price is in the range of 50
to 100 (Both values included)
(iii) To display the ClientName, City from table Client, and ProductName
andPricefromtableProduct,withtheircorrespondingmatchingP_ID
(iv) To increase the Price of all Products by 10
(v) SELECTDISTINCTAddress FROM Client;
(vi) SELECTManufacturer,MAX(Price),Min(Price),Count(*)
FROM Product GROUP BY Manufacturer;
(vii) SELECTClientName,ManufacturerName
FROM Product, Client
WHEREClient.Prod_ld=Product.P_ld;
(viii) SELECT ProductName, Price *4
FROM Product
6. (a) State and verify De Morgan’s law in BooleanAlgebra 2
(b) DrawaLogicalCircuitDiagramforthefollowingBooleanExpression
X’. (Y’ + Z) 1
(c) ConvertthefollowingBooleanexpressionintoitsequivalentCanonical
Sum of Product Form(SOP)
(X’+ Y + Z’) . (X’+ Y + Z) . (X’+ Y’+ Z) . (X’+ Y’+ Z’) 2
(d) Reduce the following Boolean expression using K - Map
F (A,B,C,D) = ∑(0,2,3,4,6,7,8,10,12) 3
7. (a) What is a Hub? 1
(b) ExpandthefollowingtermswithrespecttoNetworking: 2
(i) MODEM
(ii) WLL
(iii) FTP
(iv) TCP/IP
(c) HowisCoaxialcabledifferentfromOpticalFibre? 1
(d) “Bias Methodologies” is planning to expand their network in India, starting
withthreecitiesinIndiatobuildinfrastructureforresearchanddevelopment
317
of their chemical products. The company has planned to setup their main
officeinPondicherry-atthreedifferentlocationsandhavenamedtheiroffices
as “Back Office”, “Research Lab” and “Development Unit”. The company
has one more Research office namely “Corporate Office” in “Mumbai”.A
roughlayoutofthesameisasfollows: 4
Approximatedistancesbetweentheseofficesisasfollows:
Incontinuationoftheabove,thecompanyexpertshaveplannedtoinstallthe
followingnumberofcomputersineachoftheiroffices:
(i) Suggestthekindofnetworkrequired(outofLAN,MAN,WAN)
forconnectingeachofthefollowingofficeunits:
Research Lab and Back Office
Research Lab and Development Unit
(ii) Whichoneofthefollowingdevicewillyousuggestforconnecting
allthecomputerswithineachoftheirofficeunits?
318
Switch/Hub
Modem
Telephone
(iii) Whichofthefollowingcommunicationmedium,youwillsuggest
to be procured by the company for connecting their local office
units in Pondicherry for very effective (High Speed)
communication?
Telephone Cable
Optical Fiber
Ethernet Cable
(iv) Suggestacable/wiringlayoutforconnectingthecompany’slocal
office units located in Pondicherry.Also, suggest an effective
method/technology for connecting the company’s office unit
locatedinMumbai.
QUESTION PAPER CODE 91
1. (a) What is the purpose of using a typedef command in C++. Explain with
suitableexample. 2
(b) Name the header files that shall be needed for the following code: 1
voidmain()
{
char Word [ ] =”Exam”;
cout<<setw(20)<<Word;
}
(c) Rewritethefollowingprogramafterremovingthesyntaxerror(s),ifany.
Underlineeachcorrection. 2
#include<iostream.h>
voidmain()
{
One = 10, Two = 20;
Callme(One;Two);
Callme(Two);
}
voidCallme(intArg1,intArg2=20)
{
319
Arg1 =Arg1 +Arg2;
cout<<Arg1>>Arg2;
}
(d) Findtheoutputofthefollowingprogram: 3
#include<iostream.h>
#include<ctype.h>
voidmain()
{
charMystring[]=“What@OUTPUT!”;
for(int I = 0; Mystring [I] ! =’ 0'; I++)
{
if(!isalpha(Mystring[I]))
Mystring [I] = ‘*’;
elseif(isupper(Mystring[I]))
Mystring[I]=Mystring[I]+1;
else
Mystring[I]=Mystring[I+1];
}
cout<<Mystring;
}
(e) Findtheoutputofthefollowingprogram: 2
#include<iostream.h>
voidmain()
{
intA=5, B=10;
for (int I = 1; I<=2; 1++)
{
cout<<“Linel=”<<A++<<“&”<<B–2<<endl;
cout<<“Line2=”<<++B<<“&”<<A+3<<endl;
}
}
(f) Inthefollowingprogram,findthecorrectpossibleoutput(s)fromtheoptions: 2
#include<stdlib.h>
#include<iostream.h>
voidmain()
{
320
randomize();
charArea [] [10] = {‘‘NORTH”, ‘‘SOUTH”, “EAST”, “WEST”} ;
intToGo;
for (int I=0; 1<3; 1++)
{
ToGo = random(2) +1;
cout<<Area [ToGo]<<” : “;
}
}
outputs:
(i) SOUTH:EAST:SOUTH:
(ii) NORTH:SOUTH:EAST:
(iii) SOUTH:EAST:WEST:
(iv) SOUTH:EAST:EAST:
2. (a) Differentiatebetweenprivateand protectedvisibilitymodesincontextof
ObjectOrientedProgramminggivingasuitableexampleillustratingeach. 2
(b) Answerthequestions(i)and(ii)aftergoingthroughthefollowingprogram: 2
#include<iostream.h>
#include<string.h>
classRetail
{
char Category [20];
char Item [20];
intQty;
floatPrice;
Retail() //Function1
{
strcpy (Category, “Cereal”);
strcpy(Item,“Rice”);
Qty = 100;
Price = 25;
public:
void Show ( ) //Function2
{
cout<<Category<<“–”<<Item<<“:”<<Qty
321
<<“@”<<Price<<endl;
}
};
voidmain()
{
RetailR; //Function1
R. Show ( ) ;. //Function2
}
(i) Will Statement 1 initialize all the data members for object R with the
values given in the Function 1 ? (Yes OR No). Justify your answer
suggesting the correction(s) to be made in the above code.
(ii) What shall be the possible output when the program gets executed?
(Assuming, if required - the suggested correction(s) are made in the
program)
(c) DefineaclassClothinginC++withthefollowingdescriptions: 4
PrivateMembers:
Code oftypestring
Type oftypestring
Size oftypeinteger
Material oftypestring
Price oftypefloat
AfunctionCalc_Price()whichcalculatesandassignsthevalueofPrice
asfollows:
For the value of Material as “COTTON” :
Type Price (Rs.)
TROUSER 1500
SHIRT 1200
ForMaterialotherthan“COTTON”theabovementionedPrice
gets reduced by 25%.
PublicMembers:
Aconstructor to assign initial values of Code, Type and Material with the
word “NOTASSIGNED” and Size and Price with 0.
Afunction Enter( ) to input the values of the data members Code,Type, Size
and Material and invoke the CalcPrice( ) function.
A function Show( ) which displays the content of all the data members for a
Clothing.
322
(d) Answer the questions (i) to (iv) based on the following code: 4
classToys
{
char TCode [5] ;
protected:
floatPrice;
voidAssign(float);
public:
Toys( ) ;
void TEntry ( ) ; ,
voidTDisplay();
} ;
classSoftTOYS:publicToys
{
char STName [ 20] ;
floatweight;
public:
SoftToys( ) ;
void STEntry ( ) ;
voidSTDisplay();
} ;
classElectronicToys:publicToys
{
char ETName[20];
intNo_of_Batteries;
public:
ElectronicToys();
void ETEntry ( ) ;
voidETDisplay();
} ;
(i) WhichtypeofInheritanceisshownintheaboveexample?
(ii) How many bytes will be required by an object of the class SoftToys ?
(iii) Writenameofallthedatamembersaccessiblefrommemberfunctions
of the class SoftToys.
(iv) Writenameofallthememberfunctions,whichareaccessiblefroman
object of the class ElectronicToys.
323
3. (a) WriteafunctioninC++,whichacceptsanintegerarrayand its size as arguments
andswapstheelementsofeveryevenlocationwithitsfollowingoddlocation. 4
Example:ifanarrayofnineelementsinitiallycontainstheelementsas
2, 4, 1, 6, 5, 7, 9, 23, 10
thenthefunctionshouldrearrangethearrayas
4, 2, 6, 1, 7, 5, 23, 9, 10
(b) An arrayArr[50] [100] is stored in the memory along the row with each element
occupying2bytes.FindouttheaddressofthelocationArr[20][50],ifthelocation
Arr[10] [25] is stored at the address 10000. 4
(c) WriteafunctioninC++toDeleteanelementfromadynamicallyallocatedQueue
where each node contains a real number as data.
AssumethefollowingdefinitionofMYNODEforthesame.
struct MYNODE 4
{
floatNUM;
MYNODE*Link;
} ;
(d) Write a function in C++ to print the product of each row of a two dimensional
integer array passed as the argument of the function. 2
Example:ifthetwodimensionalarraycontains
Then the output should appear as :
Product of Row 1= 8000
Product of Row 2= 6000
Product of Row 3= 3600
Product of Row 4= 2400
(e) Evaluatethefollowingpostfixnotationofexpression(ShowstatusofStack
after execution of each operation) : 2
5, 20, 15, –, *, 25, 2, *, +
324
4. (a) Observetheprogramsegmentgivenbelowcarefully,andanswerthequestion
thatfollows:
class Candidate
{
longCld; / /Candidate’ s Id
char CName [20]; / /Candidate’s Name
floatMarks; / /Candidate’s Marks
public:
void Enter ( ) ;
void Display ( ) ;
void MarksChange( ) ; / /Function to change marks
lond R_Cid( ) {return Cld; )
};
void MarksUpdate (long Id)
{
fstreamFile;
File.open(“CANDIDAT.DAT”,ios::binary|ios::in|ios::out);
Candidate C;
int Record=0, Found=0;
while (! Found && File.read ( (char*) &C, sizeof (C) ) )
{
if (Id= =C. R_Cld ( ) )
{
cout<<”EnternewMarks”;
C.MarksChange( ) ;
_______________ / /Statement 1
_______________ / /Statement 2
Found = 1;
}
Record++;
}
if (Found = 1) cout<<”Record Updated”;
File.close ( ) ;
}
WritetheStatement1topositiontheFilePointeratthebeginningoftheRecord
forwhichtheCandidate’sIdmatcheswiththeargumentpassed,andStatement
2 to write the updated Record at that position. 1
325
(b) Write a function in C++ to count the number of uppercase alphabets present
inatextfile“ARTICLE.TXT”. 2
(c) Given a binary file TELEPHON.DAT, containing records of the following
classDirectory:
classDirectory
{
char Name[20] ;
charAddress [30] ;
charAreaCode[5];
char Phone_No[15];
public:
void Register ( ) ;
void Show ( ) ;
int CheckCode(charAC[ ])
{
return strcmp (AreaCode,AC);
}
};
Write a function COPYABC( ) in C++, that would copy only those records
havingAreaCode as “123” fromTELEPHON.DATtoTELEBACK.DAT. 3
5. (a) Differentiate between Candidate Key and Alternate Key in context of
RDBMS. 2
(b) Consider the following tables Item and Customer.WriteSQLcommands
for the statements (i) to (iv) and give outputs for SQL queries (v) to
(viii). 6
TABLE : ITEM
326
TABLE : CUSTOMER
(i) To display the details of those Customers whose City is Delhi
(ii) To display the details of Items whose Price is in the range of 35000 to
55000(Bothvaluesincluded)
(iii) TodisplaytheCustomerName,CityfromtableCustomerandItemName
andPricefromtableItem,withtheircorrespondingmatchingI-Id
(iv) To increase the Price of all Items by 1000 in the table Item
(v) SELECT DISTINCT City FROM Customer;
(vi) SELECT ItemName, MAX(Price), Count(*)
FROM Item GROUP BY ItemName;
(vii) SELECT CustomerName, Manufacturer FROM Item, Customer
WHEREItem.Item_Id=Customer.Item.I_Id
(viii) SELECT ItemName, Price * 100
FROM Item WHERE Manufacturer =’ABC’; .
6. (a) StateanyverifyAbsorptionlawinBooleanAlgebra. 2
(b) DrawaLogicalCircuitDiagramforthefollowingBooleanExpression: 1
A . (B + C’)
(c) ConvertthefollowingBooleanexpressionintoitsequivalentCanonical
Product of Sum Form (POS) : 2
A. B’ . C + A’. B . C + A’. B . C’
(d) ReducethefollowingBooleanexpressionusingK-Map: 3
F (A, B, C, D) = ∑ (0, l, 2, 4, 5, 8, 9, 10, 11)
7. (a) What is a Modem? 1
(b) ExpandthefollowingtermswithrespecttoNetworking: 2
(i) PPP
327
(ii) GSM
(iii) XML
(iv) HTTP
(c) How is a Hacker different from a Cracker? 1
(d) “China Middleton Fashion’” is planning to expand their network in India,
starting with two cities in India to provide infrastructure for distribution of
their product. The company has planned to set up their main office units in
Chennaiatthreedifferentlocationsandhavenamedtheirofficesas“Production
Unit”,“FinanceUnit”and“MediaUnit”.Thecompanyhasitscorporateunit
inDelhi.
Aroughlayoutofthesameisasfollows:
ApproximatedistancesbetweentheseUnitsisasfollows:
328
Incontinuationoftheabove,thecompanyexpertshaveplannedtoinstallthe
followingnumberofcomputersineachoftheirofficeunits:
(i) Suggest the kind of network required (out of LAN, MAN,WAN) for
connectingeachofthefollowingofficeunits:
ProductionUnitandMediaUnit
ProductionUnitandFinanceUnit
(ii) Whichoneofthefollowingdeviceswillyousuggestforconnectingall
thecomputerswithineachoftheirofficeunits?
Switch/Hub
Modem
Telephone
(iii) Which of the following communication media, will you suggest to be
procuredbythecompanyforconnectingtheirlocalofficeunitsinChennai
forveryeffective(HighSpeed)communication?
TelephoneCable
OpticalFiber
EthernetCable
(iv) Suggestacable/wiringlayoutforconnectingthecompany’slocaloffice
unitslocatedinChennai.Also,suggestaneffectivemethod/technology
forconnectingthecompany’sofficeunitlocatedinDelhi. 4
329
Marking Scheme — Computer Science
General Instructions :
1. TheanswersgiveninthemarkingschemeareSUGGESTIVE,Examinersarerequestedto
awardmarksforallalternativecorrectSolutions/Answersconveyingthesimilarmeaning
2. All programming questions have to be answered with respect to. C++ Language only.
3. InC++,ignorecasesensitivityforidentifiers(Variable/Functions/Structures/ClassNames).
4. In SQL related questions - both ways of text/character entries should be acceptable for
Example: “AMAR” and ‘amar’both are correct. .
5. InSQLrelatedquestions-semicolonshouldbeignoredforterminatingtheSQLstatements
6. InSQLrelatedquestions,ignorecasesensitivity.
QUESTION PAPER CODE 91/1
EXPECTEDANSWERS
1. (a) Whatisthedifferencebetween#defineandconst?Explainwithsuitable
example. 2
Ans: #define: It is a preprocessor directive in C++ for creating a Macro.
Example:
#define sqr(i) i*i
const: It is an Access Modifier in C++ that assigns a constant (non modifiable)
valuetoavariable.Anyattemptinmodifyingthevalueassignedtosuchavariableis
reported as an error by the compiler.
Example:
const float Pi = 3.14;
(½ Mark for each correct explanation of #define and const)
(½ Mark for each correct example of #define and const)
OR
(Full 2 Marks for correct examples demonstrating the difference between #define
and const)
OR
(Only 1 Mark to be awarded if Explanation without supporting examples)
330
(b) Name the header files that shall be needed for the following code 1
void main ( )
{
char String [ ] = “Peace”;
cout<<setw(20)<<String;
}
Ans: iostream.h
iomanip.h
(½ Mark for identifying each correct header file)
Note: Ignore any other header files, if mentioned.
(c) Rewritethefollowingprogramafterremovingthesyntacticalerror(s)ifany.
Underlineeachcorrection. 2
#include <iostream.h>
void main( )
{
First = 10 , Second = 20;
Jump to (First; Second) ;
Jumpto (Second);
}
void Jumpto(int N1, int N2=20)
{
N1 = N1 + N2;
cout<<N1>>N2;
}
Ans: #include <iostream.h>
void Jumpto(int N1, int N2=20); // Error 1
void main( )
{
int First = 10, Second = 20; // Error 2
Jumpto(First, Second); // Error 3
Jumpto(Second) ;
}
void Jumpto(int N1, int N2=20)
{
N1 = N1 + N2;
cout<<N1<<N2; // Error 4
}
OR
#include <iostream.h>
void Jumpto(int N1, int N2=20) // Error 1
331
{
N1 = N1 + N2;
cout<<N1<< N2; // Error 2
}
void main ( )
{
int First = 10, Second = 20; // Error 3
Jumpto(First, Second); // Error 4
Jumpto (Second) ;
}
(½ Mark for each correction)
OR
(1 Mark for identifying at least three errors, without suggesting
correction)
(d) Findtheoutputofthefollowingprogram: 3
#include<iostream.h>
#include<ctype.h>
void main ( )
{
char Text [ ] = “Mind@Work!”;
for (int I = 0; Text [I] !=’0’; I++)
{
if (!isalpha (Text [I])
Text [I] = ‘*’;
else if (isupper(Text [I]))
Text [I] = Text [I]+1;
else
Text (I) = Text [I+l];
}
cout<<Text;
}
Ans: Nnd@*Xrk!*
(½ Mark for N in the 1st position)
(½ Mark for nd in the 2nd and 3rd position)
(½ Mark for @ in the 4th position)
(½ Mark for * in the 5th position)
(½ Mark for Xrk!)
(½ Mark for * at the end)
332
OR
(Fu1l 3 Marks If error is mentioned in the code for Text (I) after last else)
(e) Findtheoutputofthefollowingprogram: 2
#include<iostream.h>
void main()
{
int U=10, V=20;
for (int I = 1; I<=2; I++)
{
cout<<“[1]=”<<U++<<“&”<<V–5<<endl;
cout<<“[2]=”<<++V<<“&”<<U+2<<endl;
}
}
Ans: [1]=10&15
[2]=21&13
[1]=11 &16
[2]=22&14
(½ Mark for each correct line of output)
Note:
½ Mark to be deducted for missing “=” and “&” symbols in the output.
½ Mark to be deducted if endl is not considered in the output
(f) Inthefollowingprogram,findthecorrectpossibleoutput(s)fromtheoptions: 2
#include<stdlib.h>
#include<iostream.h>
void main( )
{
randomize( );
char City [ ] [10] = {“DEL”, “CHN”, “KOL”, “BOM”, “BNG”};
int Fly;
for (int I=0;1<3;1++)
{
Fly = random(2)+1;
cout<<City [Fly]<<”:”;
}
}
outputs:
(i) DEL:CHN:KOL:
(ii) CHN:KOL:CHN:
(iii) KOL:BOM:BNG:
(iv) KOL:CHN:KOL:
333
Ans: (ii) & (iv)
(2 Marks for mentioning both correct options)
OR
(1 Mark for mentioning anyone correct option)
2. (a) DifferentiatebetweenpublicandprivatevisibilitymodesincontextofObject
OrientedProgrammingusingasuitableexampleillustratingeach. 2
Ans: public visibility mode:
Members of a class declared under this visibility are accessible inside the
class(inmemberfunctionsoftheclass)aswellasbytheObjectsofthatclass
(in any non member function of the program, prototyped / defined after the
classdeclaration).
private visibility mode:
Membersofaclassdeclaredunderthisvisibilityareaccessibleonlyinsidethe
class (in member functions of the class). They can not be accessed outside
the class.
class Example
{
int Priv;
public:
void Assign ( )
{
Priv =10; //private member accessible only inside class
}
} ;
void main ( )
{
Example E;
E.Assign( ); //public member accessible by Object
}
(2 Marks for differentiating public and private correctly using suitable
example)
OR
(1 Mark for correct explanation of private visibility)
(1 Mark for correct explanation of public visibility)
OR
(1 Mark for any valid example of a private member of a class)
(1 Mark for any valid example of a public member of a class)
334
(b) Answerthequestions(i)and(ii)aftergoingthroughthefollowingprogram 2
#include<iostream.h>
#include<string.h>
class Bazar
{
char Type [20];
char Product [20];
int Qty;
float Price;
Bazar ( )
{ //Function 1
strcpy (Type,”Electronic”);
strcpy (Product,”Calculator”);
Qty = 10;
Price = 225;
}
public:
void Disp ( )
{ //Function 2
cout<<Type<<“-”<<Product<<“:”<<Qty
<<“@”<<Price<<endl;
}
};
void main ( )
{
Bazar B; //Statement 1
B. Disp ( ) ; //Statement 2
}
(i) Will Statement 1 initialize all the data members for object B with the
values given in the Function 1? (Yes OR No). Justify your answer
suggesting the correction(s) to be made in the above code.
Ans: No, since the constructor Bazar has been defined in private section
Suggested Correction: Constructor Bazar() to be ,defined in public
(½ Mark for identifying NO)
(½ Mark for justification and correction)
(ii) What shall be the possible output when the program gets executed?
(Assuming, if required - the suggested correction(s) are made in the
program)
335
Ans: Iftheconstructorisdefinedasapublicmember,thefollowingoutputshallbe
generated:
Electronic-Calculator:10@225
(1 Mark for correct answer)
OR
(½ Mark each for the String and Numeric values)
(c) Define,aclassGarmentsinC++withthefollowingdescriptions: 4
PrivateMembers:
GCode oftypestring
GType oftypestring
GSize oftypeinteger
GFabric oftypestring
GPrice oftypefloat
Afunction Assign ( ) which calculates and assigns the value of GPrice as
follows
For the value ofGFabric as “COTTON”,
GType GPrice(Rs)
TROUSER 1300
SHIRT 1100
For GFabric other than “COTTON” the above mentioned
GPrice gets reduced by 10%.
PublicMembers:
Aconstructor to assign initial values of GCode, GType and GFabric
with the word “NOTALLOTTED” and GSize and GPrice with 0
A function Input ( ) to input the values of the data members GCode,
GType, GSize and GFabricl and invoke theAssign ( ) function.
AfunctionDisplay()whichdisplaysthecontentofallthedatamembers
for a Garment.
Ans:
class Garments
{
char GCode[10];
char GType[10];
int GSize;
char GFabric[10] ;
float GPrice;
336
void Assign( ) ;
public:
Garments( )
{
strcpy(GCode,”NOT ALLOTTED”) ;
strcpy(GType,”NOT ALLOTTED”) ;
strcpy (GFabric, “NOT ALLOTTED”) ;
GSize=0;
GPrice=0;
}
void Input( ) ;
void Display( ) ;
} ;
void Garments::Assign( )
{
if (strcmp(GFabric,“COTTON”)==0)
//if (!strcmp(GFabric, “COTTON”))
{
if (strcmp(GType,“TROUSER”) ==0)
GPrice=1300;
else if (strcmp(GType,“SHIRT”)==0)
GPrice=1100;
}
else
{
if (strcmp(GType,”TROUSER”) = =0)
GPrice=1300*0.9; // 10% reduction
else if (strcmp(GType,“SHIRT”)= =0)
GPrice=1100*0.9; // 10% reduction
}
}
void Garments::Input( )
{
gets(GCode) ; // or cin >> GCode;
gets(GType) ; // or cin >> GType;
cin>>GSize;
gets(GFabric) ;// or cin >> GFabric;
Assign( ) ;
}
void Garments::Display( )
{
cout<<GCode<<GType<<GSize<<GFabric<<GPrice<<endl;
}
337
(½ Mark for correct syntax for class header)
(½ Mark for correct declaration of data members)
(½ Mark for correct definition of constructor)
(1 Mark for correct definition of Assign( ))
(1 Mark for correct definition of Input( ) with proper invocation of Assign( ) function)
(½ Mark for correct definition of Display( ))
NOTE:
Deduct % Mark ifAssign( ) is not invoked properly inside Input( ) function
(d) Answer the questions (i) to (iv) based on the following code: 4
class Dolls
{
char DCode[5] ;
protected:
float Price;
void CalcPrice(float);
public:
Dolls ( );
void DInput ( ) ;
void DShow ( ) ;
} ;
class SoftDolls : public Dolls
{
char SDName[20] ;
float Weight;
public:
SoftDolls ( ) ;
void SDInput ( ) ;
void SDShow ( ) ;
} ;
class ElectronicDolls: public Dolls
{
char EDName[20] ;
char BatteryType[10];
int Batteries;
public:
ElectronicDolls ( ) ;
void EDInput ( ) ;
void EDShow ( ) ;
} ;
338
(i) WhichtypeofInheritanceisshownintheaboveexample?
Ans: HierarchicalInheritance
OR
SingleLevelInheritance
(1 mark for mentioning any of the above mentioned type of Inheritance)
(ii) How many bytes will be required by an object of the class ElectronicDolls?
Ans: 41 bytes
(1 Mark for correct answer)
(iii) Writenameofallthedatamembersaccessiblefrommemberfunctionsof
theclassSoftDolls
Ans: SDName,Weight, Price
(1 Mark for correct answer)
Note:
No marks to be awarded for partially correct answer
(iv) Write name of all the member functions accessible by an object of the class
ElectronicDolls.
Ans: EDInput( ), EDShow( ), DInput( ), DShow( )
(1 Mark for Correct answer)
Note:
Constructor functions ElectronicDolls( ) & Dolls( ) to be
Ignored.
No marks to be awarded for partially correct answers
3. (a) Write a function in C++, which accepts an integer array and its size as
parameters and rearranges the array in reverse. Example: if an array of nine
elementsinitiallycontainstheelementsas
4, 2, 5, 1, 6, 7, 8, 12, 10
thenthefunctionshouldrearrangethearrayas
10, 12, 8, 7, 6, 1, 5, 2, 4 4
Ans:
void Rearrange( int Arr [], int Size)
{
for (int i = 0; i<Size/2; i++)
{
int T = Arr[i];
Arr[i] = Arr[Size-1-i];
Arr[Size-1-i]=T;
}
}
OR
Any other correct equivalent function definition
(1 Mark for correct Function Header with proper Arguments)
339
(1 Mark for correct loop)
(2 Marks for swapping the values correctly)
Note:
Deduct ½ Mark if loop runs till Size instead of Size/2 for swapping
Deduct ½ Mark if reversed values are stored in another array
(b) An arrayArr[40][10] is stored in the memory along the column with each
element occupying 4 bytes. Find out the address of the locationArr[3][6]
if the locationArr[30][10] is stored at the address 9000 4
Ans:
AddressofArray[i][j]alongthecolumn=
Base Address + W [( i - L1) + (j - L2) * M]
where,
W = size of each location in bytes = 4
L1 = Lower Bound of rows = 0
L2 = Lower Bound of columns = 0
M = Number of rows per column = 40
Address of Array[30][10] = Base Address + 4 * (30 + 10 * 40)
9000 = Base Address + 4 * 430
BaseAddress = 9000 - 4 x 430
= 9000 -1720
= 7280
Address ofArray[3][6] = 7280 + 4 * (3 + 6 * 40)
= 7280 + 4 * 243
= 7280 + 972
= 8252
OR
AddressofArray[i][j]alongthecolumn=
Base Address + W (( i - L1) + (j - L2) * M)
where,
W = size of each location in bytes = 4
L1 = Lower Bound of rows = 1
L2 = Lower Bound of columns = 1
M = Number of rows per column = 40
Address of Array[30][10] = Base Address + 4 * ((30 -1) +(10 -1) * 40)
9000 = Base Address + 4 * (29+9*40)
340
9000 = Base Address + 4 * (29+360)
9000 = Base Address + 4 * (389)
BaseAddress = 9000 - 4 * 389
= 9000 -1556
= 7444
Address ofArray[3][6] = 7444 + 4 * ((3 -1) + (6 -1) * 40)
= 7444 + 4 * (2+5 * 40)
= 7444 + 4 * (2+200),
= 7444 + 4 * 202
= 7444 + 808
= 8252
OR
AddressofArray[i][j]alongthecolumn=
Address ofArray[x][y] + W [( i-x) + (j - y) * M]
where,
W = size of each location in bytes = 4
M = Number of rows per column = 40
i , j = Index value of the unknown element
x , y = Index value of the known element
Address ofArray[3][6] = Address of Array[30][10]+ 4 [(3 - 30) +(6 -10) * 40]
= 9000 + 4 [-27 -160]
= 9000 - 4 x 187
= 9000 -748
= 8252
(2 Marks for writing correct formula (for column major), substituting
formula with correct values and/or calculate Base Address)
(2 Marks for writing correct formula/correct substituted values, for
column major properly, for calculating Address of Arr[20][50])
(c) Write a function in c++ to Insert an element into a dynamically allocated
Queue where each node contains a name (of type string) as data. 4
AssumethefollowingdefinitionofTHENODEforthesame.
structTHENODE
{
char Name[20];
THENODE *Link;
};
341
Ans:
void Qinsert (THENODE *&Front, THENODE *&Rear)
{
THENODE *Temp = new THENODE;
gets(Temp->Name); //or cin>>Temp->Name;
Temp->Link = NULL;
if (Rear = = NULL)
{
Front = Temp;
Rear = Temp;
}
else
{
Rear – > Link = Temp;
Rear = Temp;
}
}
OR
class Queue
{
THENODE *Front, *Rear;
public:
QUEUE( ) //Constructor to initialize Top
{ Front = NULL;
Rear = NULL;
}
void Qinsert( );//Function to insert a node
void QDelete( );//Function to delete a node
void QDisplay( );//Function to display nodes of Stack
~Queue( ); //Destructor to delete all nodes
} ;
void Queue: : Qinsert ( )
{
THENODE *Temp;
Temp = new THENODE;
gets (Temp–>Name) ;//Or cin>>Temp–>Name;
Temp–>Link = NULL;
if (Rear = = NULL)
{
Front = Temp;
342
Rear = Temp;
}
else
{
Rear–>Link = Temp;
Rear = Temp;
}
}
(½ Mark for declaration of a temporary pointer to THENODE)
(½Markfornewallocationfortemporarypointer)
(½ Mark for assigning OR entering the value of NAME on temporary
pointer)
(½ Mark for assigning NULLto Temp->Link)
(½ Mark for checking Empty QUEUE)
(½ Mark for assigning Front and Rear in case of Empty QUEUE)
(½ Mark for assigning Rear ->Link with Temporary pointer when
QUEUEisnotEmpty)
(½MarkforreassigningRearwithTempwhentheQUEUEisnotEmpty)
(d) Write a function in C++ to print the product of each column of a two
dimensionalintegerarraypassedastheargumentofthefunction. 2
Explain:ifthetwodimensionalarraycontains
Then the output should appear as :
Product of Column 1 = 24
Product of Column 2 = 30
Product of Column 3 = 240
Ans:
void ProdCol(int Arr[][100], int Row, int Col)
{
int i, j, Prod;
for (j = 0; j < Col; j++)
{
Prod=1;
for (i = 0; i < Row; i++)
343
Prod * = Arr[i][j];
cout<<“Product of Column”<<j<< “=” <<Prod<<endl;
}
}
OR
Any other correct equivalent function definition
(½ Mark for correct function header)
(½ Mark for correct loop(s))
(½ Mark for finding product of elements for each column correctly)
(½ Mark for printing the product in correct format)
(e) Evaluatethefollowingpostfixnotationofexpression(ShowstatusofStack
after execution of each operation) : 2
4, 10, 5, +, *, 15, 3, /, –
Ans:
Operator Scanned Stack Content
4 4
10 4, 10
5 4, 10, 5
+ 4, 15
* 60
15 60, 15
3 60, 15, 3
/ 60, 5
- 55
OR
Anyothermethodofevaluatingcorrectlythepostfixexpressionisshowing
the Stack Status.
(½ Mark for each operation correctly evaluated showing the Stack Status)
OR
(½ Mark only to be given for writing correct answer without showing the
Stack Status)
4. (a) Observetheprogramsegmentgivenbelowcarefully,andanswerthequestion
thatfollows: 1
class Applicant
344
{
long AId; //Applicant’s Id
char Name [20] ; //Applicant’s Name
float Score; //Applicant’s Score
public:
void Enroll ( );
void Disp ( );
void MarksScore( ); //Function to change Score
long R_AId () {retumAId;)
} ;
void ScoreUpdate (long Id)
{
fstream File;
File.open (“APPLI.DAT”,ios::binary|ios::in|ios::out);
Applicant A;
int Record = 0, Found = 0 ;
while (!Found && File.read((char*) &C, sizeof(c)))
{
if(Id ==A.R_AId ( ))
{
cout<<”Enter new Score” ;
A.MarksScore ( );
______________ // Statement 1
______________ //Statement 2
Found = 1 .
}
Record ++;
}
if (Found ==1) cout<<”Record Updated”;
File.close ( ) ;
}
WritetheStatement1topositiontheFilePointeratthebeginningoftheRecord
forwhichtheApplicant’sldmatcheswiththeargumentpassed,andStatement2
to write the updated Record at that position.
Ans:
Statement 1 :
File.seekp (Record * sizeof (A));
OR
File.seekp (Record * sizeof (Applicant));
OR
345
File.seekp (File. tellg() - sizeof(A));
OR
File. seekp(File. tellg() - sizeof{Applicant));
OR
File. seekp(-sizeof (A) , ios::cur);
OR
File.seekg(Record * sizeof(A));
OR
File.seekg(Record * sizeof(Applicant));
OR
File. seekg(-sizeof (A) , ios::cur);
OR
Anyequivalentcorrectmethod
Statement 2:
File.write((char*) &A, sizeof (A));
OR
File.write((char*)&A, sizeof(Applicant));
OR
Any equivalent correct method usingAor C as object
(½ Mark for each correct Statement)
Note:
(Full1Marktobegivenformentioningerrorincodeforundeclaredsymbols
C and c in the File.read(...))
(b) Write a function in C++ to count the number of lowercase alphabets
present in a text file “BOOK.TXT”. 2
Ans:
int CountLower()
{
ifstream Fil; OR ifstream Fil (“BOOK.TXT”);
Fil.open(“BOOK. TXT”)
char Ch;
int Count =0;
while (Fil.get(Ch))
{
if (Ch>=‘a’ && Ch<=‘z’)
Count++;



346
}
Fil.close() ; //Ignore
return Count;
}
OR
int CountLower()
{
OR ifstream Fil (“BOOK.TXT”);ifstream Fil;
Fil.open(“BOOK. TXT”);
char Ch;
int Count =0;
while (Fil.get(Ch))
{
if (islower(Ch))
Count++;
}
Fil.close(); //Ignore
return Count;
}
OR
int CountLower()
{
ifstream Fil; OR ifstream Fil (“BOOK.TXT”);
Fil.open(“BOOK.TXT”);
char Ch;
int Count = 0;
while (!Fil.eof())
{
ch=Fil.get() ;
if (islower(Ch))
Count++;
}
Fil.close() ; //Ignore
return Count;
}
OR
Any other correct function definition
(½ Mark for opening BOOK. TXT correctly)
(½ Mark for reading each character from the file)
(½ Mark for checking lowercase alphabet)
(½ Mark for calculating the lowercase alphabets)






347
NOTE:
No Mark should be deducted if Count is not returned
(c) GivenabinaryfilePHONE.DAT,containingrecordsofthefollowing
structuretype 3
class Phonlist
{
char Name [20] ;
char Address[30];
char AreaCode[5];
char PhoneNo[15] ;
public:
void Register () ;
Void Show ( ) ;
int CheckCode (char AC[])
{
return strcmp (AreaCode, AC) ;
}
} ;
Write a function TRANSFER ( ) in C++, that would copy all those records
which are having AreaCode as “DEL” from PHONE.DAT to
PHONBACK.DAT.
Ans:
void TRANSFER() OR
{ ifstream fin (“PHONE.DAT”, ios: :binary);
Phonlist P; ofstream fin (“PHONBACK.DAT”, ios: :binary);
fstream fin,fout;
fin.open(“PHONE.DAT”,ios::binary|ios::in);
fout.open(“PHONBACK.DAT”, ios:: binary | ios::out);
while (fin.read((char*)&P, sizeof(P)))
{
if (P. CheckCode(“DEL”) ==0)
fout.write((char*)& P,sizeof(P));
}
fin.close(); //ignore
fout.close(); //ignore
}
OR OR
void TRANSFER() ifstream fin (“PHONE.DAT”, ios: :binary);
{ ofstream fin (“PHONBACK.DAT”, ios: :binary);
Phonlist P;
fstream fin, fout;
fin. open (“PHONE. DAT”, ios: : binary | ios: : in);
348
fout.open(“PHONBACK.DAT”, ios: :binary|ios: :in);
if (fin)
{
fin.read((char*)&P, sizeof(P));
while (!fn.eof())
{
if (P.CheckCode(“DEL”) ==0)
fout.write((char*)&P, sizeof(P));
fin.read((char*)&P, sizeof(P));
}
}
fin.close(); //ignore
fout.close(); //ignore
}
(½ Mark for opening PHONE.DAT correctly)
(½ Mark for opening PHONBACK.DAT correctly)
(½ Mark for reading each record from PHONE.DAT)
(½ Mark for correct loop / checking end of file)
(½ Mark for comparing value returned by CheckCode(“DEL”) with 0)
(½ Mark for writing the record to PHONBACK.DAT)
5. (a) Differentiate between Candidate Key and Primary Key in context of RDBMS
Ans: CandidateKey:Allsuchattributes/columns,whichcanuniquelyidentifyeach
row/record in a table
PrimaryKey:Anattribute/columnamongtheCandidateKeyswhichisused
touniquelyidentifyeachrow/recordinatable
(2Marksforanyvaliddifference/relationbetweenCandidateKeyandPrimary
Key)
OR
(1 Mark for correct explanation of Candidate Key)
(1 Mark for correct explanation of Primary Key)
(b) Consider the following tables Product and Client.Write SQLcommands for the
statement (i) to (iv) and give outputs for SQL queries (v) to (viii) 6
TABLE: PRODUCT
349
TABLE:CLIENT
(i) Todisplaythedetails ofthoseClientswhoseCityisDelhi
Ans: SELECT * FROM Client WHERE City = ‘Delhi’;
(½ Mark for correct SELECT)
(½ Mark for correct WHERE clause)
(ii) To display the details of Products whose Price is in the range of 50 to
100(Bothvaluesincluded)
Ans: SELECT * FROM Product
WHERE Price >=50 AND Price <=100;
OR
SELECT * FROM Product
WHERE Price BETWEEN 50AND 100;
(½ Mark for correct SELECT)
(½ Mark for correct WHERE clause)
(iii) TodisplaytheClientName,CityfromTableClient,andProductName
andPricefromtableProduct,withtheircorrespondingMatchingP_ID
Ans: SELECT ClientName, City, ProductName, Price, Client.P_ID
FROM Client, Product
WHERE Client.P_ID = Product. P_ID;
(½ Mark for correct SELECT)
(½ Mark for correct WHERE clause)
(iv) To increase the Price of all Products by 10
Ans: UPDATE Product SET Price = Price +10;
(½ Mark for correct SELECT)
(½ Mark for correct WHERE clause)
(v) SELECT DISTINCTAddress FROM Client
Ans: DISTINCT City
Bangalore
Delhi
350
Mumbai
(½ Mark for correct output)
OR
(½ Mark for mentioning Address is not a Column in the Table Client OR
mentioningERROR)
(vi) SELECTManufacturer,MAX(Price),Min(Price),Count(*)
FROM Product GROUP BY Manufacturer;
Ans: Manufacturer MAX(Price) MIN(Price) Count(*)
ABC 55 45 2
LAK 40 40 1
XYZ 120 95 2
(½ Mark for correct output)
(vii) SELECT ClientName, ManufacturerName FROM Product, Client
WHERE Client.Prod_Id = Product.P_Id;
Ans: ClientName Manufacturer
Cosmetic Shop ABC
TotalHealth ABC
Livelife XYZ
PrettyWoman XYZ
Dreams LAK
(½ Mark for correct output)
OR
(½MarkformentioningManufactureNameandProd_ldarenotvalidColumn
intherespectiveTables)
(viii) SELECT ProductName, Price * 4
Ans: Product Name Price * 4
TalcomPowder 160
Face Wash 180
Bath Soap 220
Shampoo 480
Face Wash 380
(½ Mark for correct output)
NOTE:
For Parts (v) to (viii), Ignore the Column Header and order of output rows
351
6. (a) State and verify De Morgan’s law in BooleanAlgebra 2
Ans:
(X + Y )’= X’. Y’
OR
(X . Y)’= X’+ Y’
Verification:
OR
(X+Y)’ = X’. Y’
If (X+Y)’ . (X+Y) = (X’ . V’) . (X+Y)
If 0 - = X’. Y’ . X + X’. Y’ . Y
If 0 = 0 + 0
Hence Proved andVerified
(1 Mark for stating anyone of the De Morgan’s Law)
(1 Mark for verifying anyone of the De Morgan’s Law)
(b) DrawaLogicalCircuitDiagramforthefollowingBooleanExpression 1
X’ . (y’ + Z)
Ans:
(1 Marks for Drawing Logic Circuit Diagram for all )
(c) ConvertthefollowingBooleanexpressionintoitsequivalentCanonicalSum
of Product Form«SOP) 2
(X’ +Y +Z’). (X’ +Y +Z). (X’ +Y’ +Z). (X’ +Y’ +Z’)”
Ans: F( X , Y , Z) = Π (4 , 5 , 6 , 7)
= ∑ (0 , 1 , 2 , 3)
352
= X’. Y’. Z’+ X’. Y’. Z + X’. Y. Z’+ X’. Y. Z
(2 Marks for writing correct Canonical SOP Expression)
OR
(1 Mark for only deriving Product Terms)
(d) Question
Ans:
F= C’.D’ + A’.C + B’.D’
(½ Mark for drawing correct K-Map)
(½ Mark for plotting 1‘s correctly)
(1 Mark for correct grouping)
(1 Mark for correct Answer)
7. (a) What is a Hub? 1
Ans: A Hub is used for a central connection between two or more computers on a
network.
OR
A Hub is a network device used to connect two or more computers.
OR
A Hub is an unintelligent network device to connect computers.
(1 Mark for any correct definition / explanation)
(b) ExpandthefollowingtermswithrespecttoNetworking: 2
(i) Modem (ii) WLL (iii) FTP (iv) TCP/IP
Ans:
(i) Modulator - Demodulator
(ii) Wireless Local Loop OR Wireless in Local Loop
(iii) File Transfer Protocol
(iv) TransferControl Protocol/Internet Protocol
(½ Mark for each correct expansion)
353
(c) HowisCoaxialcabledifferentfromOpticalFibre? 1
Ans: CoaxialCable:ComparativelySlow,Economic,convenienttolaydown,used
inBustopologyofnetworks
Optical Fibre:Veryfast,expensive,reliable,nointerference
(1 Mark for mentioning anyone valid difference)
OR
(½ Mark for anyone characteristic each of Coaxial Cable or Optical
Fibre)
(d) “Bias Methodologies” is planning to expand their network in India, starting
withthreecitiesinIndiatobuildinfrastructureforresearchanddevelopment
of their chemical products. The company has planned to setup their main
officeinPondicherry-atthreedifferentlocationsandhavenamedtheiroffices
as “Back Office”, “Research Lab” and “Development Unit”. The company
has one more Research office namely “Corporate Office” in “Mumbai”.A
roughlayoutofthesameisasfollows: 4
Approximatedistancesbetweentheseofficesisasfollows:
Incontinuationoftheabove,thecompanyexpertsp.ayeplannedtoinstallthe
followingnumberofcomputersineachoftheiroffices:
354
(i) Suggest the kind of network required (out of LAN, MAN, WAN) for
connectingeachofthefollowingofficeunits:
Research Lab and Back Office
ResearchLabandDevelopmentUnit
Ans: Research Lab and Back Office - LAN
Research Lab and Development Unit - MAN
(½ Mark for each answer)
(ii) Whichoneofthefollowingdevicewillyousuggestforconnectingall
thecomputerswithineachoftheirofficeunits?
Switch/Hub
Modem
Telephone
Ans: SwitchIHub
(1 Mark for mentioning correct option)
(iii) Whichofthefollowingcommunicationmedium,youwillsuggesttobe
procured by the company for connecting their local office units in
Pondicherryforveryeffective(HighSpeed)communication?
TelephoneCable
OpticalFiber
EthernetCable
Ans: OpticalFibre
(1 Mark for mentioning correct option)
(iv) Suggestacable/wiringlayoutforconnectingthecompany'slocaloffice
units located in Pondicherry. Also, suggest an effective method/
technologyforconnectingthecompany'sofficeunitlocatedinMumbai.
Ans: Local office units at Pondicherry to be connected using LAN / MAN / star
Topology / Tree Topology
Mumbai Office to be connected using Satellite/WAN
(½ Mark for mentioning valid connectivity or topology or diagram for
local office in Pondicherry)
(½ Mark. for mentioning valid connectivity or topology or diagram for
Mumbai office)
355
MARKING SCHEME
QUESTION PAPER CODE 91
EXPECTEDANSWERS
1. (a) What is the purpose of using a typedef command in C++. Explain with
suitableexample. 2
Ans: Typedef:
Thiskeywordallowscreatingsynonymsoraliasesforpreviouslydefineddata
types
Thegeneralformoftypedefis
typedefold_namenew_name;
OR
typedef is used for renaming a data type.
Example:
typedef char STR [80];
OR
typedef signed char SMALLNUM;
OR
typedef float REAL;
OR
typedef long int BIGNUM;
OR
typedef int MAT[2][3] ;
(1 Mark for definition of typedef)
(1 Mark for example of typedef)
OR
(Full 2 Marks for an example with an appropriate explanation)
(b) Name the header files that shall be needed for the following code: 1
void main ( )
{
char Word [ ] =”Exam”;
cout<<setw(20)<<Word;
}
Ans:
iostream.h
iomanip.h
(½ Mark for identifying each correct header file)
Note: Marks are not to be deducted if any additional header file is mentioned
356
(c) Rewritethefollowingprogramafterremovingthesyntaxerror(s),ifany.
Underlineeachcorrection. 2
#include <iostream.h>
void main ( )
{
One = 10, Two = 20;
Callme (One;Two) ;
Callme (Two) ;
}
void Callme (int Arg1, int Arg2=20)
{
Arg1 = Arg1 + Arg2;
cout<<Arg1>> Arg2;
}
Ans:
#include <iostream.h>
void Callme (int,int Arg2=20); //Error 1
void main ()
{
int One=10,Two=20; //Error 2
Callme(One,Two); //Error 3
Callme (Two);
}
void Callme (int Argl, int Arg2=20)
{
Argl=Argl +Arg2 ;
cout<<Argl<<Arg2; //Error 4
}
(½ Mark for each correction)
OR
(1 Mark for only identifying at least three errors, without suggesting
correction)
(d) Findtheoutputofthefollowingprogram:
#include<iostream.h>
#include<ctype.h>
void main ( )
{
char Mystring[ ] =“What@OUTPUT!” ;
for(int I = 0; Mystring [I] ! =’ 0'; I++)
{
357
if (!isalpha (Mystring[I]))
Mystring [I] = ‘*’;
else if (isupper (Mystring[I]))
Mystring [I] = Mystring[I] +1;
else
Mystring [I] = Mystring [I+1];
}
cout<<Mystring;
}
Ans:
Xat@*PVUQVU*
(½ Mark for X in the first position)
(½ Mark for at in the 2nd & 3rd positions)
(½ Mark for @ in the 4th position)
(½ Mark for * in the 5th position)
(½ Mark for PVUQvu)
(½ Mark for * at the end)
(e) Findtheoutputofthefollowingprogram:
#include<iostream.h>
void main ( )
{
int A=5, B=10;
for (int I = 1; I<=2; 1++)
{
cout<< “Linel=”<<A++<<“&”<<B–2<<endl;
cout<<“Line2=”<<++B<<“&”<<A+3<<endl;
}
}
Ans:
Line1=5&8
Line2=11&9
Line1=6&9
Line2=12&10
(½ Mark for each correct line of output)
Note: .
½ Mark to be deducted for missingAmpersand (&) in each line of output
½ Mark to be deducted if endl is not considered in the output
(f) Inthefollowingprogram,findthecorrectpossibleoutput(s)fromtheoptions:
#include<stdlib.h>
358
#include<iostream.h>
void main ( )
{
randomize() ;
char Area [] [10] = {‘‘NORTH”, ‘‘SOUTH”, “EAST”, “WEST”} ;
int ToGo;
for (int I=0; 1<3; 1++)
{
ToGo = random(2) +1;
cout<<Area [ToGo]<<” : “;
}
}
(i) SOUTH:EAST:SOUTH:
(ii) NORTH:SOUTH:EAST:
(iii)SOUTH:EAST:WEST:
(iv) SOUTH:EAST:EAST:
Ans:
(i)and(iv)
(2 Mark for the correct answer)
OR
(1 Mark for anyone of the option)
2. (a) Differentiatebetweenprivateand protectedvisibilitymodesincontextof
ObjectOrientedProgramminggivingasuitableexampleillustratingeach.
Ans: Private Visibility Mode Protected Visibility Mode
Themembersinprivatevisibility Themembersinprotectedvisibility
modes are not accessible to modes are not accessible to objects
objectsaswellasderivedclasses but are accessible in derived classes
class A
{
int x;
protected:
int y;
public:
void display(void) ;
} ;
class B:public A
{
int a;
public:
int b;
void readit(void) ;
};
359
(1 mark for anyone correct difference given above)
(1 mark for correct example).
(b) Answerthequestions(i)and(ii)aftergoingthroughthefollowingprogram:
#include<iostream.h>
#include<string.h>
class Retail
{
char Category [20];
char Item [20];
int Qty;
float Price;
Retail ( ) // Function 1
{
strcpy (Category, “Cereal”);
strcpy (Item, “Rice”);
Qty = 100;
Price = 25;
}
public:
void Show ( ) // Function 2
{
cout<<Category<<“–”<<Item<<“ : ”<<Qty
<<“@”<<Price<<endl;
}
};
void main ( )
{
Retail R; // Function 1
R. Show ( );. // Function 2
}
Ans: i) No, since the constructor Retail has been defined in private section.
Suggested Correction: Constructor RetailO to be defined in public
section of class.
(½ mark for identifying No)
(½ mark for justification)
Ans: ii) Cereal-Rice:100@25
(1 full mark for the correct answer)
(c) DefineaclassClothinginC++withthefollowingdescriptions:
PrivateMembers:
360
Code of type string
Type of type string
Size of type integer
Material of type string
Price of type float
AfunctionCalc_Price()whichcalculatesandassignsthevalueofPrice
asfollows:
For the value of Material as “COTTON” :
Type Price (Rs.)
TROUSER 1500
SHIRT 1200
ForMaterialotherthan“COTTON”theabovementionedPrice
gets reduced by 25%.
PublicMembers:
Aconstructor to assign initial values of Code, Type and Material with the
word “NOTASSIGNED” and Size and Price with 0.
Afunction Enter( ) to input the values of the data members Code,Type, Size
and Material and invoke the CalcPrice( ) function.
A function Show( ) which displays the content of all the data members for a
Clothing.
Ans:
class Clothing
{
char Code[25];
char Type[25];
int Size;
char Material[30];
float Price;
Public:
Clothing() ;
void Calc_Price() ;
void Enter() ;
void Show() ;
};
Clothing::Clothing()
{
strcpy(Code,”NOT ASSIGNED”);
strcpy(Type,”NOT ASSIGNED”);
Size=0;
361
strcpy (Material, “NOT ASSIGNED”);
Price=0;
}
void Clothing:: Calc_Price()
{
if (strcmp(Type, “TROUSER”) ==0 && strcmp (Material,“COTTON”)==0)
Price=1500;
else if (strcmp(Type, “SHIRT”) ==0 && strcmp(Material,”COTTON”)==O)
Price=1200;
else if (strcmp(Type, “TROUSER”) ==0 && strcmp(Material,”COTTON”)!=O)
Price=1500*0.75;
else if (strcmp(Type,”SHIRT”)==0) && strcmp(Material,”COTTON”)!= 0)
Price=1200*0.75;
}
void Clothing::Enter()
{
gets(Code) ; // or cin >> Code;
gets(Type) ; // or cin >> Type;
cin>>Size;
gets(Material) ;// or cin >> Material;
Calc_Price() ;
}
void Clothing::Show()
{
cout<<Code<<Type<<Size<<Material<<Price<<endl;
}
(½ Mark for correct syntax for class header)
(½ Mark for correct declaration of data members)
(½MarkforcorrectdefinitionoffunctionCalc_price())
(½ Mark for constructor)
(1 Mark for calculation of correct Price for each condition)
(½ Mark for correct Enter() with proper invocation of Calc_Price())
(½MarkfordisplayingalldataMembersinfunctionShow())
(d) Answer the questions (i) to (iv) based on the following code:
class Toys
{
char TCode [5] ;
protected:
float Price;
void Assign (float);
public:
Toys( ) ;
void TEntry ( ) ; ,
362
void TDisplay () ;
} ;
class SoftTOYS: public Toys
{
char STName [ 20] ;
float weight;
public:
SoftToys( ) ;
void STEntry ( ) ;
void STDisplay ( );
} ;
class ElectronicToys: public Toys
{
char ETName[20];
int No_of_Batteries;
public:
ElectronicToys( ) ;
void ETEntry ( ) ;
void ETDisplay ( ) ;
} ;
(i) Whichtypeofinheritanceisshownintheaboveexample?
Ans: HierarchicalInheritance
OR
SingleLevelInheritance
(1 Mark to be given for mentioning any of the above mentioned type of
inheritance)
(ii) How many bytes will be required by an object of the class softToys?
Ans:
33
(1 Mark for correct answer)
(iii) Writenameofallthedatamember(s)accessiblefrommemberfunctions
of class SoftToys.
Ans: Data Members: Price, STName, Weight
(1 Mark for all correct members)
NOTE:
No marks to be awarded for partially correct answers
(iv) Writenameofallthememberfunctions,whichareaccessiblefroman
object of the class ElectronicToys.
Ans:
Member Functions: TEntry ( ) , TDisplay ( ) , ETEntry ( ) , ETDisplay ( )
(1 Mark for correct answer)
363
NOTE:
ConstructorsToys() & ElectronicToys(), it mentioned to be ignored.
No marks to be awarded for partially correct answers
3. (a) WriteafunctioninC++,whichacceptsanintegerarrayand its size as arguments
andswapstheelementsofeveryevenlocationwithitsfollowingoddlocation. 4
Example:ifanarrayofnineelementsinitiallycontainstheelementsas
2, 4, 1, 6, 5, 7, 9, 23, 10
thenthefunctionshouldrearrangethearrayas
4, 2, 6, 1, 7, 5, 23, 9, 10
Ans:
void Display (int NUM[ ], int N)
{
int T;
for (int I=0; I<N–l; I+=2)
{
T=N[I] ;
N[I]=N[I+1] ;
N[I+1] = T ;
}
}
(1 Mark tor correct Function Header with proper Arguments)
(1 Mark for correct loop)
(2 Marks for swapping values correctly with/without a temporary variable)
(b) An arrayArr[50] [100] is stored in the memory along the row with each element
occupying2bytes.FindouttheaddressofthelocationArr[20][50],ifthelocation
Arr[10] [25] is stored at the address 10000.
Ans:
Assuming LBR=LBC=0
S=2 bytes
Number of Rows (N)=50
Number of Columns (M)=100
LOC (Arr [I] [J]) =B + (I*M+J)*S
LOC (Arr [10] [25])=B +(10*100+25)*2
10000 = B +(1000+25)*2
B = 10000-2050
B = 7950
LOC (Arr [20] [50]) = 7950+(20*100+50)*2
= 7950 + (2050*2)
364
= 7950+4100
= 12050
OR
Assuming LBR=LBC=1
S=2 bytes
Number of Rows (N)=50
Number of Columns (M) =100
LOC (Arr [I] [J]) =B +((I-LBR)*M+(J-LBC))*S
LOC (Arr [10] [25]) =B +((10–1)*100+(25–1))*2
10000 = B +(900+24)*2
B = 10000-1848
B = 8152
LOC (Arr [20] [50]) = 8152+ ((20-1)*100+ (50-1))*2
= 8152 + (1949*2)
= 8152+3898
= 12050
(2 Mark for writing correct formula(for row major), substituting formula
with correct values and calculate Base Address)
(1 Mark for writing correct formula/correct substituted values, for row
major properly, for calculating Address of Arr[20][50])
(1 Mark for calculating correct Address of Arr[20][50])
(c) WriteafunctioninC++toDeleteanelementfromadynamicallyallocatedQueue
where each node contains a real number as data.
AssumethefollowingdefinitionofMYNODEforthesame.
struct MYNODE
{
float NUM;
MYNODE *Link;
} ;
Ans:
class QUEUE
{
MYNODE *Rear,*Front;
public:
QUEUE() { Rear=NULL; Front=NULL;}
void DELETE();
~QUEUE() ;
};
//Function definition DELETE()
365
void QUEUE:: DELETE()
{
if (Front==NULL) // OR if{!Front)
cout<<”n Queue Underflown”i
else
{
MYNODE *Temp;
Temp=Front;
cout<<Front->NUM<<“:”<<“Deleted”<<endl;
// To be ignored
Front=Front–>Link;
delete Temp;
if (Front==NULL)
Rear=NULL;
}
}
OR
void DELETE(MYNODE *& Front, MYNODE *& Rear)
{
if (! Front)
cout<<“n Queue Underflown”;
else
{
MYNODE *Temp;
Temp=Front;
cout<<Front–>NUM<<“:”«“Deleted”<<endl;
//To be ignored
Front=Front–>Link;
delete Temp;
if (Front==NULL)
Rear=NULL;
}
}
Note. If Front and Rear are declared as Global vanabfes then Parameters are
not needed in the above function.
(½ Mark for correct function header)
(½ Mark for declaring Front and Rear as members OR passing them as
arguments OR declaring them as global variables)
(1 Mark for checking Underflow)
(1 Mark for updating Front)
(1 Mark for deleting node)
366
(d) Write a function in C++ to print the product of each row of a two dimensional
integer array passed as the argument of the function.
Example:ifthetwodimensionalarraycontains
Then the output should appear as :
Product of Row 1= 8000
Product of Row 2= 6000
Product of Row 3= 3600
Product of Row 4= 2400
Ans:
// Function definition
void Display(int A[ ][3], int M, int N)
{
int I, J;
long int T; // OR int T;
cout<<“Performing Calculation:”<<endl;
for (I=0; I<M; I=I+1)
{
T=1;
for (J=0; J<N; J=J+1)
T=T*A[M][N] ;
cout<<”Product of Row “<<I+1<<”= “<<T<<endl;
}
}
OR
Any other correct equivalent function definition
(1/2 mark for correct function header)
(1/2 mark for correct loops)
(1/2 mark for calculating product)
(1/2 mark for correct initialization of T after every inner loop)
(e) Evaluatethefollowingpostfixnotationofexpression(ShowstatusofStack
after execution of each operation) :
5, 20, 15, –, *, 25, 2, *, +
367
Ans: Evaluationofthegivenpostfixexpressionisexplainedbelow
Operator Scanned Stack Content
5 5
20 5, 20
15 5, 20,15
- 5, 5
* 25
25 25, 25, 2
2 25, 25, 2
* 25, 50,
+ 75
OR
Any other method of evaluating the postfix expression is shown.
(2 Marks to be given for correct answer)
(½ Mark for each operation correctly evaluated)
(Only 1 Mark is to be awarded if correct answer is given without steps)
4. (a) Observetheprogramsegmentgivenbelowcarefully,andanswerthequestion
thatfollows:
class Candidate
{
long Cld; / /Candidate’ s Id
char CName [20];/ /Candidate’s Name
float Marks; / /Candidate’s Marks
public:
void Enter ( ) ;
void Display ( ) ;
void MarksChange( ) ; / /Function to change marks
lond R_Cid( ) {return Cld; )
};
void MarksUpdate (long Id)
{
fstream File;
File.open (“CANDIDAT.DAT”,ios: :binary | ios: :in | ios: :out);
Candidate C;
int Record=0, Found=0;
while (! Found && File.read ( (char*) &C, sizeof (C) ) )
{
368
if (Id==C. R_Cld ( ) )
{
cout<<”Enter new Marks”;
C.MarksChange( ) ;
_______________/ /Statement 1
_______________/ /Statement 2
Found -= 1;
}
Record++;
}
if (Found= =1) cout<<”Record Updated”;
File.close ( ) ;
}
WritetheStatement1topositiontheFilePointeratthebeginningoftheRecord
forwhichtheCandidate’sIdmatcheswiththeargumentpassed,andStatement
2 to write the updated Record at that position.
Ans:
Statement 1:
File.seekp(Record*sizeof(C));
OR
File.seekp(-l*sizeof(C),ios::cur);
OR
File.seekg (Record*sizeof(C));
OR
File.seekg(-l*sizeof(C),ios::cur);
OR
Any equivalent correct method qf calculating size of the
record in place of sizeof operator.
Statement 2:
File.write((char*)&C, sizeof(C));
OR
File.write((char*)&C,sizeof(Candidate));
(½ Mark for each correct statement)
(b) Write a function in C++ to count the number of uppercase alphabets present
inatextfile“ARTICLE.TXT”.
Ans:
void theUpperAlphaCount()
{
ifstream Fi1(“ARTICLE. TXT”) ;
369
//R fstream Fi1;
//Fil.open(“ARTICLE. TXT”, ios : : in) ;
Char ch;
int c=0;
while(Fil) // OR while (!Fi1.eof())
Fil.get(ch) ; //OR ch = Fil.get();
if (isupper(ch))
//OR if (ch>=65 && ch<=90) OR if (ch>=‘A’&&ch<=‘Z’)
c++;
}
cout<<”Number of alphabets in uppercase”<<c<<endl.;
Fil.close() ;
}
OR
void theUpperAlphaCount()
{
ifstream Fil(“ARTICLE.TXT”);
//R fstream Fil;
//Fil.open(“ARTICLE. TXT”, ios:: in) ;
char ch;
int c=0;
while (Fil.get(ch))
{
if (isupper(ch))
//OR if (ch>=65 && ch<=90) OR if (ch>=‘A’ && ch<=‘Z’)
c++;
}
cout<<“Number of alphabets in uppercase”<<c<<endl;
Fil.close();
}
(½ Mark for opening file in the correct mode)
(½ Mark for reading the content from the file and the loop)
(½ Mark for correct comparison)
(½Markforinitializationandincrementofthecounter(variable))
(c) Given a binary file TELEPHON.DAT, containing records of the following
classDirectory:
class Directory
{
char Name[20] ;
char Address[30] ;
char AreaCode[5];
370
char Phone_No[15];
public:
void Register ( ) ;
void Show ( ) ;
int CheckCode(char AC[ ])
{
return strcmp (AreaCode, AC);
}
};
Write a function COPYABC( ) in C++, that would copy only those records
havingAreaCode as “123” fromTELEPHON.DATtoTELEBACK.DAT.
Ans:
//Function to copy records from TELEPHON.DAT to
//TELEBAC.DAT
void COPYABC()
{
fstream IS, OA;
IS.open(“TELEPHON.DAT”, ios::binary|ios: :in);
OA.open(“TELEBACK. DAT”, ios::binary | ios:: out);
Directory D;
while (IS.read((char*)& D,sizeof(D)))
{
if (D. CheckCode(“123”)==0)
OA.write((char *)& D,sizeof(D));
}
IS.close() ;
OA.close() ;
}
OR
Anyotherequivalentcode
(½ Mark for opening each file in the correct mode)
(½ Mark for reading the content from the file)
(½ Mark for the correct loop)
(½ Mark for the correct comparison with “123”)
(½ Mark for writing the content to the second file)
5. (a) Differentiate between Candidate Key and Alternate Key in context of
RDBMS.
Ans: Candidate Key: It is the one that is capable of becoming primary key i.e., a
columnorsetofcolumnsthatidentifiesarowuniquelyintherelation.
Alternate Key:Acandidate key that is not selected as a primary key is called
anAlternateKey.
371
(1 Mark each for correct definition/explanation of Candidate Key and
Alternate Key)
OR
(Full2MarksforillustratingtheconceptofCandidateandAlternatekeywith
appropriateexample)
(b) Consider the following -tables Item and Customer.Write SQLcommands
for the statements (i) to (iv) and give outputs for SQL queries (v) to (viii).
TABLE : ITEM
TABLE : CUSTOMER
(i) To display the details of those Customers whose City is Delhi.
Ans:
SELECT * FROM CUSTOMER WHERE City=’Delhi’ ;
(½ Mark for correct use of SELECT and FROM)
(½ Mark for correct use of WHERE clause)
(ii) To display the details of Items whose Price is in the range of 35000 to
55000(Bothvaluesincluded)
Ans:
SELECT * FROM ITEM WHERE PRICE BETWEEN 35000 AND 55000;
OR
SELECT * FROM ITEM WHERE PRICE>=35000 AND PRICE<=55000;
(½ Mark for correct use of SELECT and FROM)
(½ Mark for correct use of WHERE clause)
372
(iii) TodisplaytheCustomerName,CityfromtableCustomerandItemName
andPricefromtableitemwiththeircorrespondingmatchingI_Id.
Ans:
SELECT CustomerName, City, ItemName , Price
FROM CUSTOMER C, ITEM I WHERE I. I_Id=C.I_ID;
OR
SELECT CustomerName, City, ItemName, Price
FROM CUSTOMER, ITEM WHERE CUSTOMER.I_Id=ITEM.I_ID;
OR
SELECT C. CustomerName, C.City, I.ItemName, I.Price
FROM CUSTOMER C, ITEM I WHERE C.I_Id=I.I_ID;
OR
SELECT CUSTOMER.CustomerName, CUSTOMER.City,
ITEM. ItemName, ITEM. Price
FROM CUSTOMER, ITEM WHERE CUSTOMER.I_Id=ITEM.I_ID;
(½ Mark for correct use of SELECT and FROM)
(½ Mark for correct use of WHERE clause)
(iv) To increase the Price of all Items by 1000 in the table Item.
Ans:
UPDATE ITEM SET PRICE=PRICE+1000;
(½ Mark for cbrrect use of UPDATE)
(½ Mark for correct use of SET)
(v) SELECT DISTINCT City FROM Customer;
Ans:
DISTINCT City
Delhi
Mumbai
Bangalore
(½ Mark for correct output - ignore the order of City in the output &
Column Header)
(vi) SELECT ItemName, Max (Price), Count(*) From Item Group by
ItemName;
Ans:
ItemName Max (Price) Count ( * )
PersonalComputer 37000 3
Laptop 57000 2
(½Markforcorrectoutput-ignoretheorderofrowsintheoutput&Column
Headers)
373
(vii) SELECT CustomerName, Manufacturer FROM Item, Customer
WHEREItem.Item_Id=Customer.Item.I_Id;
Ans:
CustomerName Manufacturer
N Roy PQR
HSingh XYZ
R Pandey COMP
C Sharma PQR
KAgarwal ABC
(½Markforcorrectoutput-ignoretheorderofrowsintheoutput&Column
Headers)
OR
(½ Mark for mentioning syntax error or error as the column Item_ld is not
present)
(viii) SELECTItemName,Price*100FROMItemWHEREManufacturer=
'ABC';
Ans:
ItemName Price*100
PersonalComputer 3500000
Laptop 5500000
(½ Mark for correct output - ignore the order of rows in the output &
Column Headers)
6. (a) StateanyverifyAbsorptionlawinBoolean-Algebra.
Ans:
X+X.Y=X
X Y X.Y X+X.Y X
0 0 0 0 0
0 1 0 0 0
1 0 0 1 1
1 1 1 1 1
OR
X. (X+Y) = X
X Y X+Y X.(X+Y) X
0 0 0 0 0
0 1 1 0 0
1 0 1 1 1
1 1 1 1 1
374
OR
X+X’.Y=X+Y
X Y X’ X’.Y X+X’.Y X+Y
0 0 1 0 0 0
0 1 1 1 0 0
1 0 0 0 1 1
1 1 0 0 1 1
OR
X. (X’+Y) =X.Y
X Y X’ X’+Y X. (X’+Y) X.Y
0 0 1 1 0 0
0 1 1 1 0 0
1 0 0 0 0 0
1 1 0 1 1 1
OR
X+X.Y=X
L.H.S=X+X.Y
=X.1+X. Y
=X. (l+Y)
=X.1
=X
=R.H.S
Verified
OR
X(X+Y)=X
L.H.S=X. (X+Y)
L.H.S=X.X+X.Y
=X+X.Y
=X.1+X.Y
=X. (l+Y)
=X.1
=X
=R.H.S
Verified
OR
375
X+X’.Y=X+Y
L.H.S=(X+X’).(X+Y)
=1.(X+Y)
=X+Y
=R.H.S
Verified
OR
X.(X’+Y)=X.Y
L.H.S=X.(X’ +Y)
=X.X’+X.Y
=0+X.Y
=X.Y
=R.H.S
Verified
(2 Marks for verification of anyone form of the Absorption Law)
OR
(1 Mark for stating anyone form of theAbsorption Law)
(b) DrawaLogicalCircuitDiagramforthefollowingBooleanExpression:
A . (B + C’)
Ans:
(1 mark for the correct circuit diagram)
(c) ConvertthefollowingBooleanexpressionintoitsequivalentCanonical
Product of Sum Form (POS) :
A. B’ . C + A’. B . C + A’. B . C’
Ans:
= Π (0, 1, 4, 6, 7)
OR
= (A+B+C) . (A+B+C’) . (A’+B+C) . (A’ +B’ +C) . (A’+B’ +C’ )
(2 Marks for the correct expression)
OR
(1 Mark if only truth table is given for the expression without deriving
POS expression)
Note: No marks to be awarded for partial answers
F
376
(d) ReducethefollowingBooleanexpressionusingK-Map:
F (A, B, C, D) = ∑ (0, l, 2, 4, 5, 8, 9, 10, 11)
Ans:
F(A,B,C,D)=A’.C’+A.B’+ B’.D’
(1 Mark for drawing correct K-Map )
(½ Mark for plotting 1‘s correctly)
(½ Mark for each correct grouping)
Note: No marks should be deducted even if the solution is arrived with the
help of POS form.
7. (a) What is a Modem?
Ans: ModemisaModulationDemodulationdevicethatconvertsanalogsignalto
digitalsignalandviceversa.
(1Markforanycorrectdefinition/explanation)
(b) ExpandthefollowingtermswithrespecttoNetworking:
(i) PPP (ii) GSM (iii) XML (iv) HTTP
Ans: (i) PointTo Point Protocol
(ii) GlobalSystemforMobileCommunication
(iii) eXtensibleMarkUpLanguage
(iv) HyperTextTransfer Protocol
(½ Mark for each correct expansion)
(c) How is a Hacker different from a Cracker?
Ans:
Hackers are the ones who get into someone’s code or computer without any
maliciousintentions,whereasCrackersaretheone’swhogetintosomeone’s
codeorcomputerwithmaliciousintentions.
OR
Any equivalent difference
(½ Mark for each correct definition)
(d) “China Middleton Fashion’” is planning to expand their network in India,
starting with two cities in India to provide infrastructure for distribution of
377
their product. The company has planned to set up their main office units in
Chennaiatthreedifferentlocationsandhavenamedtheirofficesas“Production
Unit”,“FinanceUnit”and“MediaUnit”.Thecompanyhasitscorporateunit
inDelhi.
Aroughlayoutofthesameisasfollows:
ApproximatedistancesbetweentheseUnitsisasfollows:
Incontinuationoftheabove,thecompanyexpertshaveplannedtoinstallthe
followingnumberofcomputersineachoftheirofficeunits:
378
(i) Suggest the kind of network required (out of LAN, MAN,WAN) for
connectingeachofthefollowingofficeunits:
ProductionUnitandMediaUnit
ProductionUnitandFinanceUnit
Ans:
Production Unit and Media Unit : MAN
ProductionUnitandFinanceUnit: LAN
(½ Mark for mention of each - MAN and LAN correctly)
(ii) Whichoneofthefollowingdevicewillyousuggestforconnectingall
thecomputerswithineachoftheirofficeunits?
Switch/Hub
Modem
Telephone
Ans:
Switch/Hub
(1 Mark for the correct device)
(iii) Which of the following communication media, will you suggest to be
procuredbythecompanyforconnectingtheirlocalofficesinChennai
forveryeffective(HighSpeed)communication?
Ethernetcable
OpticalFiber
Telephonecable
Ans:
OpticalFiber
(1 Mark for the correct media)
(iv) Suggestacable/wiringlayoutforconnectingthecompany'slocaloffice
unitslocatedinChennai.Also,suggestaneffectivemethod/technology
forconnectingthecompany'sofficeunitlocatedinDelhi.
Ans:
Optical Fiber/StarTopology
Wireless/SatelliteLink/leasedLine
(½ Mark for the correct layout)
(½ Mark for the equivalent correct method/technology)
310
COMPUTER SCIENCE
Time allowed : 3 hours Maximum Marks : 70
Instructions:
(i) All questions are compulsory.
(ii) Programming Language: C+ +
QUESTION PAPER CODE 91/1
1. (a) What is the difference between call by value and call by reference? Give an
exampleinC++toillustrateboth. 2
(b) Writethenamesoftheheaderfilestowhichthefollowingbelong: 1
(i) puts( )
(ii) sin()
(c) Rewritethefollowingprogramafterremovingthesyntacticalerrors(ifany).
Underlineeachcorrection. 2
#include [iostream.h]
#include [stdio.h]
class Employee
{
int EmpId = 901;
char EName [20] ;
public
Employee ( ) { }
void Joining () {cin>>EmpId; gets (EName);}
void List ( ) {cout<<EmpId<<“ : ”<<EName<<endl;}
} ;
void main ( )
{
Employee E ;
311
Joining.E ( ) ;
E. List ( )
}
(d) Findtheoutputofthefollowingprogram: 3
#include<iostream.h>
void main ( )
{
int X[ ] = {10, 25, 30, 55, 100};
int *p = X ;
while ( *p < 110)
{
if (*p%3 ! = 0)
*p = *p + 1 ;
else
*p = *p + 2 ;
p++;
}
for(int I = 4 ; 1>= 1 ; I - -)
{
cout << X[I] << “*” ;
if ( I%3 = = 0) cout<<endl ;
}
cout<<X[0]*3<<endl ;
}
(e) Findtheoutputofthefollowingprogram: 2
#include<iostream.h>
#include<ctype.h>
void Encode (char Info [ ], int N) ;
void main ( )
{
312
char Memo [ ] = “Justnow” ;
Encode(Memo, 2) ;
cout<<Memo<<endl ;
}
void Encode(char Info[ ], int N)
{
for (int I = 0 ; Info[I] != ‘0’ ; 1++)
if (1%2= =0)
Info[I] = Info[I] –N ;
else if (islower(Info[I]))
Info[I] = toupper(Info[I]) ;
else
Info[I] = Info[I] +N ;
}
(f) Studythefollowingprogramandselectthepossibleoutputfromit: 2
#include <iostream.h>
#include <stdlib.h>
const int LIMIT = 4 ;
void main ( )
{
randomize ( ) ;
int Points;
Points = 100 + random(LIMIT) ;
for (int P=Points ; P>=100 ; P– –)
cout<<P<<“#” ;
cout<<endl;
}
(i) 103#102#101#100#
(ii) 100#101#102#103#
313
(iii) 100#101#102#103#104#
(iv) 104#103#102#101#100#
2. (a) What is copy constructor? Give an example in C++ to illustrate copy con-
structor. 2
(b) Answer the questions (i) and (ii) after going through the following class:
class WORK 2
{
int WorkId;char WorkType ;
public:
-WORK ( ) //Function 1
{ cout<<”Un-Allocated”<<endl ;}
void status ( ) //Function 2
{ cout<<WorkId<<”: “<<WorkType<<endl ;}
WORK ( ) //Function 3
{ WorkId = 10; WorkType=’T’ ; }
WORK(WORK &W) //Function 4
{
WorkId=W. WorkId+12;WorkType=W. WorkType+l
}
} ;
(i) WhichmemberfunctionoutofFunction1,Function2,Function3andFunction
4shownintheabovedefinitionofclassWORKiscalledautomatically,when
the scope of an object gets over? Is it known as Constructor OR Destructor
OR Overloaded Function OR Copy Constructor?
(ii) WORK W ; //Statement1
WORK Y (W) ; //Statement2
WhichmemberfunctionoutofFunction1,Function2,Function3andFunction
4shownintheabovedefinitionofclassWORKwillbecalledonexecutionof
statementwrittenasstatement2?Whatisthisfunctionspecificallyknownas
out of Destructor or Copy Constructor or Default Constructor?
(c) DefineaclassRESORTinC++withfollowingdescription: 4
314
PrivateMembers
Rno //Data member to store Room No
Name //Data member to store customer name
Charges //Data member to store per day charges
Days //Data member to store number of days of stay
COMPUTE( ) //A function to calculate’ and return Amount as
Days*Charges and if the value of Days*Charges is more than 11000
then as 1.02*Days*Charges
PublicMembers
Getinfo() //A function to enter the content Rno, Name,
//Charges and Days
Dispinfo() //A function to display Rno, Name, Charges,
//Days andAmount (Amount to be displayed by
//calling function COMPUTE ( ) )
(d) Answerthequestions(i)to(iv)basedonthefollowing: 4
class FaceToFace
{
char CenterCode [10] ;
public:
void Input ( ) ;
void Output ( ) ;
} ;
class Online
{
char website [50] ;
public:
void SiteIn ( ) ;
void SiteOut ( ) ;
} ;
class Training: public FaceToFace, private Online
315
{
long Tcode ;
float charge;
int period;
public:
void Register ( ) ;
void Show ( ) ;
} ;
(i) WhichtypeofInheritanceisshownintheaboveexample?
(ii) WritenamesofallthememberfunctionsaccessiblefromShow()functionof
classTraining.
(iii) WritenameofallthemembersaccessiblethroughanobjectofclassTraining.
(iv) Is the function Output( ) accessible inside the function SiteOut( ) ? Justify
youranswer.
3. (a) Write a function SORTPOINTS( ) in C++ to sort an array of structure Game
in descending order of Points using Bubble Sort. 3
Note:AssumethefollowingdefinitionofstructureGame
struct Game
{
long PNo; //Player Number
char PName [20] ;
long Points;
} ;
Sample content of the array (before sorting)
PNo PName Points
103 RitikaKapur 3001
104 JohnPhilip 2819
101 RaziaAbbas 3451
105 TarunKumar 2971
316
Sample content of the array (after sorting)
PNo PName Points
101 RaziaAbbas 3451
103 Ri tika Kapur 3001
105 TarunKumar 2971
104 JohnPhilip 2819
(b) An array S[40][30]isstoredinthememoryalongthecolumnwith each of the
element occupying 4 bytes, find out the base address and address of element
S[20][15], if an element S[15][10] is stored at the memory location 7200. 4
(c) Write a function QUEINS( ) in C++ to insert an element in a dynamically
allocatedQueuecontainingnodesofthefollowinggivenstructure: 4
struct Node
{
int PId ; //Product Id
char Pname [20] ;
NODE *Next ;
} ;
(d) DefineafunctionSWAPCOL()inC++toswap(interchange)thefirstcolumn
elements with the last column elements, for a two dimensional integer array
passed as the argument of the function. 3
Example:Ifthetwodimensionalarraycontains
2 1 4 9
1 3 7 7
5 8 6 3
7 2 1 2
After swapping of the content of 1st column and last column, it should be :
9 1 4 2
7 3 7 1
3 8 6 5
2 2 1 7
317
(e) Convert the following infix expression to its equivalent postfix expression
showingstackcontentsfortheconversion: 2
X–Y /(Z + U) * V
4. (a) Observe the program segment given below carefully and fill in the blanks
markedasLine1andLine2usingfstreamfunctionsforperformingthere-
quired task. 1
#include <fstream.h>
class Stock
{
long Ino ; //Item Number
char Item [20] ;//Item Name
int Qty ; //Quantity
public:
void Get(int) ;//Function to enter the content
void show ( ) ;//Function to display the content
void Purchase (int Tqty)
{
Qty + = Tqty ;
} //Function to increment in Qty
long KnowIno ( ) {return Ino ;}
} ;
void Purchaseitem (long PINo, int PQty)
//PINo -> Ino of the item purchased
//PQty -> Number of item purchased
{
fstream File;
File.open(“ITEMS.DAT”, ios :: binarylios ::
inlios :: out);
int Pos = –1 ;
Stock S ;
318
while (Pos = = –1 && File.read((char*) &S, sizeof (S)))
if (S. KnowIno( ) = =PINo)
{
S. Purchase (PQty); //To update the number of Items
Pos = File.tellg ( ) -sizeof (S) ;
//Line 1: To place the file pointer to the required
position ;
//Line 2: To write the object S on to the binary
file ;
}
if (Pos = = –1)
cout<<“No updation done as required Ino not found..” ;
File.close ( ) ;
}
(b) Write a function COUNT_DO( ) in C++ to count the presence of a word
‘do’inatextfile“MEMO.TXT” 2
Example:
Ifthecontentofthefile“MEMO.TXT”isasfollows:
I will do it, if you
request me to do it.
It would have been done much earlier.
ThefunctionCOUNT_DO()willdisDla
Count of -do- in file : 2
Note: In the above example, ‘do’ occurring as a part of word done is not
considered.
(c) Write a function in C++ to read and display the detail of all the users whose
statusis‘A’(i.e.Active)fromabinaryfile“USER.DAT”.Assumingthebinary
file “USER.DAT” is containing objects of class USER, which is definedas
follows: 3
319
class USER
{
int Uid ; //User Id
char Uname [20];//User Name
char Status; //User Type: A Active I Inactive
Public:
void Register ( ) ;//Function to enter the content
void show ( ) ; //Function to display all data
members
char Getstatus ( ) {return Status;}.
} ;
5. (a) What are candidate keys in a table? Give a suitable example of candidate
keys in a table. 2
(b) Consider the following tables GARMENT and FABRIC. Write SQL
commands for the statements (i) to (iv) and give outputs for SQL queries
(v)to(viii) 6
Table:GARMENT
Table : FABRIC
FCODE TYPE
F04 POLYSTER
F02 COTTON
F03 SILK
F01 TERELENE
320
(i) To display GCODE and DESCRIPTION of each GARMENT in
descending order of GCODE
(ii) TodisplaythedetailsofalltheGARMENTs,whichhaveREADYDA
TE in between 08-DEC-07 and 16-JUN-08(inclusive of both the
dates).
(iii) TodisplaytheaveragePRICEofalltheGARMENTs,whicharemade
up of FABRIC with FCODE as F03.
(iv) To display FABRIC wise highest and lowest price of GARMENTs
fromGARMENTtable.(DisplayFCODEofeachGARMENTalong
withhighestandlowestprice)
(v) SELECT SUM (PRICE) FROM GARMENT WHERE FCODE =
‘F01’ ;
(vi) SELECT DESCRIPTION, TYPE FROM GARMENT, FABRIC
WHERE GARMENT.FCODE = FABRIC.FCODE AND
GARMENT. PRICE > = 1260 ;
(vii) SELECT MAX (FCODE) FROM FABRIC;
(viii) SELECT COUNT (DISTINCT PRICE) FROM GARMENT ;
6. (a) Verify X’Y+ X.Y’+ X’Y’= (X’+Y’) using truth table. 2
(b) WritetheequivalentBooleanExpressionforthefollowingLogicCircuit: 2
(c) Write the POS form of a Boolean function H, which is represented in a truth
tableasfollows: 1
321
(d) ReducethefollowingBooleanExpressionusingK-Map: 3
F(P, Q, R, S) = Σ(1, 2, 3, 5,6, 7, 9, 11, 12, 13, 15)
7. (a) What is difference between StarTopology and BusTopology of network? 1
(b) Expandthefollowingabbreviations: 1
(i) GSM
(ii) CDMA
(c) What is protocol? Which protocol is used to search information from internet
usinganinternetbrowser? 1
(d) Name two switching techniques used to transfer data between two terminals
(computers ). 1
(e) Freshminds University of India is starting its first campus inAna Nagar of
South India with its center admission office in Kolkata. The university has 3
major blocks comprising of Office Block, Science Block and Commerce
Block in the 5 KM area Campus.
As a network expert, you need to suggest the network plan as per (El) to
(E4)totheauthoritieskeepinginmindthedistanceandothergivenparameters.
ExpectedWiredistancesbetweenvariouslocations:
Office Block to Science Block 90 m
Office Block to Commerce Block 80 m
Science Block to Commerce Block 15 m
KolkataAdmission office toAna Nagar Campus 2450 km
Expected number of Computers to be installed’ at various locations in the
Universityareasfollows:
Office Block 10
Science Block 140
Commerce Block 30
KolkataAdmission office 8
322
(E1) Suggest the authorities, the cable layout amongst various blocks inside
universitycampusforconnectingtheblocks. 1
(E2) Suggest the most suitable place (i.e. block) to house the server of this
universitywithasuitablereason. 1
(E3) Suggestanefficientdevicefromthefollowingtobeinstalledineachofthe
blocks to connect all the computers: 1
(i) MODEM
(ii) SWITCH
(iii) GATEWAY
(E4) Suggest the most suitable. (very high speed) service to provide data con-
nectivity betweenAdmission Office located in Kolkata and the campus
locatedinAnaNagarfromthefollowingoptions: 1
Telephoneline
Fixed-LineDial-upconnection
Co-axial Cable Network
GSM
Leasedline
SatelliteConnection
QUESTION PAPER CODE 91
1. (a) What is the difference betweenActual Parameter and Formal Parameter?
Give an example in C++ to illustrate both types of parameters. 2
(b) Writethenamesoftheheaderfilestowhichthefollowingbelong: 1
(i) setw( )
(ii) sqrt( )
(c) Rewritethefollowingprogramafterremovingthesyntacticalerrors(ifany).
Underlineeachcorrection. 2
include <iostream.h>
include <stdio.h>
class MyStudent
{
323
int StudentId = 1001;
char Name [20] ;
public
MyStudent( ){ }
void Register ( ) {cin>>StudentId; gets (Name) ;}
void Display ( ) {cout<<StudentId<< “:” <<Name<<end1;}
} ;
void main ( )
{
MyStudent MS ;
Register.MS( ) ;
MS.Display( ) ;
}
(d) Findtheoutputofthefollowingprogram: 3
#include<iostream.h>
void main ( )
{
int A[ ] = {10, 15, 20, 25, 30}
int *p = A;
while (*p < 30)
{
if (*p%3 ! = 0)
*p = *p + 2 ;
else
*p = *p + 1;
p++;
}
for (int J = 0; J<=4; J++)
{
cout << A[J] << “*” ;
if ( J%3 = = 0) cout<<end1;
324
}
Cout<<A[4] * 3<<end1;
}
(e) Findtheoutputofthefollowingprogram: 2
#include <iostream.h>
#include <ctype.h>
void Secret (char Mig [ ], int N);
void main ( )
{
char SMS[ ] = “rEPorTmE” ;
Secret{SMS,2);
cout<<SMS<<end1;
}
void Secret(char Msg[ ], int N)
{
for (int C=0; Msg[C] ! =’ 0' ;C++)
if (C%2==0)
Msg[C] = Msg[C]+N;
else if (isupper(Msg[C]))
Msg[C] = tolower(Msg[C]);
else
Msg[C] = Msg[C]-N;
}
(f) Studythefollowingprogramandselectthepossibleoutputfromit: 2
#include <iostream.h>
#include <stdlib.h>
const int MAX=3 ;
void main ( )
{
randomize( ) ;
int Number ;
325
Number = 50 + random{MAX) ;
for (int P=Number; P>=50; P– –)
cout<<p<< “ # ” ;
cout<<endl;
}
(i) 53#52#51#50#
(ii) 50#51#52#
(iii) 50#51#
(iv) 51#50#
2. (a) Whatisfunctionoverloading?GiveanexampleinC++toillustratefunction
overloading. 2
(b) Answerthequestions(i)and(ii)aftergoingthroughthefollowingclass: 2
class Job
{
int JobId;char JobType;
public:
~Job ( ) //Function 1
{ cout<< “Resigned” <<end1; }
Job ( ) //Function 2
{ JobId=10 ; JobType =‘T” ;}
void TellMe( )//Function 3
{ cout<<JobId<< “: ” <<JobType<<end1; }
Job (Job &J) //Function 4
{
JobId=J.JobId+10; JobType=J.JobType+l;
}
};
326
(i) WhichmemberfunctionoutofFunction1,Function2,Function3andFunction
4shownintheabovedefinitionofclassJobiscalledautomatically,whenthe
scope of an object gets over? Is it known as Constructor OR Destructor OR
Overloaded Function OR Copy Constructor?
(ii) Job P ; //Line 1
Job Q(P) ; //Line 2
WhichmemberfunctionoutofFunction1,Function2,Function3andFunction
4 shown in the above definition of class Job will be called on execution of
statementwrittenasLine2?Whatisthisfunctionspecificallyknownasoutof
Destructor or Copy Constructor or Default Constructor?
(c) DefineaclassHOTELinC++withthefollowingdescription: 4
PrivateMembers:
Rno //Data member to store Room No
Name //Data member to store customer name
Tariff //Data member to store per day charges
NOD //Data member to store number of days of stay
CALC( ) //Afunction to calculate and returnAmount as NOD*Tariff
and if the value of NOD*Tariff is more than 10000 then as
1.05*NOD*Tariff
PublicMembers
Checkin ( ) / /Afunction to enter the content Rno, Name,
/ / Tariff and NOD
Checkout( ) / /Afunction to display Rno, Name, Tariff,
/ /NOD andAmount (Amount to be displayed by
//callingfunctionCALC())
(d) Answerthequestions(i)to(iv)basedonthefollowing: 4
class Regular
{
char SchoolCode[10];
327
public:
void InRegular( );
void OutRegular( );
} ;
class Distance
{
char StudyCentreCode [‘5] ;
public:
void InDistance( );
void OutDistance ( );
} ;
class Course: public Regular, private Distance
{
char Code [ 5] ;
float Fees;
int Duration;
public:
void InCourse( );
void OutCourse( );
} ;
(i) WhichtypeofInheritanceisshownintheaboveexample?
(ii) Write names of all the member functions accessible from OutCourse
functionofclassCourse.
(iii) Write name of all the members accessible througb an object of class
Course.
(iv) IsthefunctionInRegular()accessibleinsidethefunctionInDistance()?
Justifyyouranswer.
3. (a) WriteafunctionSORTSCORE()inC++tosortanarrayofstructureExaminee
in descending order of Score using Bubble Sort. 3
Note:AssumethefollowingdefinitionofstructureExaminee
328
struct Examinee
{
long RollNo;
char Name [20] ;
float Score;
} ;
Sample Content of the array (before sorting)
Sample Content of the array (after sorting)
(b) An array T[50][20] is stored in the memory along the column with each of
the elements occupying 4 bytes. Find out the base address and address of
element T[30][15], if an element T[25][10] is stored at the memory location
9800. 4
(c) Write a function QUEDEL( ) in C++ to display and delete an element from
a dynamically allocated Queue containing nodes of the following given
structure: 4
struct NODE
{
329
int Itemno;
char Itemname[20];
NODE *Link;
} ;
(d) Define a function SWAPARR( ) in C++ to swap (interchange) the first row
elements with the last row elements, for a two dimensional integer array
passed as the argument of the function. 3
Example:Ifthetwodimensionalarraycontains
5 6 3 2
1 2 4 9
2 5 8 1
9 7 5 8
After swapping of the content of first row and last row, it should be as follows:
9 7 5 8
1 2 4 9
2 5 8 1
5 6 3 2
(e) Convert the following infix expression to its equivalent postfix expression
showingstackcontentsfortheconversion: 2
A + B * (C – D) / E
4. (a) Observetheprogramsegmentgivenbelowcarefullyandfilltheblanksmarked.
asLine1andLine2usingfstreamfunctionsforperformingtherequiredtask. 1
#include <fstream.h>
class Library
{
long Ano; //Ano - Accession Number of the Book
char Title[20]; //Title - Title of the Book
int Qty; //Qty - Number of Books in Library
public:
330
void Enter(int); //Function to enter the content
void Display(); //Function to display the content
void Buy(int Tqty)
{
Qty+=Tqty;
} //Function to increment in Qty
long GetAno() {return Ano;}
} ;
void BuyBook(long BANo,int BQty)
//BANo → Ano of the book purchased
//BQty → Number of books purchased
{
fstream File;
File.open(“STOCK.DAT” ,ios::binary|ios::in|ios::out);
int position=-l;
Library L;
while (Position==-l && File.read((char*)&L,sizeof(L).))
if (L. GetAno() ==BANo)
{
L.Buy(BQty); //To update the number of Books
Position = File.tellg()-sizeof(L) ;
//Line 1: To place the file pointer to the required positiol
______________________________;
//Line 2:To write the object L on to the binary file
______________________________;
}
if (Position==-l)
cout<< “No updation do:r{e as required Ano not found..”;
File.close();
}
(b) Write a function COUNT_TO( ) in C++ to count the presence of a word ‘to’
inatextfile“NOTES.TXT”. 2
331
Example:
Ifthecontentofthefile“NOTES.TXT”isasfollows:
It is very important to know that
smokingisinjurioustohealth.
Let us take initiative to stop it.
ThefunctionCOUNT_TO()willdisplaythefollowingmessage:
Count of -to- in file: 3
Note: In the above example, ‘to’ occurring as a part of word stop is not
considered.
(c) Write a function in C++ to read and display the detail of all the members
whose membership type is ‘L’or ‘M’from a binary file “CLUB.DAT”.
Assume the binary file “CLUB.DAT” contains objects of class CLUB,
whichisdefinedasfollows: 3
class CLUB
{
int Mno; //Member Number
char Mname [20]; //Member Name
char Type;//Member Type:L Life Member M Monthly Member G Guest
public:
void Register();//Function to enter the content
void Display(); //Function to display all data
members char WhatType() {return Type;}.
} ;
5. (a) What is the purpose of a key in a table? Give an example of a key in a table. 2
(b) Consider the following tables DRESS and MATERIAL. Write SQL
commands for the statements (i) to (iv) and give outputs for SQL queries (v)
to(viii). 6
332
Table: DRESS
Table: MATERIAL
MCODE TYPE
MOOl TERELENE
MOO2 COTTON
MOO4 POLYESTER
MOO3 SILK
(i) To display DCODE and DESCRIPTION of each dress in ascending
order of DCODE.
(ii) TodisplaythedetailsofallthedresseswhichhaveLAUNCHDATEin
between 05-DEC-07 and 20-JUN-08 (inclusive of both the dates).
(iii) To display the average PRICE of all the dresses which are made up of
material with MCODE as M003.
(iv) TodisplaymaterialwisehighestandlowestpriceofdressesfromDRESS
table. (Display MCODE of each dress along with highest and lowest
price)
333
(v) SELECTSUM(PRICE)FROMDRESSWHEREMCODE=‘M001’;
(vi) SELECT DESCRIPTION, TYPE FROM DRESS, MATERIAL
WHERE DRESS.DCODE = MATERIAL.MCODE AND
DRESS.PRICE>=l250;
(vii) SELECT MAX(MCODE) FROM MATERIAL;
(viii) SELECT COUNT(DISTINCT PRICE) FROM DRESS;
6. (a) Stateandverifyabsorptionlawusingtruthtable. 2
(b) WritetheequivalentBooleanExpressionforthefollowingLogicCircuit: 2
(c) Write the POS form of a Boolean function G, which is represented in a truth
tableasfollows: 1
(d) ReducethefollowingBooleanExpressionusingK-Map: 3
H(U,V,W,Z) = Σ(0, 1, 4, 5, 6, 7, 11, 12, 13, 14, 15)
334
7. (a) What is the difference between LAN andWAN? 1
(b) Expandthefollowingabbreviations: 1
(i) HTTP
(ii) ARPANET
(c) What is protocol? Which protocol is used to copy a file from/to a remotely
located server? 1
(d) Name two switching techniques used to transfer data between two terminals
(computers). 1
(e) Eduminds University of India .is starting its first campus in a small town
ParampurofCentralIndiawithitscenteradmissionofficeinDelhi.Theuniversity
has3majorbuildingscomprisingofAdminBuilding,AcademicBuildingand
Research Building in the 5 KM area Campus.
As a network expert, you need to suggest the network plan as per (E1) to
(E4) to the authorities keeping in mind the distances and other given
parameters.
ExpectedWiredistancesbetweenvariouslocations:
ResearchBuildingtoAdminBuilding 90m
ResearchBuildingtoAcademicBuilding 80m
AcademicBuildingtoAdminBuilding 15m
DelhiAdmissionOfficetoParampurCampus 1450 km
Expected number of computers to be installed at various locations in the
universityareasfollows:
335
ResearchBuilding 20
AcademicBuilding 150
AdminBuilding 35
DelhiAdmissionOffice 5
(E1) Suggest to the authorities, the cable layout amongst variousbuildings
insidetheuniversitycampusforconnectingthebuildings. 1
(E2) Suggestthemostsuitableplace(i.e.building) to house the server of this
organisation,withasuitablereason. 1
(E3) Suggestanefficientdevicefromthefollowingtobeinstalledineachof
thebuildingstoconnectallthecomputers: 1
(i) GATEWAY
(ii) MODEM
(iii) SWITCH
(E4) Suggest the most suitable (very high speed) service to provide data
connectivity betweenAdmission Building located in Delhi and the
campuslocatedinParampurfromthefollowingoptions: 1
Telephoneline
Fixed-LineDial-upconnection
Co-axial Cable Network
GSM
Leasedline
SatelliteConnection
336
Marking Scheme — Computer Science
General Instructions :
1. TheanswersgiveninthemarkingschemeareSUGGESTIVE,Examinersarerequestedto
awardmarksforallalternativecorrectSolutions/Answersconveyingthesimilarmeaning
2. All programming questions have to be answered with respect to. C++ Language only.
3. InC++,ignorecasesensitivityforidentifiers
(Variable/Functions/Structures/ClassNames)
4. In SQL related questions - both ways of text/character entries should be acceptable for
Example: “AMAR” and ‘amar’both are correct.
5. In SQL related questions - all date entries should be acceptable for Example: 'DD-Mon-
YY', "DD/MM/YY", 'DD/MM/YY", 'DD/MM/YY', "MM/DD/YY", 'MM/DD/YY', and
{MM/DD/YY} are correct.
6. InSQLrelatedquestions-semicolonshouldbeignoredforterminatingtheSQLstatements
7. InSQLrelatedquestions,ignorecasesensitivity.
QUESTION PAPER CODE 91/1
EXPECTEDANSWERS
1. (a) What is the difference between call by value and call by reference? Give an
exampleinC++toillustrateboth. 2
Ans Call by value is used to create a temporary copy of the data coming from the
actualparameterintotheformalparameter.Thechangesdoneinthefunction
informalparameterarenotreflectedbackinthecallingenvironment.Itdoes
notuse‘&’sign.
Call by reference is used to share the same memory location for actual and
formal parameters and so changes done in the function are reflected back in
thecallingenvironment.Ituses‘&’sign.
void Compute(int A, int &B)
{
A++;
B++;
337
cout<<”In the function”<<endl;
cout<<”A=”<<A<<“&”<<“B=”<<B<<endl;
}
void main ()
{
int I=50,J=25;
cout<<”Before function call “<<endl;
cout<<”I=”<<I<<”&”<<”J=”<<J <<endl;
Compute (I,J) ;
cout<<”After function call “<<endl;
cout<<I=”<<I<<”&”<<”J=”<<J <<endl;
}
OUTPUT
Before function call
I=50&J=25
In the function
A=51&B=26
After function call
I=50&J=26
(½MarkforeachcorrectexplanationofCallbyValueandCallbyReference)
(½ Mark for each correct example of Call by Value and Call by Reference)
OR
(Full 2 Marks for correct examples demonstrating the difference between
Call byValue and Call by Reference)
OR
(Only 1 Mark to be awarded if Explanation without supporting examples)
Note:Outputisoptional
(b) Writethenamesoftheheaderfilestowhichthefollowingbelong: 1
(i) puts ( ) (ii) sin ( )
338
Ans (i) stdio.h (ii) math. h
(½ Mark for writing each correct header file)
(c) Rewritethefollowingprogramafterremovingthesyntacticalerrors(ifany).
Underlineeachcorrection. 2
#include [iostream.h]
#include [stdio.h]
class Employee
{
int EmpId=901;
char EName [20] ;
public
Employee(){}
void Joining() {cin>>EmpId; gets (EName);}
void List () {cout<<EmpId<<” : “<<EName<<endl;}
};
void main ()
{
Employee E;
Joining.E();
E.List()
}
Ans #include <iostream.h>
#include <stdio.h>
class Employee
{ int EmpId;
char EName[20];
public :
Employee() {EmpId=901;}
void Joining() {cin>>EmpId; gets (EName);}
void List () {cout<<EmpId<<”: “<<EName<<endl;}
339
};
void main ()
{ Employee E;
E.Joining ();
E.List ();
}
(½ Mark for writing both header files inside < >)
(½ Mark for removing = 901 from int Empld = 901;)
(½Markforwriting:afterpublicand;afterE.List())
(½MarkforwritingE.Joining();correctly)
Note: ½markforidentifyinganytwoerrorswithoutvalidcorrectionand1
markforidentifyingallfiveerrorswithoutvalidcorrection
(d) Findtheoutputofthefollowingprogram: 3
#include<iostream.h>
void main ()
{
int X[] = {10,25,30,55,110};
int *p = X;
while ( *p < 110)
{
if ( *P%3 != 0 )
*p=*p+1;
else
*p = *p + 2;
p++;
}
for(int I = 4; I>=l ; I--)
{
cout << X[I] << “*" ;
if ( I%3 == 0) cout<<endl;
340
}
cout<<X[0] * 3<<endl;
}
Ans 1110*56*
32*26*33
(½ Mark for each correct value)
(½ Mark for all correct endl and *)
(e) Findtheoutputofthefollowingprogram: 2
#include <iostream.h>
#include <ctype.h>
void Encode (char Info [ ], int N) ;
void main ( )
{
char Memo [ ] = “Justnow” ;
Encode (Memo, 2) ;
cout<<Memo<<endl ;
}
void Encode (char Info [ ], int N)
{
for (int I = 0 ; Info[I] !=‘0’ ; 1++)
if (1%2= =0)
Info[I] = Info[I] –N ;
else if (islower(Info[I]))
Info[I] = toupper(Info[I]) ;
else
Info[I] = Info[I] +N ;
}
Ans HuqTlOu
(½ Mark for writing H, U as the first two characters)
(½ Mark for writing q, T as the next two characters)
341
(½ Mark for writing 1, O as the next two characters)
(½ Mark for writing u as the last character)
(f) Studythefollowingprogramandselectthepossibleoutputfromit: 2
#include <iostream.h>
#include <stdlib.h>
const int LIMIT = 4 ;
void main ( )
{
randomize( ) ;
int Points;
Points = 100 + random(LIMIT) ;
for (int P=Points ; P>=100 ; P– –)
cout<<P<<“#” ;
cout<<endl;
}
(i) 103#102#101#100#
(ii) 100#101#102#103#
(iii) 100#101#102#103#104#
(iv) 104#103#102#101#100#
Ans (i) 103#102#101#100#
(2 Marks for mentioning correct option)
Note: No Marks to be awarded for any other answer
2. (a) What is copy constructor? Give an example in C++ to illustrate copy con-
structor. 2
Ans A copy constructor is an overloaded constructor function in which (an)
object(s) of the same class is/are passed as a reference parameter(s). It is
used when an object’s data value is related to or is initialised using another
object’sdatavalueofthesameclass.Intheexamplebelowthevaluesofdata
342
members of object Q are dependent on the values of data members of object
P and Data members of object R dependent on Q.
//Example of Copy Constructor
class Play
{
int Count, Number;
public:
Play(); //constructor
Play(Play &);//copy constructor
void Disp();
void Change(int,int);
};
Play::Play () //constructor
{
Count=0;
Number=0;
}
Play:: Play (Play &P) //copy constructor
{
Count=P.Count+l0;
Number=P.Number+20;
}
void Play::Disp()
{
cout<<Count;
cout<<Number<<endl;
}
void Play::Change(int C,int N)
{
Count=C;
343
Number=N;
}
void main ()
{
Play P; //Call for constructor
P.Disp (); P.Change(90,80) ;
Play Q(P); //Copy constructor call
Q.Disp();
Play R=Q; //Copy constructor ca11 [same as P1ay R(Q);]
R. Disp();
}
(1 Mark for correct explanation of Copy Constructor)
(1 Mark for a valid example of Copy Constructor)
Note: Member function other than the constructors are optional
(b) Answer the questions (i) and (ii) after going through the following class:
class WORK 2
{
int WorkId;char WorkType ;
public:
-WORK ( ) //Function 1
{ cout<<”Un-Allocated”<<endl ;}
void status ( ) //Function 2
{ cout<<WorkId<<”: “<<WorkType<<endl ;}
WORK ( ) //Function 3
{ WorkId = 10; WorkType=’T’ ; }
WORK(WORK &W) //Function 4
{
WorkId=W. WorkId+12;WorkType=W. WorkType+l
}
} ;
344
(i) WhichmemberfunctionoutofFunction1,Function2,Function3andFunction
4shownintheabovedefinitionofclassWORKiscalledautomatically,when
the scope of an object gets over? Is it known as Constructor OR Destructor
OR Overloaded Function OR Copy Constructor?
Ans Function1
Destructor.
(½ Mark for naming Function 1 correctly)
(½ Mark for naming it as Destructor,
(ii) WORK W; // Statement 1
WORK Y(W); // Statement 2
WhichmemberfunctionoutofFunction1,Function2,Function3andFunction
4shownintheabovedefinitionofclassWORKwillbecalledonexecutionof
statementwrittenasstatement2?Whatisthisfunctionspecificallyknownas
out of Destructor or Copy Constructor or Default Constructor?
Ans Function4
Copy Constructor.
(½ Mark for naming Function 4 correctly)
(½ Mark for naming it as Copy Constructor)
(c) DefineaclassRESORTinC++withfollowingdescription: 4
PrivateMembers
Rno //Data member to store Room No
Name //Data member to store customer name
Charges //Data member to store per day charges
Days //Data member to store number of days of stay
COMPUTE( ) //A function to calculate’ and return Amount as
Days*Charges and if the value of Days*Charges is more than 11000
then as 1.02*Days*Charges
PublicMembers
Getinfo() //A function to enter the content Rno, Name,
//Charges and Days
345
Dispinfo() //A function to display Rno, Name, Charges,
//Days andAmount (Amount to be displayed by
//calling function COMPUTE ( ) )
Ans class RESORT
{
int Rno;
char Name [20];
float Charges;
int Days;
float COMPUTE();
public:
void Getinfo() ;
void Dispinfo();
};
void RESORT::Getinfo()
{
cin>>Rno;
gets (Name);
cin>>Charges;
cin>>Days;
}
void RESORT::Dispinfo()
{
cout<<Rno<<” “<<Name<<“ “<<Charges<<” “<<Days<<
COMPUTE()<<endl;
}
float RESORT::COMPUTE(}
{
float Amount = Charges*Days;
if (Amount>11000)
346
Amount = 1.02*Days*Charges;
return Amount;
}
(½ Mark for correct syntax for class header)
(½ Mark for correct declaration of data members)
(1 Mark for correct definition of COMPUTE ( )) .
(1 Mark for correct definition of Dispinfo( ) with proper invocation of
COMPUTEOfunction)
(1 Mark for correct definition of Getinfo( ))
NOTE: Deduct ½ Mark if COMPUTE( ) is not invoked properly inside
Dispinfo()function
(d) Answerthequestions(i)to(iv)basedonthefollowing: 4
class FaceToFace
{
char CenterCode [10] ;
public:
void Input ( ) ;
void Output ( ) ;
} ;
class Online
{
char website [50] ;
public:
void SiteIn ( ) ;
void SiteOut ( ) ;
} ;
class Training: public FaceToFace, private Online
{
long Tcode ;
float charge;
347
int period;
public:
void Register ( ) ;
void Show ( ) ;
} ;
(i) WhichtypeofInheritanceisshownintheaboveexample?
Ans MultipleInheritance
(1Markformentioningcorrectinheritancetype)
ii) WritenamesofallthememberfunctionsaccessiblefromShow()functionof
classTraining.
Ans Register()
Siteln( ). SiteOut( ).
Input( ), Output( )
(1 Mark for correct answer)
Note: No marks to be awarded for any other alternative answer
iii) WritenameofallthemembersaccessiblethroughanobjectofclassTraining.
Ans Register( ), Show( ),
Input( ), Output( )
(1 Mark for correct answer)
Note: No marks to be awarded for any other alternative answer
iv) IsthefunctionOutput()accessibleinsidethefunctionSiteOut()?Justifyyour
answer.
Ans No,functionOutput()isnotaccessibleinsidethefunctionSiteOut(),because
Output( ) is a member of class FaceToFace and SiteOut( ) is a member of
class Online. and the classes FaceToFace and Online are two independent
classes.
( ½ Mark for mentioning NOTACCESSIBLE correctly)
( ½ Mark for correct justification)
OR
(1MarkifYESissupportedwithvalidjustificationthatthefunctionInRegular()
348
is accessible inside the function InDistance( ) ONLYfor an object of the derived class OR in
contextofInheritance)
NOTE: No mark to be awarded if onlyYES is written without any justification.
3. (a) Write a function SORTPOINTS( ) in C++ to sort an array of structure Game
in descending order of Points using Bubble Sort. 3
Note:AssumethefollowingdefinitionofstructureGame
struct Game
{
long PNo; //Player Number
char PName [20] ;
long Points;
} ;
Sample content of the array (before sorting)
PNo PName Points
103 RitikaKapur 3001
104 JohnPhilip 2819
101 RaziaAbbas 3451
105 TarunKumar 2971
Sample content of the array (after sorting)
PNo PName Points
101 RaziaAbbas 3451
103 Ri tika Kapur 3001
105 TarunKumar 2971
104 JohnPhilip 2819
Ans void SORTPOINTS(Game G[], int N)
{
Game Temp;
349
for (int I = 0; I<N-l; I++)
for (int J = 0; J<N-I-l; J++)
if(G[J].Points < G[J+l].Points)
{
Temp = G[J];
G[J] = G[J+l];
G[J+l] = Temp;
}
{
OR
Anyothercorrectequivalentfunctiondefinition
( ½ Mark for correct Function Header)
( ½ Mark for each correct loop)
( 1 Mark for correct comparison of adjacent elements)
( ½ Mark for swapping the values correctly)
Note:
Deduct ½ Mark if sorted in ascending order instead of descending order
Deduct ½ Mark if only Points is swapped instead of the whole Structure
Deduct ½ Mark ifTemp is not declared with correct data type
(b) An array S[40][30]isstoredinthememoryalongthecolumnwith each of the
element occupying 4 bytes, find out the base address and address of element
S[20][15], if an element S[15][10] is stored at the memory location 7200. 4
Ans Loc(S[I][J]) = Base(S)+W(I+J*N)
Loc(S[15][10]) = Base(S)+4(15+10*40)
Base(S) = 7200-4*415
Base(S) = 7200-1660
Base(S) = 5540
Loc(S[20][15]) = Base(S)+4(20+15*40)
Loc(S[20][15]) = 5540 + 4(20+15*40)
= 5540 + 4(20+600)
350
= 5540 + 4*620
= 5540 + 2480
= 8020
OR
Address of S[i][j]=BaseAddress + W[(i-L1) + ( j - L2) *M]
Address of S[15] [10] = BaseAddress+ 4[(15–0)+(10 - 0)*40]
7200= Base Address + 4 [415]
Base Address = 7200 - 4 * 415
= 7200 - 1660
= 5540
Address of S[20][15]= 5540 + 4 [(20 - 0) + (15 - 0) x 40]
= 5540 + 4 x 620
= 5540 + 2480
= 8020
OR
Address of Sri] [j] along the column =
Base Address + W [( i - L1) + (j - L2) * M]
Address of S[15)[10] = BaseAddress + 4[(15 - 1)+(10-1) x 40]
7200= Base Address + 4 [374]
Base Address = 7200 - 4 x 374
= 7200 - 1496
= 5704
Address of 5[20)[15] = 5704 + 4 [(20 - 1) + (15 - 1) x 40]
= 5704 + 4 x 579
= 5704 + 2316
= 8020
(1Markforwritingcorrectformula(forcolumnmajor)ORsubstitutingformula
with correct values for calculating correct BaseAddress)
(1 Mark for calculating correct BasgAddress)
351
(1 Mark for writing correct formula/correct substituted values, for column
major properly, for calculatingAddress of 5[20][15])
(1 Mark for calculating correct address of 5[20][15])
(c) Write a function QUEINS( ) in C++ to insert an element in a dynamically
allocatedQueuecontainingnodesofthefollowinggivenstructure: 4
struct Node
{
int PId ; //Product Id
char Pname [20] ;
NODE *Next ;
} ;
Ans class Queue
{
Node *Front, *Rear;
public:
QUEUE() //Constructor to initia1ize Front and Rear
{
Front = NULL;
Rear = NULL;
}
void QUEINS(); //Function to insert a node
void QUEDEL(); //Function to de1.ete a node
void QUEDISP(); //Function to disp1ay nodes
~Queue(); //Destructor to de1ete a11 nodes
} ;
void Queue::QUEINS( )
{
Node *Temp;
Temp = new Node;
cin>>Temp->PId;
352
gets(Temp->Pname); //Or cin>>Temp->Pname;
//cin.get1ine(Temp->Pname);
Temp->Next = NULL;
if (Rear = = NULL)
{
Front = Temp;
Rear = Temp;
}
e1se
}
Rear->Next = Temp;
Rear = Temp;
}
}
OR
void QUEINS (Node *&Front, Node *&Rear)
{
Node *Temp = new Node;
cin>>Temp->PId;
gets (Temp->Pname); //or cin>>Temp->Pname;
//cin.get1ine(Temp->Pname);
Temp->Next = NULL;
if(Rear == NULL)
Front = Temp;
e1se
Rear -> Next = Temp;
Rear = Temp;
}
(1 Mark for creating Node dynamcally)
(½ Mark for input / assigning Pld, Pname)
353
(½ Mark for assigning NULLtoTemp->Next)
(½ Mark for checking Empty Queue)
(½ Mark for assigning Front withTemp in case of empty queue)
(½ Mark for assigning Rear ->Next withTemp when queue is not empty)
(½ Mark for assigning RearwithTemp)
(d) DefineafunctionSWAPCOL()inC++toswap(interchange)thefirstcolumn
elements with the last column elements, for a two dimensional integer array
passed as the argument of the function. 3
Example:Ifthetwodimensionalarraycontains
2 1 4 9
1 3 7 7
5 8 6 3
7 2 1 2
After swapping of the content of 1st column and last column, it should be :
9 1 4 2
7 3 7 1
3 8 6 5
2 2 1 7
Ans void SWAPCOL(int A[][100], int M, int N)
{
int Temp, I;
for(I=O; I<M; I++)
{
Temp = A [I][0] ;
A[I][0] = A[I][N-l];
A[I][N-l] = Temp;
}
}
354
OR
void SWAPCOL(int A[4][4])
{
int Temp, I;
for(I=O; I<4; I++)
{
Temp = A[I][0];
A[I][0] = A[I][3];
A[I][3] = Temp;
}
}
OR
Anyothercorrectequivalentfunctiondefinition.
(1 Mark for correct function header)
(1 Mark for correct loop)
(1Markforswappingthefirstcolumnwithlastcolumncorrectly)
(e) Convert the following infix expression to its equivalent postfix expression
showingstackcontentsfortheconversion: 2
X–Y /(Z + U) * V
Ans X - Y / (Z + U) * v
= (X - ((Y / (Z + U)) * v))
Element Scanned Stack Postfix
(
X X
- -
(
(
Y XY
/ -/
(
355
Z XYZ
+ -/+
U XYZU
) -/ XYZU+
) - XYZU+/
* -*
V XYZU+/V
) - XYZU+/V*
) XYZU+/V*-
OR
Element Scanned Stack Postfix
( (
X ( X
- (- X
Y (- XY
/ (-/ XY
( (-/( XY
Z (-/( XYZ
+ (-/(+ XYZ
U (-/(+ XYZU
) (-/ XYZU+
* (-* XYZU+/
V (-* XYZU+/V
) XYZU+/V*-
OR
Any other method for converting the given infix expression to its equivalent
postfixexpressionshowingtheStackStatus.
(½ Mark for correctly converting expression up to each operator
(1 Mark only to be given for writing correct answer without showing the
Stack Status)
4. (a) Observe the program segment given below carefully and fill in the blanks
markedasLine1andLine2usingfstreamfunctionsforperformingthere-
quired task. 1
356
#include <fstream.h>
class Stock
{
long Ino ; //Item Number
char Item [20] ;//Item Name
int Qty ; //Quantity
public:
void Get(int) ;//Function to enter the content
void show ( ) ;//Function to display the content
void Purchase (int Tqty)
{
Qty + = Tqty ;
} //Function to increment in Qty
long KnowIno ( ) {return Ino ;}
} ;
void Purchaseitem (long PINo, int PQty)
//PINo -> Ino of the item purchased
//PQty -> Number of item purchased
{
fstream File;
File.open(“ITEMS.DAT”, ios :: binarylios ::
inlios :: out);
int Pos = –1 ;
Stock S ;
while (Pos = = –1 && File.read((char*) &S, sizeof (S)))
if (S. KnowIno( ) ==PINo)
{
S. Purchase (PQty); //To update the number of Items
Pos = File.tellg ( ) -sizeof (S) ;
357
//Line 1: To place the file pointer to the required
position
_____________________________________;
//Line 2: To write the object S on to the binary
file
_____________________________________;
}
if (Pos = = –1)
cout<<“No updation done as required Ino not found..” ;
File.close ( ) ;
}
Ans Statement1:
File.seekp(Pos);
OR
File.seekp(-sizeof(A), ios:: cur);
OR
File.seekg(Pos); //Not advisable
OR
File.seekg(-sizeof (A), ios:: cur);//Not advisable
OR
Anyequivalentcorrectmethod
Statement2:
File.write((char*)&S, sizeof(S));
OR
File.write((char*)&S, sizeof(Stock));
OR
Anyequivalentcorrectmethod
(½ Mark for each correct Statement)
(b) Write a function COUNT_DO( ) in C++ to count the presence of a word
‘do’inatextfile“MEMO.TXT” 2
358
Example:
Ifthecontentofthefile“MEMO.TXT”isasfollows:
I will do it, if you
request me to do it.
It would have been done much earlier.
ThefunctionCOUNT_DO()willdisplaythefollowingmessage:
Count of -do- in file : 2
Note: In the above example, ‘do’ occurring as a part of word done is not
considered.
Ans void COUNT_DO ()
{
ifstream Fi1;
Fil.open(“MEMO.TXT”);
char Word[80];
int Count =0;
while(!Fil.eof())
{
Fil>>Word;
if (strcmp (Word, “do”) ==0)
Count++;
}
cout<<”Count of -do- in file:”<<Count;
Fil.close(); //Ignore
}
OR
void COUNT_TO ()
{
ifstream Fi1(“MEMO.TXT”);
//OR fstream Fi1;
OR ifstream Fil(“MEMO.TXT”);



359
//Fi1.open (“NOTES. TXT”, ios::in);
char. STR[10];
int c=0;
whi1e(Fi1.qet1ine(STR,10, ‘ ‘))
{
if (strcmpi (STR, “to”) =0)
c++;
}
Fi1.c1ose();//Ignore
cout<<”Count of -to- in file : “<<c<<end1;
}
OR
void COUNT_DO ()
{
ifstream Fi1;
Fil.open(“MEMO.TXT”);
char Word[80],Ch;
int Count =0, I=0;
while(Fi1.get(Ch))
{
if (Ch! = ‘ ‘)
Word[I++] = Ch;
else
{
Word[I] = ‘0’;
if (strcmp (Word, “do”) ==0)
Count++;
I=O;
}
}
OR ifstream Fil(“MEMO.TXT”);



360
cout<<”Count of -do- in file:”<<Count;
Fil.close(); //Ignore
}
OR
Anyothercorrectfunctiondefinition
(½ Mark for opening MEMO. TXT correctly)
(½ Mark for reading each word (Whichever method adopted) from the file)
(½ Mark for comparing the word with ‘do’ and incrementing counter)
(½ Mark for displaying the number of ‘do’with/without theText Message)
(c) Write a function in C++ to read and display the detail of all the users whose
statusis‘A’(i.e.Active)fromabinaryfile“USER.DAT”.Assumingthebinary
file “USER.DAT” is containing objects of class USER, which is definedas
follows: 3
class USER
{
int Uid ; //User Id
char Uname [20];//User Name
char Status; //User Type: A Active I Inactive
Public:
void Register ( ) ;//Function to enter the content
void show ( ) ; //Function to display all data
members
char Getstatus ( ) {return Status;}.
} ;
Ans void DisplayActive ()
{
USER U;
ifstream fin;
fin.open (“USER.DAT”, ios::binary);
OR
ifstream fin (“USER.DAT”, ios::binary);
361
while(fin.read((char*)&U, sizeof(U)))
{
if(U.Getstatus()==’A’)
U.show();
}
fin.close(); //Ignore
}
OR
void DisplayActive()
{
USER U;
ifstream fin;
fin.open (“USER.DAT”, ios::binary);
OR
ifstream fin (“USER.DAT”, ios::binary);
if (fin)
{
fin.read((char*)&U, sizeof(U));
while(!fin.eof())
{
if (U.Getstatus()==’A’)
U.show() ;
fin.read((char*)&U, sizeof(U))
}
fin.close(); //Ignore
}
(½ Mark for opening USER.DATcorrectly)
(½ Mark for reading each record from USER.DAT)
(½ Mark for correct loop / checking end of file)
(1 Mark for comparing value returned by Getstatus( ) with ‘A’)
(½Markfordisplayingthematchingrecord)
362
5. (a) What are candidate keys in a table? Give a suitable example of candidate
keys in a table. 2
Ans Atablemayhavemorethanonesuchattribute/groupofattributethatidentifies
a tuple uniquely, all such attribute(s) are known as Candidate Keys.
Table:Item
Ino Item Qty
I01 Pen 560
I02 Pencil 780
I04 CD 450
I09 Floppy 700
I05 Eraser 300
I03 Duster 200
(1 Mark for writing correct definition of Candidate Key)
(1Markforgivingsuitableexample)
OR
(2MarksforillustratingCandidateKeywith/withoutshowingitasapartof
aTable)
(b) Consider the following tables GARMENT and FABRIC. Write SQL
commands for the statements (i) to (iv) and give outputs for SQL queries
(v)to(viii) 6
Table: GARMENT
363
Table : FABRIC
FCODE TYPE
F04 POLYSTER
F02 COTTON
F03 SILK
F01 TERELENE
(i) TodisplayGCODEandDESCRIPTIONofeachGARMENTindescending
order of GCODE
Ans SELECT GeODE, DESCRIPTION FROM GARMENT
ORDER BY GCODE DESC;
(1 Mark for correct query)
(½ Mark for partially correct answer)
(ii) TodisplaythedetailsofalltheGARMENTs,whichhaveREADYDATEin
between 08-DEC-07 and 16-JUN-08(inclusive of both the dates).
Ans SELECT * FROM GARMENT WHERE READYDATE BETWEEN’ 08-
DEC-07’ AND , 16-JUN-08’ ;
OR
SELECT * FROM DRESS WHERE LAUNCHDATE >= ‘08-DEC-07’
AND LAUNCHDATE<=’16-JUN-08’;
(1 Mark for correct query)
(½ Mark for partially correct answer)
(iii) To displaytheaveragePRICEofalltheGARMENTs,whicharemadeupof
FABRIC with FCODE as F03.
Ans SELECT AVG (PRICE) FROM GARMENT WHERE FCODE = ‘F03’;
(1 Mark for correct query)
(½ Mark for partially correct answer)
(iv) To display FABRIC wise highest and lowest price of GARMENTs from
GARMENTtable.(DisplayFCODEofeachGARMENTalongwithhighest
and lowest price)
Ans SELECT FCODE, MAX (PRICE), MIN(PRICE) FROM GARMENT
GROUP BY FCODE;
364
(1 Mark for correct query)
(½ Mark for partially correct answer)
(v) SELECT SUM (PRICE) FROM GARMENT WHERE FCODE = ‘F01’ ;
Ans SUM (PRICE)
26:10
(½ Mark for correct output)
(vi) SELECTDESCRIPTION, TYPE FROM GARMENT, FABRICWHERE
GARMENT.FCODE = FABRIC.FCODEAND GARMENT. PRICE > =
1260 ;
Ans DESCRIPTION TYPE
INFORMAL SHIRT COTTON
INFORMAL PANT COTTON
FORMAL PANT TERELENE
(½ Mark for correct output)
(vii) SELECT MAX (FCODE) FROM FABRIC;
Ans MAX (FCODE)
F04
(½ Mark for correct output)
(viii) SELECT COUNT (DISTINCT PRICE) FROM GARMENT ;
Ans COUNT(DISTINCT PRICE)
7
(½ Mark for correct output)
6. (a) Verify X’Y+ X.Y’+ X’Y’= (X’+Y’) using truth table. 2
Ans
VERIFIED
(1 Mark for drawing the truth table with correct inputs)
(1 Mark for deriving LHS values = RHS values)
365
(b) WritetheequivalentBooleanExpressionforthefollowingLogicCircuit: 2
Ans (x+Y’) . (X’ +Z)
(2 Marks for the final expression (x+Y’). (X’ +Z))
OR
(1 Mark for any of the correct terms out of (X+Y’) or (X’ +Z) )
(c) Write the POS form of a Boolean function H, which is represented in a truth
tableasfollows: 1
Ans (A+B+C).(A’+B+C’).(A’+B’+C)
OR
H(A,B,C) = n (0, 5, 6)
(1 Mark for the correct POS form)
Note: Deduct ½ mark if wrong variable names are used
(d) ReducethefollowingBooleanExpressionusingK-Map: 3
F(P, Q, R, S) = Σ(1, 2, 3, 5,6, 7, 9, 11, 12, 13, 15)
Ans
366
F (P,Q,R,S = PQR’+R+ P’R
( ½ Mark for placing aU1 s at correct positions in K-Map)
( ½ Mark for each grouping)
(1Markforwritingfinalexpressioninreduced/minimalform)
Note: Deduct ½ mark if wrong variable names are used
7. (a) What is difference between StarTopology and BusTopology of network? 1
Ans BusTopology:Itischaracterisedbycommontransmissionmediumsharedby
all the connected hosts, managed by dedicated nodes. It offers simultaneous
flow of data and control.
StarTopology:Itischaracterisedbycentralswitchingnode(communication
controller)anduniquepath(pointtopointlink)foreachhost.Itiseasytoadd
andremoveadditionalhostsbyupgradingthecentralisednode
(1Markforcorrectdifference,eitherTextualorDiagrammatical)
OR
(½MarkforcorrectTextual/DiagrammaticalexplanationofeitherBusor
StarTopology
(b) Expandthefollowingabbreviations: 1
(i) GSM
(ii) CDMA
Ans (i) GlobalSystemforMobileCommunication
(ii) CodeDivisionMultipleAccess
( ½ Mark tor correct expansion of GSM)
( ½ Mark for correct expansion of CDMA)
367
(c) What is protocol? Which protocol is used to search information from internet
usinganinternetbrowser? 1
Ans A protocol is the set of rules for governing communication between two
communication devices. It also infers documentation, negotiations and
establishmentofrules.
Protocolusedtosearchinformationfrominternetusinganinternetbrowseris:
TCP/IP OR HTTP
(½Markforexplainingprotocolcorrectly)
(½ Mark for TCP/IP or HTTP)
(d) Name two switching techniques used to transfer data between two terminals
(computers ). 1
Ans MessageSwitchingandPacketSwitching
OR
CircuitSwitchingandMessageSwitching
OR
CircuitSwitchingandPacketSwitching
(½Markforfirstswitchingtechnique)
(½Markforsecondswitchingtechnique)
(e) Freshminds University of India is starting its first campus inAna Nagar of
South India with its center admission office in Kolkata. The university has 3
major blocks comprising of Office Block, Science Block and Commerce
Block in the 5 KM area Campus.
As a network expert, you need to suggest the network plan as per (El) to
(E4)totheauthoritieskeepinginmindthedistanceandothergivenparameters.
368
ExpectedWiredistancesbetweenvariouslocations:
Office Block to Science Block 90 m
Office Block to Commerce Block 80 m
Science Block to Commerce Block 15 m
KolkataAdmission office toAna Nagar Campus 2450 km
Expected number of Computers to be installed’ at various locations in the
Universityareasfollows:
Office Block 10
Science Block 140
Commerce Block 30
KolkataAdmission office 8
(E1) Suggest the authorities, the cable layout amongst various blocks inside
universitycampusforconnectingtheblocks. 1
Ans
(1 Mark for mentioning any valid connectivity or topology or diagram
connectingvariousblocksinsideuniversitycampus)
(E2) Suggest the most suitable place (i.e. block) to house the server of this
universitywithasuitablereason. 1
Ans ScienceBlockasitcontainsmaximumnumberofcomputere.
(½Markformentioningtheblock)
(½ Mark for correct reason)
Note: 1 mark if Commerce Block is written with valid justification eg.
Minimumwiringneeded
(E3) Suggestanefficientdevicefromthefollowingtobeinstalledineachofthe
blocks to connect all the computers: 1
(i) MODEM
369
(ii) SWITCH
(iii) GATEWAY
Ans SWITCH
( 1 Mark for correct device)
(E4) Suggest the most suitable. (very high speed) service to provide data con-
nectivity betweenAdmission Office located in Kolkata and the campus
locatedinAnaNagarfromthefollowingoptions: 1
Telephoneline
Fixed-LineDial-upconnection
Co-axial Cable Network
GSM
Leasedline
SatelliteConnection
Ans SatelliteConnection
OR
Leasedline
(1 Mark for correct service name)
QUESTION PAPER CODE 91
EXPECTEDANSWERS
1. (a) What is the difference betweenActual Parameter and Formal Parameter?
Give an example in C++ to illustrate both types of parameters. 2
Ans AparameterusedinthefunctioncallisknownasActualParameter.Itisused
to send the data to function.
AparameterusedinthefunctiondefinitionisknownasFormalParameter,It
is used to accept the data from actual parameter.
void Seventimes(int A)//A is formal parameter
{
cout<<7*A;
}
370
void main ()
{
int P=6;
Seventimes(P);//p is actual parameter
}
(½ Mark for each correct explanation of Actual Parameter and Formal
Parameter)
(½ Mark for each correct example of Actual Parameter and Formal
Parameter)
OR
(Full 2 Marks for correct examples demonstrating the difference between
Actual Parameter and Formal Parameter)
OR
(Only 1 Mark to be awarded for Explanation given without supporting
examples)
(b) Writethenamesoftheheaderfilestowhichthefollowingbelong: 1
(i) setw( )
(ii) sqrt( )
Ans (i) iomanip.h (ii) math.h
(½ Mark for writing each correct header file)
(c) Rewritethefollowingprogramafterremovingthesyntacticalerrors(ifany).
Underlineeachcorrection. 2
include <iostream.h>
include <stdio.h>
class MyStudent
{
int StudentId = 1001;
char Name [20] ;
public
MyStudent( ){ }
371
void Register ( ) {cin>>StudentId; gets (Name) ;}
void Display ( ) {cout<<StudentId<< “:” <<Name<<end1;}
} ;
void main ( )
{
MyStudent MS ;
Register.MS( ) ;
MS.Display( ) ;
}
Ans # include <iostream.h>
# include <stdio.h>
class MyStudent
{ int StudentId;
char Name[20];
public :
MyStudent() {StudentId = 1001;}
void Register(){ cin>>StudentId; gets (Name);}
void Display () {cout«StudentId<<”:“<<Name<<endl;}
};
void main ()
{
MyStudent MS;
MS. Register ();
MS. Display () ;
}
(½Markforwritingbothincludeas#include)
(½ Mark for removing = 1001 from int StudentId = 1001;)
(½Markforwriting:afterpublic)
(½ Mark for writing MS. Register ( ) ; correctly)
Note: ½ mark for identifying any two errors without valid correction and
1markforidentifyingallfiveerrorswithoutvalidcorrection
372
(d) Findtheoutputofthefollowingprogram: 3
#include<iostream.h>
void main ( )
{
int A[ ] = {10, 15, 20, 25, 30}
int *p = A;
while (*p < 30)
{
if (*p%3 ! = 0)
*p = *p + 2 ;
else
*p = *p + 1;
p++;
}
for (int J = 0; J<=4; J++)
{
cout << A[J] << “*” ;
if ( J%3 = = 0) cout<<end1;
}
Cout<<A[4] * 3<<end1;
}
Ans 12*
16*22*27*
30*90
(1 Mark for each line with correct values)
Note:
Deduct½Markifany/all‘*’missing
Deduct ½ Mark if endl is not considered at the right positions
(e) Findtheoutputofthefollowingprogram: 2
#include <iostream.h>
#include <ctype.h>
373
void Secret (char Mig[ ], int N);
void main ( )
{
char SMS[ ] = “rEPorTmE” ;
Secret{SMS,2);
cout<<SMS<<end1;
}
void Secret(char Msg[ ], int N)
{
for (int C=0; Msg[C] !=’ 0' ;C++)
if (C%2==0)
Msg[C] = Msg[C]+N;
else if (isupper(Msg[C]))
Msg[C] = tolower(Msg[C]);
else
Msg[C] = Msg[C]-N;
}
Ans teRmttoe
(½ Mark for writing t,e as the first two characters)
(½ Mark for writing R,m as the next two characters)
(½ Mark for writing t,t as the next two characters)
(½ Mark for writing o,e as the next two characters)
(f) Studythefollowingprogramandselectthepossibleoutputfromit: 2
#include <iostream.h>
#include <stdlib.h>
const int MAX=3 ;
void main ( )
{
randomize( ) ;
int Number ;
374
Number = 50 + random{MAX) ;
for (int P=Number; P>=50; P– –)
cout<<p<< “ # ” ;
cout<<endl;
}
(i) 53#52#51#50#
(ii) 50#51#52#
(iii) 50#51#
(iv) 51#50#
Ans (iv) 51#50#
(2 Marks for mentioning correct option)
Note: No Marks to be awarded for any other answer
2. (a) Whatisfunctionoverloading?GiveanexampleinC++toillustratefunction
overloading. 2
Ans Function overloading is an example of polymorphism, where the functions
havingsamenamewithdifferentsetofparametersperformdifferentoperations.
OR
Whenafunctionishavingmorethanonedefinitionanddifferentiablebythe
number/typeofparametersisknownasfunctionoverloading
Example:
void Disp() //Function 1
{
cout<<”Hello”<<endl;
}
void Disp(int N) // Function 2
{
for (int I=1;I<=N;I++)
cout<<I<<end1;
}
375
void main ()
{
int x=5;
Disp(x);//call for Function 2 - Prints numbers from 1 to 5
Disp(); //call for Function 1 - Prints Hello
}
(1MarkforcorrectdefinitionorexplanationofFunctionOverloading)
(1 Mark for a valid example of Function Overloading)
(b) Answerthequestions(i)and(ii)aftergoingthroughthefollowingclass: 2
class Job
{
int JobId;char JobType;
public:
~Job ( ) //Function 1
{ cout<< “Resigned” <<end1; }
Job ( ) //Function 2
{ JobId=10 ; JobType =‘T” ;}
void TellMe( )//Function 3
{ cout<<JobId<< “: ” <<JobType<<end1; }
Job (Job &J) //Function 4
{
JobId=J.JobId+10; JobType=J.JobType+l;
}
};
(i) WhichmemberfunctionoutofFunction1,Function2,Function3andFunction
4shownintheabovedefinitionofclassJobiscalledautomatically,whenthe
scope of an object gets over? Is it known as Constructor OR Destructor OR
Overloaded Function OR Copy Constructor?
376
Ans Function1.
Destructor.
(½Markformentioningthecorrectfunction)
( ½ Mark for identifying it as Destructor)
(ii) Job P ; //Line 1
Job Q(P) ; //Line 2
WhichmemberfunctionoutofFunction1,Function2,Function3andFunction
4 shown in the above definition of class Job will be called on execution of
statementwrittenasLine2?Whatisthisfunctionspecificallyknownasoutof
Destructor or Copy Constructor or Default Constructor?
Ans Function4.
Copy Constructor.
(½Markformentioningthecorrectfunction)
( ½ Mark for identifying it as Copy constructor)
(c) DefineaclassHOTELinC++withthefollowingdescription: 4
PrivateMembers:
Rno //Data member to store Room No
Name //Data member to store customer name
Tariff //Data member to store per day charges
NOD //Data member to store number of days of stay
CALC( ) //Afunction to calculate and returnAmount as NOD*Tariff
and if the value of NOD*Tariff is more than 10000 then as
1.05*NOD*Tariff
PublicMembers
Checkin ( ) / /Afunction to enter the content Rno, Name,
/ / Tariff and NOD
Checkout( ) / /Afunction to display Rno, Name, Tariff,
/ /NOD andAmount (Amount to be displayed by
//callingfunctionCALC())
377
Ans class HOTEL
{
int Rno;
char Name[20];
float Tariff;
int NOD;
float CALC() ;
public:
void Checkin() ;
void Checkout() ;
} ;
float HOTEL::CALC()
{
float Amount = Tariff*NOD;
if (Amount>10000)
Amount = 1.05*NOD*Tariff;
return Amount;
}
void HOTEL::Checkin()
{
cin>>Rno;
gets (Name);
cin>>Tariff;
cin>>NOD;
}
void HOTEL::Checkout()
{
cout<<Rno<<” “<<Name<<“ “<<Tariff<<” “<<NOD<<
CALC ()<<endl;
}
378
(½ Mark for correct syntax for class header)
(½ Mark for correct declaration of data members)
(1 Mark for correct definition of CALC( ))
(1 Mark for correct definition of Checkout( ) with proper invocation of
CALC()function)
(1 Mark for correct definition of Checkin())
NOTE:Deduct½MarkifCALC()isnotinvokedproperlyinsideCheckout()
function
(d) Answerthequestions(i)to(iv)basedonthefollowing: 4
class Regular
{
char SchoolCode[10];
public:
void InRegular( );
void OutRegular( );
} ;
class Distance
{
char StudyCentreCode [5] ;
public:
void InDistance( );
void OutDistance( );
} ;
class Course: public Regular, private Distance
{
char Code [ 5] ;
float Fees;
int Duration;
public:
void InCourse( );
void OutCourse( );
} ;
379
(i) WhichtypeofInheritanceisshownintheaboveexample?
Ans MultipleInheritance
(1Markformentioningcorrecttypeofinheritance)
(ii) WritenamesofallthememberfunctionsaccessiblefromOutCoursefunction
of class Course.
Ans InCourse( ),
InDistance( ), OutDistance( ),
InRegular(),OutRegular()
(1 Mark for correct answer)
Note: No marks to be awarded for any other alternative answer
(iii) Writenameofallthe.:membersaccessiblethrougbanobjectofclassCourse.
Ans InCourse( ), OutCourse( ),
InRegular(),OutRegular()
(1 Mark for correct answer)
Note: No marks to be awarded for any other alternative answer
(iv) IsthefunctionInRegular()accessibleinsidethefunctionInDistance()?Justify
youranswer.
Ans No, function InRegular( ) is not accessible inside the function InDistance( ),
because InRegular( ) is a member of class Regular and InDistance( ) is a
member of class Distance, and the classes Regular and Distance are two
independentclasses.
(½ Mark for mentioning NOTACCESSIBLE correctly)
(½ Mark for correct justification)
OR
(1 Mark if YES is supported with valid justification that the function
InRegular()isaccessibleinsidethefunctionInDistance(}ONLYforanobject
of the derived class OR in context of Inheritance}
NOTE:NomarktobeawardedifonlyYESiswrittenwithoutanyjustification.
3. (a) WriteafunctionSORTSCORE()inC++tosortanarrayofstructureExaminee
in descending order of Score using Bubble Sort. 3
380
Note:AssumethefollowingdefinitionofstructureExaminee
struct Examinee
{
long RollNo;
char Name[20] ;
float Score;
} ;
Sample Content of the array (before sorting)
Sample Content of the array (after sorting)
I
Ans void SORTSOORE (Examinee E[ ], int N)
{
Examinee Temp;
for (int I = 0; I<N-l; I++)
for (int J = 0; J<N-I-l; J++)
if(E[J].Score < E[J+l].Score)
{
381
Temp = E[J];
E[J] = E[J+l];
E[J+l] = Temp;
}
}
OR
Anyothercorrectequivalentfunctiondefinition
( ½ Mark for correct Function Header)
( ½ Mark for each correct loop)
( 1 Mark for correct comparison of adjacent elements)
( ½ Mark for swapping the values correctly)
Note:
Deduct ½ Mark if sorted in ascending order instead of descending order
Deduct ½ Mark if only Score is swapped instead of the whole Structure
Deduct ½ Mark ifTemp is not declared with correct data type
(b) An array T[50][20] is stored in the memory along the column with each of
the elements occupying 4 bytes. Find out the base address and address of
element T[30][15], if an element T[25][10] is stored at the memory location
9800. 4
Ans Loc(T[I][J]) = Base(T)+W(I+J*N)
Loc(T[25][10]) = Base(T)+4(25+10*50)
Base(T) = 9800-4*525
Base(T) = 9800-2100
Base(T) = 7700
Loc(T[30][15]) = Base(T)+4(30+15*50)
Loc(T[30][15]) = 7700 + 4(30+15*50)
= 7700 + 4(30+750)
= 7700 + 4*780
= 7700 + 3120
= 10820
382
OR
Address of T[i][j]=BaseAddress + W [(i - L1) + (j - L2) * M]
Address of T[25] [10] = BaseAddress + 4[(25 - 0)+(10 - 0)*50]
9800 = Base Address + 4 [525]
Base Address = 9800 - 4 * 525
= 9800 - 21.00
= 7700
Address of T[30][15]= 7700 + 4 [(30 - 0) + (15 - 0) x 50]
= 7700 + 4 x 780
= 7700 + 3120
= 10820
OR
Address of T[i][j] along the column =
Base Address + W [( i - L1) + (j - L2) * M]
Address of T[25][10]=BaseAddress + 4[(25 - 1) +(10 -1) x 50]
9800= Base Address + 4 [474]
Base Address = 9800 - 4 x 474
= 9800 - 1896
= 7904
Address of T[30][15] = 7904 + 4 [(30 - 1) + (15 - 1) x 50]
= 7904 + 4 x 729
= 7904 + 2916
= 10820
(1Markforwritingcorrectformula(forcolumnmajor)ORsubstitutingformula
with correct values for calculating correct BaseAddress)
(1 Mark for calculating correct BaseAddress)
(1Markforwritingcorrectformula(forcolumnmajor)ORsubstitutingformula
with correct values for calculatingAddress ofT[30][15])
(1 Mark for calculating correct address of T[30][15])
383
(c) Write a function QUEDEL( ) in C++ to display and delete an element from
a dynamically allocated Queue containing nodes of the following given
structure: 4
struct NODE
{
int Itemno;
char Itemname[20];
NODE *Link;
} ;
Ans class Queue
{
Node *Front, *Rear;
public:
QUEUE() //Constructor to initialize Front and Rear
{ Front = NULL;
Rear = NULL;
}
void QUEINS(); //Function to insert a node
void QUEDEL(); //Function to delete a node
void QUEDISP(); //Function to display nodes
~Queue(); //Destructor to delete all nodes
};
void Queue::QUEDEL( )
{
if (Front!=NULL)
{
NODE *Temp=Front;
cout<<Front->Itemno<<” “;
cout<<Front->Itemname<<”Deleted“;
Front=Front->Link;
384
delete Temp;
if (Front NULL) Rear=NULL;
}
else
cout<<”Queue Empty..”;
}
OR
void QUEDEL(Node *&Front, Node *&Rear)
{
if (Front ! =NULL)
{
NODE *Temp=Front;
cout<<Front->Itemno<<” “;
cout<<Front->Itemname<<”Deleted ”;
Front=Front->Link;
delete Temp;
if (Front == NULL) Rear=NULL;
}
else
cout<<”Queue Empty..”;
}
(1 Mark for checking Empty Queue)
(½ Mark for assigning Front toTemp)
(½ Mark for displaying the deleted Node detail(s))
(1MarkforreassigningFrontwithFront->Link)
( ½ Mark for deletingTemp)
( ½ Mark for assigning Rear with NULL if Queue becomes Empty)
(d) Define a function SWAPARR( ) in C++ to swap (interchange) the first row
elements with the last row elements, for a two dimensional integer array
passed as the argument of the function. 3
385
Example:Ifthetwodimensionalarraycontains
5 6 3 2
1 2 4 9
2 5 8 1
9 7 5 8
After swapping of the content of first row and last row, it should be as follows:
9 7 5 8
1 2 4 9
2 5 8 1
5 6 3 2
Ans void SWAPARR(int A[][100], int M, int N)
{
int Temp, Ji
for (J=0; J<N; J++)
{
Temp = A[0)[J] ;
A[0][J] = A[M-1][J];
A[M-l][J] = Temp;
}
}
OR
void SWAPARR(int A[4][4])
{
int Temp, J;
for (J=0; J<4; J++)
{
Temp = A[0][J];
A[0][J] = A[3][J];
386
A[3][J] = Temp;
}
}
OR
Anyotilercorrectequivalentfunctiondefinition
(1 Mark for correct function header)
(1 Mark for correct loop)
(1 Mark for swapping the first row with last row correctly)
(e) Convert the following infix expression to its equivalent postfix expression
showingstackcontentsfortheconversion: 2
A + B * (C – D) / E
Ans A + B * (C - D) / E
= (A+ ( (B* (C-D) ) / E) )
Element Scanned Stack Postfix
(
A A
+ +
(
(
B AB
* +*
(
C ABC
- +*-
D ABCD
) +* ABCD-
) + ABCD-*
/ +/
E ABCD-*E
) + ABCD-*E/
) ABCD-*E/+
387
OR
Element Scanned Stack Postfix
( (
A ( A
+ (+ A
B (+ AB
* (+* AB
( (+*( AB
C (+*( ABC
- (+*(- ABC
D (+*(- ABCD
) (+* ABCD-
/ (+/ ABCD-*
E (+/ ABCD-*E
) ABCD-*E/+
OR
Any other method for converting the given infix expression to its equivalent
postfixexpressionshowingtheStackStatus.
(½ Mark for correctly converting expression up to each operator)
(1 Mark only to be given for writing correct answer without showing the
Stack Status)
4. (a) Observetheprogramsegmentgivenbelowcarefullyandfilltheblanksmarked.
asLine1andLine2usingfstreamfunctionsforperformingtherequiredtask. 1
#include <fstream.h>
class Library
{
long Ano; //Ano - Accession Number of the Book
char Title[20]; //Title - Title of the Book
int Qty; //Qty - Number of Books in Library
public:
void Enter (int); //Function to enter the content
388
void Display(); //Function to display the content
void Buy(int Tqty)
{
Qty+=Tqty;
} //Function to increment in Qty
long GetAno() {return Ano;}
} ;
void BuyBook(long BANo,int BQty)
//BANo → Ano of the book purchased
//BQty → Number of books purchased
{
fstream File;
File.open(“STOCK.DAT” ,ios::binary|ios::in|ios::out);
int position=-l;
Library L;
while (Position==-l && File.read((char*)&L,sizeof(L)))
if (L. GetAno() ==BANo)
{
L.Buy(BQty); //To update the number of Books
Position = File.tellg()-sizeof(L) ;
//Line 1: To place the file pointer to the required positiol
_________________________________;
//Line 2:To write the object L on to the binary file
_________________________________;
}
if (Position==-l)
cout<< “No updation do:r{e as required Ano not found..”;
File.close();
}
Ans Statement1:
File.seekp(Position);
389
OR
File. seekp (-sizeof (L), ios::cur);
OR
File.seekg(Position); //Not advisable
OR
File.seekg(-sizeof(L), ios::cur); //Not advisable
OR
Anyequivalentcorrectmethod
Statement2:
File.write((char*)&L, sizeof(L));
OR
File.write((char*)&L, sizeof(Library));
OR
Anyequivalentcorrectmethod
(½ Mark for each correct Statement)
(b) Write a function COUNT_TO( ) in C++ to count the presence of a word ‘to’
inatextfile“NOTES.TXT”. 2
Example:
Ifthecontentofthefile“NOTES.TXT”isasfollows:
It is very important to know that
smokingisinjurioustohealth.
Let us take initiative to stop it.
ThefunctionCOUNT_TO()willdisplaythefollowingmessage:
Count of -to- in file: 3
Note: In the above example, ‘to’ occurring as a part of word stop is not
considered.
Ans void COUNT_TO ()
{
fstream Fil;
390
Fil.open (“NOTES.TXT”, ios::in);
char Word[80]; OR ifstream Fil(“NOTES.TXT”);
int Count =0;
while(!Fil.eof())
{
Fil>>Word;
if (strcmp(Word, “to”)==0)
Count++;
}
Fil.close(); //Ignore
cout<<”Count of -to- in file:”<<Count;
}
OR
void COUNT_TO ()
{
ifstream Fil(“NOTES.TXT”); OR
fstream Fil;
char STR[10]; Fil.open(“NOTES.TXT”,ios::in);
int c=0;
while (Fil.getline(STR, 10, ‘ ’))
{
if (strcmpi (STR, “to”) ==0)
c++;
}
Fil.close();//Ignore
cout<<“Count of -to- in file:”<<c<<end1;
}
OR
void COUNT_TO ()
391
{
ifstream Fil; OR ifstream Fi1(“NOTES.TXT”);
Fil.open(“NOTES.TXT”)
char Word[80],Ch;
int Count =0, I=0;
while(Fil.get(Ch))
{
if (Ch!= ‘ ‘)
Word [I++] = Ch;
else
{
Word[I] = ‘0’;
if (strcmp (Word, “to”) ==0)
Count++;
I=O;
}
}
Fil.close(); //Ignore
cout<<”Count of -to- in file: “<<Count;
}
OR
Anyothercorrectfunctiondefinitionperformingthedesiredoperation
(½ Mark for opening NOTES. TXT correctly)
(½ Mark for reading each word (Whichever method adopted) from the file)
(½Markforcomparingthewordwith‘to’andincrementingcounter)
(½Markfordisplayingthenumberof‘to’with/withouttheTextMessage)
(c) Write a function in C++ to read and display the detail of all the members
whose membership type is ‘L’or ‘M’from a binary file “CLUB.DAT”.
Assume the binary file “CLUB.DAT” contains objects of class CLUB,
whichisdefinedasfollows: 3
392
class CLUB
{
int Mno; //Member Number
char Mname [20]; //Member Name
char Type; //Member Type: L Life Member M Monthly Member G Guest
public:
void Register();//Function to enter the content
void Display(); //Function to display all data members
char WhatType() {return Type;}.
} ;
Ans void DisplayL_M()
{
CLUB C;
fstream fin;
fin. open (“CLUB.DAT”, ios::binary|ios::in);
OR
ifstream fin (“CLUB.DAT”, ios::binary);
while(fin.read((char*)&C, sizeof(C))
{
if(C.WhatType()==’L’||C.WhatType()==’M’)
C .Display ();
}
fin.close(); //Ignore
}
OR
void Disp1ayL_M ()
{
CLUB C;
fstream fin;
fin.open (“CLUB.DAT”, ios::binary | ios::in);
393
OR
ifstream fin (“CLUB.DAT”, ios::binary);
if (fin)
{
fin.read((char*)&C, sizeof(C));
while(!fin.eof())
{
if(C.WhatType()==’L’ || C.WhatType()==’M’)
C. Display();
fin.read((char*)&C, sizeof(C));
}
fin.close(); //Ignore
(½ Mark for opening CLUB.DATcorrectly)
(½ Mark for reading each record from CLUB.DAT)
(½ Mark for correct loop / checking end of file)
(1 Mark for comparing value returned byWhatType( ) with ‘L’, ‘M’)
(½Markfordisplayingthematchingrecord)
5. (a) What is the purpose of a key in a table? Give an example of a key in a table. 2
Ans Anattribute/groupofattributesinatablethatidentifieseachtupleuniquelyis
known as a Key.
OR
Any correct definition of Key / Primary Key / Candidate Key /Alternate Key
Table:Item
Ino Item Qty
I01 Pen 560
I02 Pencil 780
I04 CD 450
I09 Floppy 700
I05 Eraser 300
I03 Duster 200
394
(1Markforwritingcorrectdefinition/purposeofanyvalidKey)
(1Markforgivingsuitableexample)
OR
(2 Marks for illustrating the purpose of Key with/without showing it as a part
of a Table)
(b) Consider the following tables DRESS and MATERIAL. Write SQL
commands for the statements (i) to (iv) and give outputs for SQL queries (v)
to(viii). 6
Table: DRESS
Table: MATERIAL
MCODE TYPE
MOOl TERELENE
MOO2 COTTON
MOO4 POLYESTER
MOO3 SILK
395
(i) To display DCODE and DESCRIPTION of each dress in ascending order
of DCODE.
Ans SELECT DCODE. DESCRIPTION FROM DRESS ORDER BY DCODE ;
(1 Mark for correct query)
(½ Mark for partially correct answer) :
(ii) TodisplaythedetailsofallthedresseswhichhaveLAUNCHDATEinbetween
05-DEC’-07 and 20-JUN-08 (inclusive of both the dates).
Ans SELECT * FROM DRESS WHERE LAUNCHDATE
BETWEEN ‘05-DEC-07’ AND ’20-JUN-08’
OR
SELECT * FROM DRESS WHERE LAUNCHDATE >= ‘05-DEC-07’
AND LAUNCHDATE<= ’20-JUN-08’
(1 Mark for correct query)
(½ Mark for partially correct answer)
(iii) TodisplaytheaveragePRICEofallthedresseswhicharemadeupofmaterial
with MCODE as M003.
Ans SELECT AVG(PRICE) FROM GARMENT WHERE MCODE = ‘M003’
(1 Mark for correct query)
(½ Mark for partially correct answer)
(iv) To display materialwise highest and lowest price of dresses from DRESS
table. (Display MCODE of each dress along with highest and lowest price)
Ans SELECT MCODE, MAX(PRICE), MIN (PRICE) FROM DRESS
GROUP BY MCODE
(1 Mark for correct query)
(½ Mark for partially correct answer)
(v) SELECT SUM(PRICE) FROM DRESS WHERE MCODE=‘M001’;
Ans SUM(PRICE)
2700
(½ Mark for correct output)
(vi) SELECT DESCRIPTION, TYPE FROM DRESS, MATERIALWHERE
DRESS.DCODE = MATERIAL.MCODEAND DRESS.PRICE>=l250;
396
Ans DESCRIPTION TYPE
(NO OUTPUT)
(½ Mark for the above)
OR
(½ Mark for attempting the question)
(vii) SELECTMAX(MCODE) FROM MATERIAL;
Ans MAX (MCODE)
MOO4
(½ Mark for correct output)
(viii) SELECT COUNT(DISTINCT PRICE) FROM DRESS;
Ans COUNT(DISTINCT PRICE)
6
(½ Mark for correct output)
6. (a) Stateandverifyabsorptionlawusingtruthtable. 2
Ans AbsorptionLaw : For every X , Y ∈ B
i) X + X . Y = X
X . (X + Y) = X (by Duality)
ii) X + X’ . Y = X + Y
(i)
(ii)
(1 Mark for stating anyone of theAbsorption Laws)
(1MarkforverifyingthelawusingTruthTable)
397
(b) WritetheequivalentBooleanExpressionforthefollowingLogicCircuit: 2
Ans P.Q’ + P’.R
(2 Marks for the final expression P.Q’+P’R)
OR
(1 Mark for anyone of the correct terms out of P.Q’or P’.R)
(c) Write the POS form of a Boolean function G, which is represented in a truth
tableasfollows: 1
Ans (U+V’+W).(U+V’+W’) . (U’+V’+W)
OR
G(U,V,W) = Π (2, 3, 6)
(1 Mark for the correct POS form)
Note: Deduct ½ mark if wrong variable names are used
398
(d) ReducethefollowingBooleanExpressionusingK-Map: 3
H(U,V,W,Z) = Σ(0, 1, 4, 5, 6, 7, 11, 12, 13, 14, 15)
Ans
H(U,V,W,Z) = V + U’W’+ UWZ
(½ Mark for placing all 1s at correct positions in K-Map)
(½ Mark for each grouping)
(1Markforwritingtinalexpressioninreduced/minimalform)
Note: Deduct ½ mark if wrong variable names are used
7. (a) What is the difference between LAN andWAN? 1
Ans LAN (LocalArea Network):
Interconnects a high number of access or node points or stations within a
confined physical area.An example is the territory covered in a single office
building that houses various departments/offices. All these areas are
interconnectedusingaLAN.
WAN (WideArea Network)
Itisusedtoconnectsystemswithnolimitationofgeographicalarea.Itisused
to serve many locations distributed over a large geographical area.
Asystemofovernighttellermachinesusedbyabankingorganisationcovering
theNorthofIndiaisanexampleofaWAN.Internetisalsoanexampleofthe
same.
399
(1Markforcorrectdifference,eitherTextualorDiagrammatical)
OR
( ½ Mark each for correctTextual/Diagrammatical explanation of LAN orWAN)
(b) Expandthefollowingabbreviations: 1
(i) HTTP
(ii) ARPANET
Ans (i) HyperTextTransfer Protocol
(ii) Advanced Research ProjectsAgency Network
(½ Mark for correct expansion of HTTP)
(½ Mark for correct expansion ofARPANET)
(c) What is protocol? Which protocol is used to copy a file from/to a remotely
located server? 1
Ans A protocol is the set of rules for governing communication between two
communication devices. It also infers documentation, negotiations and
establishmentofrules.
Protocol used to copy a file fromlto a remotely located server is FTP (File
TransferProtocol)
(½Markforexplainingprotocolcorrectly)
(½ Mark for FTP)
(d) Name two switching techniques used to transfer data between two terminals
(computers). 1
Ans MessageSwitchingandPacketSwitching
OR
CircuitSwitchingandMessageSwitching
OR
CircuitSwitchingandPacketSwitching
(½Markfornamingfirstswitchingtechnique)
(½Markfornamingsecondswitchingtechnique)
(e) EdumindsUniversityofIndiaisstartingitsfirstcampusinasmalltownParampur
ofCentralIndiawithitscenteradmissionofficeinDelhi.Theuniversityhas3
400
majorbuildingscomprisingofAdminBuilding,AcademicBuildingandResearch
Building in the 5 KM area Campus.
As a network expert, you need to suggest the network plan as per (E1) to
(E4) to the authorities keeping in mind the distances and other given
parameters.
ExpectedWiredistancesbetweenvariouslocations:
ResearchBuildingtoAdminBuilding 90m
ResearchBuildingtoAcademicBuilding 80m
AcademicBuildingtoAdminBuilding 15m
DelhiAdmissionOfficetoParampurCampus 1450 km
Expected number of computers to be installed at various locations in the
universityareasfollows:
ResearchBuilding 20
AcademicBuilding 150
AdminBuilding 35
DelhiAdmissionOffice 5
(E1) Suggest to the authorities, the cable layout amongst variousbuildings
insidetheuniversitycampusforconnectingthebuildings. 1
Ans
401
(1 Mark for mentioning any valid connectivity or topology or diagram
connectingvariousbuildingsinsideuniversitycampus)
(E2) Suggestthemostsuitableplace(i.e.building) to house the server of this
organisation,withasuitablereason. 1
Ans AcademicBuildingasitcontainsmaximumnumberofcomputers.
(½Markformentioningthebuilding)
( ½ Mark for correct reason)
Note:1markifanysuitableplace/buildingissuggestedwithvalidjustification
(E3) Suggestanefficientdevicefromthefollowingtobeinstalledineachof
thebuildingstoconnectallthecomputers: 1
(i) GATEWAY
(ii) MODEM
(iii) SWITCH
Ans SWITCH
( 1 Mark for correct device)
(E4) Suggest the most suitable (very high speed) service to provide data
connectivity betweenAdmission Building located in Delhi and the
campuslocatedinParampurfromthefollowingoptions: 1
Telephoneline
Fixed-LineDial-upconnection
Co-axial Cable Network
GSM
Leasedline
SatelliteConnection
Ans SatelliteConnection
OR
Leasedline
(1 Mark for correct service name)
302
COMPUTER SCIENCE
Time allowed : 3 hours Maximum Marks : 70
Instructions:
(i) All questions are compulsory.
(ii) Programming Language: C+ +
QUESTION PAPER CODE 91/1
1. (a) What is the difference between automatic type conversion and type casting?
Also, give a suitable C++ code to illustrate both. 2
(b) WhichC++headerfile(s)willbeessentiallyrequiredtobeincludedtorun/
execute the following C++ code? 1
void main( )
{
int Eno=123, char Ename[ ]=”Rehan Swamp”;
cout<<setw(5)<<Eno<<setw(25)<<EName<<endl;
}
(c) Rewritethefollowingc++programcodeafterremovingthesyntaxerror(s)
(ifany).Underlineeachcorrection. 2
include <iostream.h>
class TRAIN
{
long TrainNo;
char Description[25];
public
void Entry ( )
{
303
cin >>TrainNo; gets(Description);
}
Void Display ( )
{
cout<<TrainNo<<“:”<<Description<<endl;
}
};
void main( )
{
TRAIN T;
Entry. T( ); Display. T( );
}
(d) Findtheoutputofthefollowingprogram: 3
#inc1ude <iostream.h>
struct POINT
{int X, Y, Z;};
void StepIn(POINT & P, int Step=1)
{
P.X+=Step;
P.Y -=Step;
P.Z+=Step;
}
void StepOut(POINT & P, int Step=1)
{
P.X-=Step;
P.Y+=Step;
P.Z–=Step;
304
}
void main ( )
{
POINT P1={15, 25, 5}, P2={10, 30, 20};
StepIn(P1);
StepOut(P2,4);
cout<<P1.X<<“,”<<P1.Y<<“,”<<P1.Z<<endl;
cout<<P2.X<<“,”<<P2.Y<<“,”<<P2.Z<<endl;
StepIn(P2,12);
cout<<P2.X<<“,”<<P2.Y<<“,”<<P2.Z<<endl;
}
(e) Findtheoutputofthefollowingprogram: 2
#include <iostream.h>
#include <ctype.h>
void ChangeIt(char Text[ ], char C)
{
for (int K=0;Text[K]!='0';K++)
{
if (Text[K]>=’F’ && Text[K]<=’L’)
Text[K]=tolower(Text[K]);
else
if (Text[K]=’E’ || Text[K]==’e’)
Text[K]= =C;
else
if (K%2==O)
Text[K]=toupper(Text[K]);
else
305
Text[K]=Text[K-l];
}
}
void main ( )
{
char OldText[ ]=”pOwERALone”;
ChangeIt(OldText,’%’);
cout<<“New TEXT:”<<OldText<<endl;
}
(f) Thefollowingcodeisfromagame,whichgeneratesasetof4randomnumbers.
Yallavisplayingthisgame,helphimtoidentifythecorrectoption(s)outofthe
fourchoicesgivenbelowasthepossiblesetofsuchnumbersgeneratedfrom
the program code so that he wins the game. Justify your answer. 2
#include <iostream.h>
#include <stdlib.h>
const int LOW=15;
void main ( )
{
randomize( ) ;
int POINT=5, Number;
for (int 1=1;I<=4;I++)
{
Number=LOW+random(POINT) ;
cout<<Number<<“:” ;
POINT--;
}
}
306
(i) 19:16:15:18:
(ii) 14:18:15:16:
(iii) 19:16:14:18:
(iv) 19:16:15:16:
2. (a) What do you understand by Polymorphism.?Also, give an example in C++
toillustratethesame. . 2
(b) Answerthequestions(i)and(ii)aftergoingthroughthefollowingclass: 2
class TEST
{
int Regno, Max, Min, Score;
public:
TEST() //Function 1
{
Regno= 101;Max=100;Min=40;Score=75;
}
TEST(int Pregno,int Pscore) //Function 2
{
Regno=Pregno;Max=100;Min=40;Score=Pscore;
}
~TEST() //Function 3
{
cout<<“TEST Over”<<endl;
}
void Display() //Function 4
{
cout<<Regno<<“:”<<Max<<“:”<<Min<<endl;
cout<<“[Score]”<<Score<<endl;
}
};
307
(i) As per Object Oriented Programming, which. concept is illustrated by
Function 1 and Function 2 together?
(ii) WhatisFunction3specificallyreferredas?Whendoyouthink,Function3
willbeinvoked/called?
(c) DefineaclassITEMinC++withfollowingdescription: 4
PrivateMembers
Code of type integer (Item Code)
Inameoftypestring(ItemName)
Price of type float (Price of each item)
Qtyoftypeinteger(Quantityof iteminstock)
Offer of type float (Offer percentage on the item)
AmemberfunctionGetOffer()tocalculateOfferpercentageasperthe
followingrule:
If Qty<=50 Offer is 0
If 50<Qty<=100 Offer is 5
If Qty>100 Offer is 10
PublicMembers
A function GetStock() to allow user to enter values for Code, Iname,
Price,QtyandcallfunctionGetOffer()tocalculatetheoffer
AfunctionShowItem()toallowusertoviewthecontentofallthedata
members
(d) Answerthequestions(i)to(iv)basedonthefollowing: 4
classChairperson
{
long CID; //Chairperson Identification Number
char CName[20];
protected:
char Description [40];
void Allocate();
308
public:
Chairperson();
void Assign();
void Show();
};
class Director
{
int DID; //Director ID
char Dname[20];
protected:
char Profile[30];
public:
Director();
void Input();
void output();
};
class Company: private Chairperson, public Director
{
int CID; //Company ID
char City[20], Country[20];
public:
Company();
void Enter();
void Display();
};
(i) Whichtypeofinheritanceoutofthefollowingisspecificallyisillustratedin
the above C++ code?
309
(a) SingleLevelInheritance
(b) MultiLevelInheritance
(c) MultipleInheritance
(ii) Write the names of data members, which are accessible by objects of class
typeCompany.
(iii) Write the names of all member functions, which are accessible by objects of
class type Company.
(iv) Writethenamesofallmembers,whichareaccessiblefrommemberfunctions
of class Director.
3. (a) Write a function CHANGEO in C++, which accepts an array of integer and
its size as parameters and divide all those array elements by 7 which are
divisibleby7andmultiplyother-arrayelementsby3. 3
Sample Input Data of the array
ContentofthearrayafterCalling CHANGE()function
(b) An arrayP[50][60]isstoredinthememoryalongthecolumnwitheach of the
elementoccupying2bytes,findoutthememorylocationfortheelementP[10]
[20], if the BaseAddress of the array is 6800. 3
(c) Write a completeprograminc++toimplement a dynamically allocated Stack
containingnamesofCountries. 4
(d) Write a function int SKIPSUM(intA[ ] [3], int N,int M) in C++ to find and
return the sum of elements from all alternate elements of a two-dimensional
arraystartingfromA[0][0]. 2
Hint:
Ifthefollowingisthecontentofthearray
310
The function SKIPSUM() should add elementsA[0][0],A[0][2],A[1][l],
A[2][0] andA[2][2].
(e) Evaluatethefollowingpostfixnotationofexpression: 2
(Show status of Stack after each operation)
False, True, NOT, OR, True, False,AND, OR
4. (a) Observetheprogramsegmentgivenbelowcarefullyandfilltheblanks mar-
ked as Statement 1 and Statement 2 using tellg() and seekp() functions for
performingtherequiredtask. 1
#include <fstream.h>
class Client
{
long Cno; char Name[20], Email[30] ;
public:
//Function to allow user to enter the Cno, Name,
Email
void Enter() ;
//Function to allow user to enter (modify) Email
void Modify() ;
long ReturnCno() {return Cno;}
};
void ChangeEmail()
{ Client C;
fstream F;
311
F.open (“INFO.DAT”,ios::binary|ios::in|ios::out);
long Cnoc;//Client’s no. whose Email needs to be
changed
cin>>Cnoc;
while (F.read((char*)&C, sizeof(C)))
{
if (Cnoc= =C.ReturnCno())
{
C.Modify();
//Statement 1
int Pos = __________//To find 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));
}
}
F.close();
}
(b) Write a function in C++ to count the words “this” and “these” present in a
textfile“ARTICLE.TXT”. 2
[Note that the words “this” and “these” are complete words]
(c) Write a function in C++ to search and display details of all flights, whose
destination is“Mumbai”fromabinary file “FLIGHT.DAT”.Assuming the
binaryfileiscontainingtheobjectsofthefollowingclass. 3
312
class FLIGHT
{
int Fno; //Flight Number
char From[20]; //Flight Starting Point
char To[20]; //Flight Destination
public:
char* GetFrom() {return From;}
char* GetTo() {return To;}
void Enter() {cin>>Fno;gets(From);gets(To);}
void Display(){cout<<Fno<<“:”<<From<<“:”<<To<<endl;}
};
5. (a) What do you understand by Candidate Keys in a table? Give a suitable
exampleofCandidateKeysfromatablecontainingsomemeaningfuldata. 2
(b) Consider the following tables STORE and SUPPLIERS
and answer (bl) and (b2) parts of this question:
Table:STORE
313
Table:SUPPLIERS
(b1) WriteSQLcommandsforthefollowingstatements: 4
(i) TodisplaydetailsofalltheitemsintheStoretableinascendingorderof
LastBuy.
(ii) To display ItemNo and Item name of those items from Store table
whose Rate is more than 15 Rupees.
(iii) To display the details of those items whose Supplier code (Scode) is
22 or Quantity in Store (Qty) is more than 110 from the table Store.
(iv) TodisplayMinimumRateofitemsforeachSupplierindividuallyasper
Scode from the table Store.
(b2) GivetheoutputofthefollowingSQLqueries: 2
(i) SELECT COUNT(DISTINCT Scode) FROM Store;
(ii) SELECT Rate*Qty FROM Store WHERE ItemNo=2004;
(iii) SELECT Item,Sname FROM Store S, Suppliers P
WHERE S.Scode=P.ScodeAND ItemNo=2006;
(iv) SELECT MAX(LastBuy) FROM Store;
6. (a) Verifythefollowingalgebraically. 2
(A’+B’).(A+B)=A’.B+A.B’
(b) WritetheequivalentBooleanExpressionforthefollowingLogiccircuit: 2
314
(c) Write the POS form of a Boolean function H, which is represented in a truth
tableasfollows: 1
(d) ReducethefollowingBooleanExpressionusingK-Map: 3
F (U, V, W, Z) = Σ (3, 5, 7, 10, 11, 13, 15)
7. (a) What was the role ofARPANET in the Computer Network? 1
(b) Whichofthefollowingisnotanunitfordatatransferrate? 1
(i) bps
(ii) abps
(iii) gbps
(iv) kbps
(c) WhatisthedifferencebetweenTrojanHorseandVirusintermsofcomputers? 1
(d) What term we use for a software/hardware device, which is used to block,
unauthorizedaccesswhilepermittingauthorizedcommunications.Thistermis
also used for a device or set of devices configured to permit, deny, encrypt,
decrypt,orproxyall(inandout)computertrafficbetweendifferentsecurity
domains based upon a set of rules and other criteria. 1
(e) “LearnTogether” is an educational NGO. It is setting up its new campus at
Jabalpurforitswebbasedactivities.Thecampushas4compoundsasshown
inthediagrambelow: 4
315
Center to center distances between various Compounds as per architectural
drawings(inMetre)isasfollows:
Expected Number of Computers in each Compound is as follows :
(e1) Suggest a cable layout of connections between the compounds.
(e2) Suggest the most suitable place (i.e. compound) to house the server
for this NGO.Also, provide a suitable reason for your suggestion.
(e3) Suggesttheplacementofthefollowingdeviceswithjustification:
316
(i) Repeater
(ii) Hub/Switch
(e4) The NGO is planning to connect its International office situated in
Mumbai,whichoutofthefollowingwiredcommunicationlink,youwill
suggestforaveryhighspeedconnectivity?
(i) TelephoneAnalogLine
(ii) OpticalFiber
(iii) EthernetCable
(f) Writethefullformsofthefollowing: 1
(f1) GNU
(f2) XML
(g) Write one advantage of each for Open Source Software and Proprietary
Software. 1
QUESTION PAPER CODE 91
1. (a) What is the difference between call by value and call by reference?Also,
give a suitable C++ code to illustrate both. 2
(b) WhichC++headerfile(s)willbeessentiallyrequiredtobeincludedtorun/
executethefollowingC++code: 1
void main()
{
int Rno=24; char Name[] =”Amen Singhania”;
cout<<setw(lO)<<Rno<<setw(20)<<Name<<endl;
}
(c) RewritethefollowingC++programcodeafterremovingthesyntaxerror(s)
(ifany).Underlineeachcorrection. 2
include <iostream.h>
class FLIGHT
{
317
long FlightCode;
char Description[25];
public
void AddInfo()
{
cin>>FlightCode; gets (Description) ;
{
void ShowInfo()
(
cout<<FlightCode<<“:”<<Description<<endl;
}
} ;
void main()
{
FLIGHT F;
AddInfo.F(); ShowInfo.F();
}
(d) Findtheoutputofthefollowingprogram: 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;
318
}
void MoveOut(THREE_D &T, int Step=l)
{
T.X-=Step;
T.Y+=Step;
T.Z-=Step;
}
void main ()
{
THREE_D Tl={lO,20,5},T2={30,lO,40};
MoveIn(T1);
MoveOut(T2,5);
cout<<Tl.X<<“,”<<Tl.Y<<“,”<<T1.Z<<endl;
cout<<T2.X<<“,”<<T2.Y<<“,”<<T2.Z<<endl;
MoveIn(T2,l0);
cout<<T2.X<<“,”<<T2.y<<“,”<<T2.Z<<endl;
}
(e) Find.theoutputofthefollowingprogram: 2
#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]);
319
else
if (Msg[Cnt]==’A’|| Msg[Cnt]==’a’)
Msg[Cnt]=CH;
else
if (Cnt%2==0)
Msg[Cnt]=toupper(Msg[Cnt]);
else
Msg[Cnt]=Msg[Cnt-l];
}
}
void main ()
{
char MyText [] =” ApEACeDriVE”;
MyCode(MyText,’@’);
cout<<“NEW TEXT:”<<MyText<<endl;
}
(f) Thefollowingcodeisfromagame,whichgeneratesasetof4randomnumbers.
Prafulisplayingthisgame,helphimtoidentifythecorrectoption(s)outofthe
fourchoicesgivenbelowasthepossiblesetofsuchnumbersgeneratedfrom
the program code so that he wins the game. Justify your answer. 2
#include <iostream.h>
#include <stdlib.h>
const int LOW=25;
void main ()
{
randomize();
int P01NT=5,Number;
for (int I=1;I<=4;I++)
320
{
Number=LOW+random(POINT);
Cout<<Number<<“:”;
P0INT--;
}
}
(i) 29:26:25:28:
(ii) 24:28:25:26:
(iii) 29:26:24:28:
(iv) 29:26:25:26:
2. (a) What do you understand by Data Encapsulation and Data Hiding ?’Also,
giveanexampleinC++toillustrateboth. 2
(b) Answerthequestions(i)and(ii)aftergoingthroughthefollowingclass: 2
class Exam
{
int Rno,MaxMarks,MinMarks,Marks;
public:
Exam() //Module 1
{
Rno=101;MaxMarks=l00;MinMarks=40;Marks=75;
}
Exam(int Prno, int Pmarks) //Module 2
{
Rno=Prno;MaxMarks=l00;MinMarks=40;Marks=Pmarks;
}
~Exam() //Module 3
321
{
cout<<“Exam Over”<<endl;
}
void Show () //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?
(ii) What is Module 3 referred as ? When do you think, Module 3 will be
invoked/called?
(c) DefineaclassSTOCKinC++withfollowingdescription: 4
PrivateMembers
ICode of type integer (Item Code)
Item of type string (Item Name)
Price of type float (Price of each item)
Qty of type integer (Quantity in stock)
Discountoftypefloat(Discountpercentageontheitem)
AmemberfunctionFindDisc()tocalculatediscountasperthefollowing
rule:
If Qty<=50 Discountis0
If 50<Qty<=100 Discountis5
If Qty>100 Discountis10
PublicMembers
A function Buy() to allow user to enter values for ICode, Item, Price,
QtyandcallfunctionFindDisc()tocalculatetheDiscount.
322
A function ShowAll( ) to allow user to view the content of all the data
members.
(d) Answerthequestions(i)to(iv)basedonthefollowing: 4
class Director
{
long DID; //Director Identification Number
char Name[20];
protected:
char Description[40];
void Allocate();
public:
Director();
void Assign();
void Show();
} ;
class Ractory:public Director
}
int FID; //Factory ID
char Address[20];
protected:
int NOE; //No. of Employees
public:
Factory();
void Input();
void Output();
};
class ShowRoom:private Factory
323
{
int SID; //Showroom ID
char City[20];
public:
ShowRoom();
void Enter();
void Display();
};
(i) Whichtypeofinheritanceoutofthefollowingisillustratedintheabove
C++ code?
(a) SingleLevelInheritance
(b) MultiLevelInheritance
(c) MultipleInheritance
(ii) Write the names of data members, which are accessible by objects of
class type ShowRoom.
(iii) Writethenamesofallmemberfunctionswhichareaccessiblebyobjects
of class type ShowRoom.
(iv) Write the names of all members, which are accessible from member
functionsofclassFactory.
3. (a) Write a function REASSIGNO in C++, which accepts an array of integers
and its size as parameters and divide all those array elements by 5 which are
divisibleby5andmultiplyotherarrayelementsby2. 3
Sample Input Data of the array
ContentofthearrayaftercallingREASSIGNOfunction
324
(b) An array T[90][100] is stored in the memory along the column with each of
the elementsoccupying4bytes.Findoutthememorylocationfortheelement
T[10][40], if the BaseAddress of the array is 7200. 3
(c) Write a complete program in C++ to implement a dynamically allocated
QueuecontainingnamesofCities. 4
(d) Write a function intALTERSUM (int B[ ] [5], int N, int M in C++ to find
andreturnthesumofelementsfromallalternateelementsofatwo-dimensio-
nalarraystartingfromB[0][0]. 2
Hint:
Ifthefollowingisthecontentofthearray
The function should add elements B[0][0], B[0][2], B[l][l], B[2][0] and
B[2][2].
(e) Evaluatethefollowingpostfixnotationofexpression: 2
(Show status of Stack after each operation)
True, False, NOT, OR, False, True, OR,AND
4. (a) Observetheprogramsegmentgivenbelowcarefullyandfilltheblanksmar-
ked as Statement 1 and Statement 2 using tellg() and seekp() functions for
performingtherequiredtask. 1
#include <fstream.h>
class Customer
{
long Cno;char Name[20],Mobile[12];
public:
325
//Function to allow 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 (Choc==C.GetCno())
{
C.Modify ();
//Statement 1
int Pos=_____________//To find 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));
}
}
F. close () ;
}
326
(b) Write a function in C++ to count the words “to” and “the” present in a text file
“POEM.TXT”. 2
[Note that the words “to” and “the” are complete words]
(c) Write a function in C++ to search and display details. of all trains, whose
destinationis“Delhi”.fromabinaryfile“TRAIN.DAT”.Assumingthebinary
fileiscontainingtheobjectsofthefollowingclass. 3
class TRAIN
{
int 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);}
void Show(){cout<<Tno<<“:”<<From<<“:”<<To<<endl;}
};
5. (a) WhatdoyouunderstandbyPrimaryKey?GiveasuitableexampleofPrimary
Keyfromatablecontainingsomemeaningfuldata. 2
(b) Consider the following tables STOCK and DEALERS and answer (b1) and
(b2) parts of this question:
Table: STOCK
327
Table:DEALERS
(b1) WriteSQLcommandsforthefollowingstatements: 4
(i) To display details of all Items in the Stock table in ascending
order of StockDate.
(ii) To display ItemNo and Item name of those items from Stock
table whose UnitPrice is more than Rupees 10.
(iii) To displaythedetailsofthoseitemswhosedealercode(Dcode)
is 102 or Quantity in Stock (Qty) is more than 100 from the
table Stock.
(iv) TodisplayMaximumUnitPriceofitemsforeachdealerindividually
as per Dcode from the table Stock.
(b2) GivetheoutputofthefollowingSQLqueries: 2
(i) SELECT COUNT(DISTINCT Dcode) FROM Stock;
(ii) SELECT Qty*UnitPrice FROM Stock WHERE ItemNo=5006;
(iii) SELECT Item,Dname FROM Stock S, Dealers D
WHERE S.Dcode=D.DcodeAND ItemNo=5004;
(iv) SELECT MIN(StockDate) FROM Stock;
6. (a) Verifythefollowingalgebraically: 2
X’.Y + X.Y’ = (X’+Y’).(X+Y)
(b) WritetheequivalentBooleanExpressionforthefollowingLogicCircuit: 2
328
(c) Write the SOPform of a Boolean function G, which is represented in a truth
tableasfollows: 1
(d) ReducethefollowingBooleanExpressionusingK-Map: 3
F(A,B,C,D)= Σ(3,4,5,6,7,13,15)
7. (a) What was the role ofARPANET in the Computer Network? 1
(b) Whichofthefollowingisnotaunitfordatatransferrate? 1
(i) mbps
(ii) kbps
(iii) sbps
(iv) gbps
(c) What is the difference betweenVirus andWorms in the computers? 1
(d) Whattermdoweuseforasoftware/hardwaredevice,whichisusedtoblock
unauthorizedaccesswhilepermittingauthorizedcommunications?Thisterm
isalsousedforadeviceorsetofdevicesconfiguredtopermit,deny,encrypt,
decrypt,orproxyall(inandout)computertrafficbetweendifferentsecurity
domains based upon a set of rules and other criteria. 1
(e) “Vidya for All” is an educational NGO. It is setting up its new campus at
Jaipurforitsweb-basedactivities.Thecampushasfourbuildingsasshownin
thediagrambelow: 4
329
Center to center distances between various buildings as per architectural
drawings(inmeters)isasfollows:
ExpectedNumberofComputersineachBuildingisasfollows:
(el) Suggestacablelayoutofconnectionsbetweenthebuildings.
(e2) Suggest the most suitable place (i.e. building) to house the server for
this NGO.Also, provide a suitable reason for your suggestion.
(e3) Suggesttheplacementofthefollowingdeviceswithjustification:
(i) Repeater
(ii) Hub/Switch
330
(e4) TheNGOisplanningtoconnectitsInternationalofficesituatedinDelhi.
Whichoutofthefollowingwiredcommunicationlinks,willyousuggest
foraveryhighspeedconnectivity?
(i) TelephoneAnalogLine
(ii) OpticalFiber
(iii) EthernetCable
(f) Writethefullformsofthefollowing: 1
(f1) FTP
(f2) FSF
(g) Name any two common Web browsers. 1
331
Marking Scheme — Computer Science
General Instructions :
1. TheanswersgiveninthemarkingschemeareSUGGESTIVE,Examinersarerequestedto
awardmarksforallalternativecorrectSolutions/Answersconveyingthesimilarmeaning
2. All programming questions have to be answered with respect to C++ Language only.
3. InC++,ignorecasesensitivityforidentifiers
(Variable/Functions/Structures/ClassNames)
4. In SQL related questions - both ways of text/character entries should be acceptable for
Example: “AMAR” and ‘amar’both are correct.
5. In SQL related questions - all date entries should be acceptable for Example: 'DD-Mon-
YY', "DD/MM/YY", 'DD/MM/YY", 'DD/MM/YY', "MM/DD/YY", 'MM/DD/YY', and
{MM/DD/YY} are correct.
6. InSQLrelatedquestions-semicolonshouldbeignoredforterminatingtheSQLstatements
7. InSQLrelatedquestions,ignorecasesensitivity.
QUESTION PAPER CODE 91/1
EXPECTEDANSWERS
1. (a) What is the difference between automatic type conversion and type casting?
Also, give a suitable C++ code to illustrate both. 2
Ans. AutomaticTypeConversion:itisanimplicitprocessofconversionofadata
from one type to another. For example
int N = 65;
char C = N; // Automatic type conversion
cout<<C;
OUTPUT:
A
Type Casting: It is an explicit process of conversion of a data from one type
to another. For example
332
int A=1, B=2;
float C = (float)A/B; //Type Casting
cout<<C;
OUTPUT:
0.5
(½ Mark for each correct explanation ofAutomatic Type Conversion and
TypeCasting)
(½ Mark for each correct example ofAutomaticType Conversion andType
Casting)
OR
(Full2Marksforcorrectexample(s)demonstratingthemeaningof/difference
betweenAutomaticType Conversion andType Casting)
OR
(Only 1 Mack to be awarded if Explanation without supporting examples)
Note:Outputisoptional
(b) WhichC++headerfile(s)willbeessentiallyrequiredtobeincludedtorun/
execute the following C++ code? 1
void main( )
{
int Eno=123, char Ename[ ]=”Rehan Swamp”;
cout<<setw(5)<<Eno<<setw(25)<<EName<<endl;
}
Ans. (i) iostream.h (ii) iomanip.h
OR
iomanip.h - (As iostream.h is included in iomanip.h)
(½ Mark for writing each correct header file)
OR
(Full 1 Mark for mentioning only iomanip.h )
Note: Ignore any other header files, if mentioned.
333
(c) Rewritethefollowingc++programcodeafterremovingthesyntaxerror(s)
(ifany).Underlineeachcorrection. 2
include <iostream.h>
class TRAIN
{
long TrainNo;
char Description[25];
public
void Entry ( )
{
cin >>TrainNo; gets(Description);
}
Void Display ( )
{
cout<<TrainNo<<“:”<<Description<<endl;
}
};
void main( )
{
TRAIN T;
Entry. T( ); Display. T( );
}
Ans. #include<iostream.h>
#include<stdio.h>
class TRAIN
{
long TrainNo;
334
char Description [25];
public:
void Entry ()
{
cin>>TrainNo; gets (Description);
}
void Display ()
{
cout<<TrainNo<<“:”<<Description<<end1;
}
};
void main ()
{
TRAIN T;
T.Entry(); T.Display();
}
(½ Mark for writing # before include<iostream.h>
(½ Mark for writing # include <stdio.h>
(½ Mark for writing: after public)
(½ Mark for writing T.Entry(); and T.Display(); correctly)
(d) Findtheoutputofthefollowingprogram: 3
#inc1ude <iostream.h>
struct POINT
{int X, Y, Z;};
void StepIn(POINT & P, int Step=1)
{
335
P.X+=Step;
P.Y-=Step;
P.Z+=Step;
}
void StepOut(POINT & P, int Step=1)
{
P.X-=Step;
P.Y+=Step;
P.Z–=Step;
}
void main ( )
{
POINT P1={15, 25, 5}, P2={10, 30, 20};
StepIn(P1);
StepOut(P2,4);
cout<<P1.X<<“,”<<P1.Y<<“,”<<P1.Z<<endl;
cout<<P2.X<<“,”<<P2.Y<<“,”<<P2.Z<<endl;
StepIn(P2,12);
cout<<P2.X<<“,”<<P2.Y<<“,”<<P2.Z<<endl;
}
Ans. 16, 24, 6
6, 34, 16
18, 22, 28
(1 Mark for each line with -correct values)
OR
(½ Mark for any two correct values in each line)
336
Note:
Deduct (½ Mark if any/all ‘,’ missing
Deduct (½ Mark if endl is not considered at the right positions
(e) Findtheoutputofthefollowingprogram: 2
#include <iostream.h>
#include <ctype.h>
void ChangeIt(char Text[ ], char C)
{
for (int K=0;Text[K]!='0';K++)
{
if (Text[K]>=’F’ && Text[K]<=’L’)
Text[K]=tolower (Text[K]);
else
if (Text[K]=’E’ || Text[K]==’e’)
Text[K]==C;
else
if (K%2==O)
Text[K]=toupper(Text[K]);
else
Text[K]=Text[K-l];
}
}
void main ( )
{
char OldText[ ]=”pOwERALone”;
ChangeIt(OldText,’%’);
cout<<“New TEXT:”<<OldText<<endl;
}
337
Ans. New TEXT : PPW % RR11N%
(½ Mark for writing PPW as the first three characters)
(½ Mark for writing %RR as the next three characters)
(½ Mark for writing 11 as the next two characters)
(½ Mark for writing N% as the next two characters)
Note: Deduct X Mark for not mentioning New TEXT :
(f) Thefollowingcodeisfromagame,whichgeneratesasetof4randomnumbers.
Yallavisplayingthisgame,helphimtoidentifythecorrectoption(s)outofthe
fourchoicesgivenbelowasthepossiblesetofsuchnumbersgeneratedfrom
the program code so that he wins the game. Justify your answer. 2
#include <iostream.h>
#include <stdlib.h>
const int LOW=15;
void main ( )
{
randomize( ) ;
int POINT=5, Number;
for (int 1=1;I<=4;I++)
{
Number=LOW+random(POINT) ;
cout<<Number<<“:” ;
POINT--;
}
}
(i) 19:16:15:18:
(ii) 14:18:15:16:
(iii) 19:16:14:18:
(iv) 19:16:15:16:
338
Ans. (iv) 19:16:15:16:
Justificationisasfollows:
I POINT Number
Minimum Maximum
1 5 15 19
2 4 15 18
3 3 15 17
4 2 15 16
Theonlyoptionthatsatisfiesthesevaluesisoption(iv).
(1 Mark for mentioning correct option)
(1 Mark for any valid justification)
Note: Only ½ Mark to be given if only options (i) & (iv) are mentioned as correct options;
no other combination of options is acceptable;
2. (a) What do you understand by Polymorphism?Also, give an example in C++
toillustratethesame. 2
Ans. Theprocessofusingan-operatororafunctionindifferentwaysfordifferent
set of inputs given is known- as polymorphism. Function overloading is- an
exampleofpolymorphism,wherethefunctionshavingsamenamewithdifferent
set of parameters perform different operations.
Example:
void Disp ( ) //Function 1
{
cout<<“Hello”<<endl;
}
void Disp(int N) //Function 2
{
for(int I=1;I<=N;I++)
cout<<I<<endl;
}
339
void Disp (int N,int M) //Function 3
{
for (int I=N;I<=M; I++)
cout<<N<<“x”<<I<<“=”<<N*I<<endl;
}
void main ( )
{
int x=5, y=10;
Disp(x); //Function 2 called-Prints numbers from 1 to 5
Disp(x,y) ; //Function 3 called- Prints from multiples of 5
//ranging from 5 to 10
Disp () ; //Function 1 called- Prints Hello
}
(1 Mark for correct explanation of Polymorphism)
(1 Mark for a valid example of Polymorphism)
(b) Answerthequestions(i)and(ii)aftergoingthroughthefollowingclass: 2
class TEST
{
int Regno, Max, Min, Score;
public:
TEST() //Function 1
{
Regno= 101;Max=100;Min=40;Score=75;
}
TEST(int Pregno,int Pscore) //Function 2
{
Regno=Pregno;Max=100;Min=40;Score=Pscore;
}
340
~TEST() //Function 3
{
cout<<“TEST Over”<<endl;
}
void Display() //Function 4
{
cout<<Regno<<“:”<<Max<<“:”<<Min<<endl;
cout<<“[Score]”<<Score<<endl;
}
};
(i) As per Object Oriented Programming, which. concept is illustrated by
Function 1 and Function 2 together?
Ans. Polymorphism
OR
FunctionOverloading
OR
ConstructorOverloading
(1 Mark for naming the concept correctly)
(ii) WhatisFunction3specificallyreferredas?Whendoyouthink,Function3
willbeinvoked/called?
Ans. Destructor, invoked or called when scope of an Object gets over.
(½ Mark for naming Destructor correctly)
(½ Mark for mentioning correctly when it is invoked)
(c) DefineaclassITEMinC++withfollowingdescription: 4
PrivateMembers
Code of type integer (Item Code)
Inameoftypestring(ItemName)
Price of type float (Price of each item)
341
Qtyoftypeinteger(Quantityof iteminstock)
Offer of type float (Offer percentage on the item)
AmemberfunctionGetOffer()tocalculateOfferpercentageasperthe
followingrule:
If Qty<=50 Offer is 0
If 50<Qty<=100 Offer is 5
If Qty>100 Offer is 10
PublicMembers
A function GetStock() to allow user to enter values for Code, Iname,
Price,QtyandcallfunctionGetOffer()tocalculatetheoffer
AfunctionShowItem()toallowusertoviewthecontentofallthedata
members
Ans. classITEM
{
int Code;
char Iname [20] ;
floatPrice;
intQty;
floatOffer;
voidGetOffer();
public:
void GetStock ()
{
cin>>Code;
gets (Iname) ; // OR cin.getline (Iname, 80) ; OR cin>>Iname;
cin>>Price>>Qty;
GetOffer();
342
}
void ShowItern ( )
{
cout<<Code<<Iname<<Price<<Qty<<Offer;
};
voidITEM::GetOffer()
{
if(Qty<=50)
Offer = 0;
else if (Qty <=100)
Offer = 5; / /OR Offer = 0.05;
else
Offer = 10; / /OR Offer = 0.1;
}
(½ Mark for correct syntax for class header)
(½ Mark for correct declaration of data members)
(1 Mark for correct definition of GetOffer())
(1 Mark for correct definition of GetStock () with proper invocation of GetOffer()
function)
(1 Mark for correct definition of Showltem())
NOTE:
Deduct ½ Mark if GetOffer() is not invoked properly inside GetStock()function
(d) Answerthequestions(i)to(iv)basedonthefollowing: 4
classChairperson
{
long CID; //Chairperson Identification Number
char CName[20];
protected:
char Description [40];
343
void Allocate();
public:
Chairperson();
void Assign();
void Show();
};
class Director
{
int DID; //Director ID
char Dname[20];
protected:
char Profile[30];
public:
Director();
void Input();
void output();
};
class Company: private Chairperson, public Director
{
int CID; //Company ID
char City[20], Country[20];
public:
Company();
void Enter();
void Display();
};
344
(i) Whichtypeofinheritanceoutofthefollowingisspecificallyisillustratedin
the above C++ code?
(a) SingleLevelInheritance
(b) MultiLevelInheritance
(c) MultipleInheritance
Ans. (c) MultipleInheritance
(1 Mark for writing correct inheritance type)
(ii) Write the names of data members, which are accessible by objects of class
typeCompany.
Ans None
(1 Mark for writing None or No data members)
(iii) Write the names of all member functions, which are accessible by objects of
class type Company.
Ans. Enter(),Display(),Input(),output()
(1 Mark for writing correct member functions)
Note:
Both output() or Output() are acceptable as correct answer since
differentiation between small and capital O is very difficult.
No marks to be awarded for any other alternative answer
Ignore mention of Constructor(s)
(iv) Writethenamesofallmembers,whichareaccessiblefrommemberfunctions
of class Director.
Ans. Input(),output(),Profile,Dname,DID
(1 Mark for writing correct members)
Note:
Both output() or Output() are acceptable as correct answer since
differentiation between small and capital O is very difficult.
No marks to be awarded for any other alternative answer
Ignore mention of Constructor(s)
345
3. (a) Write a function CHANGEO in C++, which accepts an array of integer and
its size as parameters and divide all those array elements by 7 which are
divisibleby7andmultiplyother-arrayelementsby3. 3
Sample Input Data of the array
ContentofthearrayafterCalling CHANGE()function
Ans. void CHANGE (int A[ ], int N)
{
for(int I = 0; I<N; I++)
{
if (A[I]%7 = = 0)
A [I] = A [I] /7;
else
A[I] = A[I] * 3;
}
}
OR
Anyothercorrectequivalentfunctiondefinition
( ½ Mark for correct Function Header)
(½ Mark for correct loop)
(½ Mark for correct checking of divisibility of array elements by 7)
(½ Mark for correct else OR correct checking of non divisibility of array elements by 7)
(½ Mark for each correct assignment)
(b) An arrayP[50] [60]isstoredinthememoryalongthecolumnwitheach of the
elementoccupying2bytes,findoutthememorylocationfortheelementP[10]
[20], if the BaseAddress of the array is 6800. 3
346
Ans.Loc(P[I] [J]) = Base(P)+W(I+J*M)
i Loc(P[10][20]) = Base(P)+ 2(10+20*50)
Loc(P[10] [20]) = 68OO + 2(10+20*50)
= 6800 + 2 (10+1000)
= 6800 + 2*1010
= 6800 + 2020
= 8820
OR
Address of P[i] [j] = BaseAddress + W((i–L1)+(j–L2)*M)
Address of P[10] [20]= 6800 + 2((10-0)+(20-0)x50)
= 6800 + 2 x 1010
= 6800 + 2020
= 8820
OR
Address of P[I] [J] along the column
= BaseAddress + W((I–LBR)+(J–LBC)*M)
(where N is the number of rows, LBR = LBC = 1)
Address of P[10][20]=6800+2((10-1)+(20-l)x50)
= 6800 + 2 ( 9 + 19 x 50 )
= 6800 + 2 x 959
= 6800 + 1918
= 8718
(1 Mark for writing correct formula (for column major) OR substituting
formula with correct values for calculating Address)
(2 marks for calculating correct address)
(c) Write a completeprograminc++toimplement a dynamically allocated Stack
containingnamesofCountries. 4
347
Ans. #include<iostream.h>
#include<stdio.h>
struct Node
{
char Country [20] ;
Node *Link;
};
class Stack
{
Node *Top;
public:
Stack() {Top = NULL;}
void Push() ;
void Pop() ;
void Display() ;
~Stack () ;
};
void Stack::Push()
{
Node *Temp = new Node;
gets(Temp -> Country);
Temp -> Link = Top;
Top = Temp;
}
void Stack::Pop()
{
if (Top !=NULL)
348
{
Node *Temp = Top;
Top = Top -> Link;
delete Temp;
}
else
cout<<“stack Empty”;
}
void Stack::Display()
{
Node *Temp = Top;
while (Temp! = NULL)
{
cout<<Temp -> Country <<endl;
Temp = Temp -> Link;
}
}
Stack::~Stack ()
{
while (Top!=NULL)
{
NODE *Temp=Top;
Top=Top->Link;
delete Temp;
}
}
349
void main ( )
{
Stack ST; char Ch;
do
{
cout<<“p/O/D/Q” ;
cin>>Ch;
switch (Ch)
{
case ‘P’ : ST.Push(); break;
case ‘O’ :ST.Pop(); break;
case ‘D’ :ST.Disp();
}
} while (Ch!=’Q’);
}
(d) Write a function int SKIPSUM(intA[ ] [3], int N,int M) in C++ to find and
return the sum of elements from all alternate elements of a two-dimensional
arraystartingfromA[0][0]. 2
Hint:
Ifthefollowingisthecontentofthearray
350
The function SKIPSUM() should add elementsA[0][0],A[0][2],A[1][l],
A[2][0] andA[2][2].
Ans. int SKIPSUM(int A[ ][ 3 ], int N,int M)
{
int S=0:
for(int I = 0; 1< N; 1++)
for (int J = (I%2)?1:0; J<M; J = J+2)
S = S + A [I][J];
return S;
}
OR
int SKIPSlJM(int A[ ][3], int N, int M)
{
int S=0;
for (int I = 0; 1< N; I++)
for (int J = (I%2==0)? 0:1 ; J<M; J = J+2)
S = S + A [I][J];
return S;
}
OR
int SKIPSUM(int A[][3], int N, int M)
{
int I,J, S=O;
for (I = 0; 1 < N; 1++)
{
if (I%2) //OR (1%2 !=0 ) OR (I%2 == 1)
J = l;
351
else
J = 0;
for ( ; J<M; J = J+2)
S = S + A[I][J];
}
return S;
}
OR
int SKIPSUM(int A[][3], int N, int M)
{
int S=0, C=0;
for(int I = 0; 1< N; 1++)
for (int J = 0; J<M; J++ )
{
if (C%2 == 0)
S = S + A[I][J];
C++;
}
return S;
}
OR
int SKIPSUM(int A[][3], int N, int M)
{
int S=0, C=l;
for(int I = 0; I<N; I++)
for (int J = 0; J<M; J++ )
352
{
if (C%2 != 0)
S = S + A[I][J];
C++;
}
return S;
}
OR
int SKIPSUM (int A[][3], int N, int M)
{
int S=0;
for(int I = 0; l< N; l++)
for (int J = 0; J<M; J++ )
{
if ((I+J)%2 == 0)
S = S + A[I][J];
}
return S;
}
OR
Anyothercorrectequivalentfunctiondefinition
(½ Mark for correct function header)
(½ Mark for each correct loop)
(½ Mark for checking alternate cells)
(½ Mark for finding Sum of elements)
(½ Mark for returning the Sum)
353
(e) Evaluatethefollowingpostfixnotationofexpression: 2
(Show status of Stack after each operation)
False, True, NOT, OR, True, False,AND, OR
Ans. ElementScanned Stack
False False
True False,True
NOT False, False
OR False
True False,True
False False, True, False
and False, False
OR False
RESULT = False
OR
Step 1: Push
False
Step 2: Push
True
False
Step 3: NOT Push
Pop
Op2=True
False
False False
354
Step 4 OR Push
Pop Pop
Op2=False Op1 =False
False Op2=False
False False False
Step 5: Push
True
False
Step 6: Push
False
True
False
Step 7: AND Push
Pop Pop
Op2=False Op1=False
True Op2=False False
False False False
Step 8: OR Push
Pop Pop
Op2=False Op1=False
Op2=False
False False
Step 9: Pop
Result
False
OR
Any other method for evaluating the given postfix expression showing the
Stack Status.
(½ Mark for correctly evaluating expression up to each operator
(1 Mark only to be given for writing correct answer without showing the
Stack Status)
355
4. (a) Observetheprogramsegmentgivenbelowcarefullyandfilltheblanks mar-
ked as Statement 1 and Statement 2 using tellg() and seekp() functions for
performingtherequiredtask. 1
#include <fstream.h>
class Client
{
long Cno; char Name[20], Email[30] ;
public:
//Function to allow user to enter the Cno, Name,
Email void Enter() ;
//Function to allow user to enter (modify) Email
void Modify() ;
long ReturnCno() {return Cno;}
};
void ChangeEmail()
{ Client C;
fstream F;
F.open (“INFO.DAT”,ios::binary|ios::in|ios::out);
long Cnoc;//Client’s no. whose Email needs to be
changed cin>>Cnoc;
while (F.read((char*)&C, sizeof(C)))
{
if (Cnoc==C.ReturnCno())
{
C.Modify();
//Statement 1
int Pos = __________//To find the current
position of file pointer
356
// 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));
}
}
F.close();
}
Ans. Statement1:
F. tellg ();
Statement2:
F. seekp(Pos-sizeof(C)) ;
OR
F.seekp(-sizeof(C), ios::cur);
OR
Anyequivalentcorrectmethod
(½ Mark for each correct statement)
(b) Write a function in C++ to count the words “this” and “these” present in a
textfile“ARTICLE.TXT”. 2
[Note that the words “this” and “these” are complete words]
Ans. void COUNT ( )
{
ifstream Fil;
OR ifstream Fil(“ARTICLE.TXT”);
Fil.open(“ARTICLE.TXT”);
char Word [80]



357
int C1 = 0, C2 = 0
while (!Fil.eop())
{
Fil>>Word;
if (strcmp(Word,“this”) ==0)
Cl++;
else if (strcmp(Word,“these”) ==0)
C2++;
}
cout<<“Count of -this- in file:”<<Cl;
cout<<“Count of -these- in file:”<<C2;
OR cout<<“Count of -this- and —these- -in file:"<<Cl+C2;
Fil.close(); //gnore
}
OR
void COUNT( )
{ OR
if stream Fil(“ARTICLE.TXT”); ifstream Fil;
char Word[80] ; Fil.open(“ARTICLE. TXT”) ;
int C = 0;
while(!Fil.eof())
{ Fil>>Word;
if (strcmp(Word,“this”)==0||strcmp(Word,“these”) ==0)
C++;
}
cout<<“Count of -this- and -these- in file:"<<C;
Fil.close(); //Ignore






358
}
OR
void COUNT( )
{
ifstream Fil(“ARTICLE.TXT”);
//OR fstream Fil;
// Fil. open(“ARTICLE. TXT”, ios: : in);
char STR[l0];
int Cl=0, C2=0;
while (Fil.getline (STR,l0, ''))
{
if (strcmp(STR,“this”)==0)
Cl++;
else if (strcmp(STR,“these”)==0)
C2++;
}
}
cout<<“Count of -this- in file:”<<Cl;
cout<<“Count of -these- in file:”<<C2;
Fil.close() ;//Ignore
} OR cout<<“Count of -this- and -these- in file:”<<Cl+C2;
OR
void COUNT ( )
{
ifstream Fil;
OR ifstreamFil(“ARTICLE.TXT");
Fil. open(“ARTICLE.TXT”);
char Word[80] ,Ch;






359
int Cl =0, C2 = 0, I=O;
while(Fil.get(Ch))
{
if (Ch! = ' ')
Word[I++] = Ch;
else
{
Word[I] = ‘0’;
if (strcmp (Word,“this”)==0)
Cl++;
else if (strcmp(Word,“these”)==0)
C2++;
I=0,
}
}
cout<<“Count of -this- in file:" <<Cl;
cout<<“Count of -these- in file:" <<C2;
OR
cout<<“Count of -this- and -these- in file: “<<Cl+C2;
Fil.close(); //Ignore
}
OR
Anyothercorrectfunctiondefinition
(½ Mark for opening ARTICLE. TXT correctly)
(½ Mark for reading each word (Whichever method adopted) from the file)
(½ Mark for comparing the word with ‘this’and ‘these’and incrementing
counter(s)
(½ Mark for displaying the individual count of ‘this’ and ‘these’ or the
total count of ‘this’ and ‘these’ with/without the Text Message)



360
(c) Write a function in C++ to search and display details of all flights, whose
destination is“Mumbai”fromabinary file “FLIGHT.DAT”.Assuming the
binaryfileiscontainingtheobjectsofthefollowingclass. 3
class FLIGHT
{
int Fno; //Flight Number
char From[20]; //Flight Starting Point
char To[20]; //Flight Destination
public:
char* GetFrom() {return From;}
char* GetTo() {return To;}
void Enter() {cin>>Fno;gets(From);gets(To);}
void Display(){cout<<Fno<<“:”<<From<<“:”<<To<<endl;}
};
Ans. void Read ()
{
FLIGHT F;
ifstream fin;
fin.open(“FLIGHT.DAT”, ios::binary) ;
OR ifstream fin (“FLIGHT. DAT”, iC;s: :binary) ;
while(fin.read((char*)&F, sizeof(F)))
{
if (strcmp(F. GetTo(),“Mumbai”))
F.Display() ;
}
fin.close(); //Ignore
}
361
OR
void Read ()
{
FLIGHT F;
ifstream fin;
fin” open (“FLIGHT. DAT”, ios:: binary) ;
OR ifstream fin (“FLIGHT. DAT” , ios:: binary;
if (fin)
{
fin.read((char*)&F, sizeof (F));
while(!fin.eof())
{
if (strcmp(F. GetTo(),“Mumbai”))
F.Display();
fin.read((char*)&F,sizeof(F))
}
fin.close(); //Ignore
}
OR
Anyothercorrectfunctiondefinition
(½ Mark for opening FLIGHT DAT correctly)
(½ Mark for reading each record from FLlGHT.DAT)
(½ Mark for correct loop / checking end of file)
(1 Mark for comparing value returned by GetTo() with “Mumbai”}
(½ Mark for displaying the matching record)
5. (a) What do you understand by Candidate Keys in a table? Give a suitable
exampleofCandidateKeysfromatablecontainingsomemeaningfuldata. 2
362
Ans. A table may have more than one such attribute/group of attribute that identi-
fies a tuple uniquely, all such attribute(s) are known as Candidate Keys.
Table:Item
Ino Item Qty
I01 Pen 560
I02 Pencil 780
I04 CD 450
I09 Floppy 700
I05 Eraser 300
I03 Duster 200
(1 Mark for writing correct definition of Candidate Key)
(1 Mark for giving suitable example)
(b) Consider the following tables STORE and SUPPLIERS
and answer (bl) and (b2) parts of this question:
Table:STORE
363
Table:SUPPLIERS
(b1) WriteSQLcommandsforthefollowingstatements: 4
(i) To display details of all the items in the Store table in ascending order of
LastBuy.
Ans. SELECT * FROM STORE ORDER BY LastBuy;
(1 Mark for correct query)
(½ Mark for partially correct answer,
(ii) To display ItemNo and Item name of those items from Store table whose
Rate is more than 15 Rupees.
Ans. SELECT ItemNo, Item..In FROM STORE WHERE Rate >15;
(1 Mark for correct query)
(½ Mark for partially correct answer,
(iii) To display the details of those items whose Supplier code (Scode) is 22 or
Quantity in Store (Qty) is more than 110 from the table Store.
Ans. SELECT * FROM STORE WHERE Scode = 22 OR Qty >110;
(1 Mark for correct query)
(½ Mark for partially correct answer,
(iv) TodisplayMinimumRateofitemsforeachSupplierindividuallyasperScode
from the table Store.
Ans. SELECT Scode, MIN(Rate) FROM STORE GROUP BY Scode;
(1 Mark for correct query)
(½ Mark for partially correct answer,
(b2) GivetheoutputofthefollowingSQLqueries: 2
Note: In all output Questions ignore Column Headings
364
(i) SELECT COUNT(DISTINCT Scode) FROM Store;
Ans. COUNT(DISTINCT Scode)
(½ Mark for correct Output)
(ii) SELECT Rate*Qty FROM Store WHERE ItemNo=2004;
Ans. RATE*QTY
880
(½ Mark for correct Output)
(iii) SELECT Item,Sname FROM Store S, Suppliers P WHERE
S.Scode=P.Scode AND ItemNo=2006;
Ans. ITEM SNAME
Gel Pen Classic Premium Stationers
(½ Mark for correct Output)
(iv) SELECT MAX(LastBuy) FROM Store;
Ans. MAX (LASTBUY)
24-Feb-10
(½ Mark for correct Output)
6. (a) Verifythefollowingalgebraically. 2
(A’+B’).(A+B)=A’.B+A.B’
Ans. LHS
(A’ +B’ ) . (A+B)
= A’.A + A’.B + A.B’ + B’.B
= 0 + A’.B + A.B’+ 0
= A’.B + A.B’
= RHS (Verified)
OR
Anyothervalidalgebraicverification
(2 Marks for verifying LHS = RHS OR RHS = LHS )
365
(b) WritetheequivalentBooleanExpressionforthefollowingLogiccircuit: 2
Ans. (P + Q’) . (Q + R’)
(2 Marks for the final expression (P + Q’) . (Q + R’))
OR
(1 Mark for any of the correct terms out of (P + Q’) or (Q + R’))
(c) Write the POS form of a Boolean function H, which is represented in a truth
tableasfollows: 1
Ans. (X + Y + Z’).(X’+ Y + Z’) . (X’+ Y’+ Z)
OR
H(X,Y,Z) = Π (1, 5, 6)
(1 Mark for the correct POS form)
Note:
Deduct % mark if wrong variable names are used
366
(d) ReducethefollowingBooleanExpressionusingK-Map: 3
Ans. F(U, V, W, Z) = Σ (3, 5, 7, 10, 11, 13, 15)
U’V’ U’V UV UV’
W’ Z’ 0 4 12 8
W’ Z 1
1
5
1
13 9
W’ Z
1
3
1
7
1
15
1
11
W Z’ 2 6 14
1
10
OR
W’Z’ W’Z WZ WZ’
U’V’ 0 1
1
3 2
U’V 4
1
5
1
7 6
U V 12
1
13
1
15 14
U V’ 8 9
1
11
1
10
F(U,V,W,Z) = WZ + VZ + UV’W
(½ Mark for drawing K-Map with correct variable names)
(½ Mark for placing all 1s at correct positions in K-Map)
(½ Mark for each grouping)
(½Markforwritingfinalexpressioninreduced/minimalform)
7. (a) What was the role ofARPANET in the Computer Network? 1
Ans. ThefirstcomputernetworkwasjointlydesignedbyTheAdvanced-Research
ProjectsAgency(ARPA)andDepartmentofDefence(DoD)ofUnitedStates
in 1969 and was calledARPANET. It was an experimental project, which
connected a few computers from some of the reputed universities of USA
andDoD.ARPANETallowedaccesstocomputerresourcesharingprojects.
ThisARPANETwashandedovertoDefenceCommunicationAgency(DCA)
forfurtherdevelopment.
(1 Mark for mentioning that ARPANET was the first computer network)
OR
(½ Mark if only the expansion of ARPANET is mentioned)
367
(b) Whichofthefollowingisnotanunitfordatatransferrate? 1
(i) bps
(ii) abps
(iii) gbps
(iv) kbps
Ans. (ii)abps
(1 Mark for writing correct option)
(c) WhatisthedifferencebetweenTrojanHorseandVirusintermsofcomputers? 1
Ans. TROJAN HORSE: “Malware” computer programs presented as useful or
harmless in order to induce the user to install and run them.
VIRUS:Virusisamaliciousprogramthatdamagesdataandfilesandcauses
harmtocomputersystem.
(1 Mark for mentioning anyone valid difference)
OR
(½ Mark for correct definition of each term)
(d) What term we use for a software/hardware device, which is used to block,
unauthorizedaccesswhilepermittingauthorizedcommunications.Thistermis
also used for a device or set of devices configured to permit, deny, encrypt,
decrypt,orproxyall(inandout)computertrafficbetweendifferentsecurity
domains based upon a set of rules and other criteria. 1
Ans. Firewall
(1 Mark for writing £orrect term)
(e) “LearnTogether” is an educational NGO. It is setting up its new campus at
Jabalpurforitswebbasedactivities.Thecampushas4compoundsasshown
inthediagrambelow: 4
368
Center to center distances between various Compounds as per architectural
drawings(inMetre)isasfollows:
Expected Number of Computers in each Compound is as follows :
(e1) Suggest a cable layout of connections between the compounds. 1
Ans.
OR
369
(e2) Suggest the most suitable place (i.e. compound) to house the server for this
NGO.Also, provide a suitable reason for your suggestion. 1
Ans. TrainingCompoundasitcontainsmaximumnumberofcomputers.
(½ Mark for mentioning the correct compound)
(½ Mark for correct justification)
OR
(1 Mark for any other location with a valid justification)
(e3) Suggesttheplacementofthefollowingdeviceswithjustification: 1
(i) Repeater
(ii) Hub/Switch
Ans. (i) ARepeatershouldbeplacedwhenthedistancebetweenanytwocon-
necting compounds exceeds 70 m.
(ii) Every compound will need one Hub I Switch, to send signals to all of
the workstations connected to it
OR
Anydiagrammaticrepresentationwithvalidjustification
(½ Mark for each correct placement of Devices with valid justifications)
(e4) The NGO is planning to connect its International office situated in Mumbai,
whichoutofthefollowingwiredcommunicationlink,youwillsuggestfor
averyhighspeedconnectivity? 1
(1 Mark for mentioning any valid connectivity or topology or diagram
connecting various compounds inside the campus)
370
(i) TelephoneAnalogLine
(ii) OpticalFiber
(iii) EthernetCable
Ans. (ii) OpticalFiber
(1 Mark for correct option /answer)
(f) Writethefullformsofthefollowing: 1
(f1) GNU
(f2) XML
Ans (f1) GNU’snotUnix
(f2) eXtensibleMarkupLanguage
(½ Mark for each full form)
(g) Write one advantage of each for Open Source Software and Proprietary
Software. 1
Ans. An Open Source Software is freely and liberally licensed because of which
users have right to study, change. and improve its design and source code.
AProprietary Software has a copyright owner, who can restrict the user's
control over the software, its modification, or restrictions in publishing of
modifiedorunmodifiedversions.
(½ Mark for writing correct advantage / definition for Open Source Software)
(½ Mark for writing correct advantage / definition for Proprietary Software)
QUESTION PAPER CODE 91
EXPECTEDANSWERS
1. (a) What is the difference between call by value and call by reference?Also,
give a suitable C++ code to illustrate both. 2
Ans. Call by value: The formal parameter makes a copy of actual parameter. It
does not make the changes In actual parameter If the changes are done In
formalparameters.
Call by reference:The formal parameter Is an alias of actual parameter.The
changes made In the formal parameter are reflected In actual parameter. It is
preceded by &.
371
vcid Caloulato(int A,int & B )// A is oall by value,
{ // B is call by roforonco
A++;
a+=A;
}
(½ Mark for each corroct explanatIon of Call by va/ueand Call by referenco)
(½ Mark for each corroct examplo,of Call by value and Call by reference)
OR
(Full 2 Marks for correct examples demonstrating tho dlfferonce botween
Call by value and Call by roforonce)
OR
(Only 1 Mark to be awarded for ExplanatIon glvon without supporting examples)
(b) WhichC++headerfile(s)willbeessentiallyrequiredtobeincludedtorun/
executethefollowingC++code: 1
void main()
{
int Rno=24; char Name [] =” Amen Singhania”;
cout<<setw(lO)<<Rno<<setw(20)<<Name<<endl;
}
Ans. iostream.h
iomanip.h
OR
iomanip.h - (As iostream.h is included in iomanip.h)
(½ Mark for writing each correct header file)
OR
(Full Mark for mentioning only iomanip.h )
Note: Ignore any other header files, if mentioned.
372
(c) RewritethefollowingC++programcodeafterremovingthesyntaxerror(s)
(ifany).Underlineeachcorrection. 2
include <iostream.h>
class FLIGHT
{
long FlightCode;
char Description[25];
public
void AddInfo ( )
{
cin>>FlightCode; gets (Description) ;
{
void ShowInfo ()
(
cout<<FlightCode<<“:”<<Description<<endl;
}
} ;
void main()
{
FLIGHT F;
AddInfo.F(); ShowInfo.F();
}
Ans. #include <iostream.h> / / Error 1
#include <stdio.h> / / Error 2
class FLIGHT
{
long FlightCode;
not required if gets( ) is re-
placed with cin.getline( ) or
cin
373
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
}
(½ Mark for each correction)
OR
(1 mark for identifying at least three errors, without suggesting correction)
(d) Findtheoutputofthefollowingprogram: 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;
374
T.Z+=Step;
}
void MoveOut(THREE_D &T, int Step=l)
{
T.X-=Step;
T.Y+=Step;
T.Z-=Step;
}
void main ()
{
THREE_D Tl={lO,20,5},T2={30,lO,40};
MoveIn(T1);
MoveOut(T2,5) ;
cout<<Tl.X<<“,”<<Tl.Y<<“,”<<T1.Z<<endl;
cout<<T2.X<<“,”<<T2.Y<<“,”<<T2.Z<<endl;
MoveIn(T2,l0);
cout<<T2.X<<“,”<<T2.y<<“,”<<T2.Z<<endl;
}
Ans. 11, 19, 6
25, 15, 35
35, 5, 45
(1 Mark for each line with correct values)
OR
(½ Mark for any two correct values in each line)
Note:
Deduct ½ Mark if any/all ',' missing
Deduct ½ Mark if endl is not considered at the right positions
375
(e) Find.theoutputofthefollowingprogram: 2
#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’|| Msg[Cnt]==’a’)
Msg[Cnt]=CH;
else
if (Cnt%2==0)
Msg[Cnt]=toupper(Msg[Cnt]);
else
Msg[Cnt]=Msg[Cnt-l];
}
}
void main ()
{
char MyText [] =” ApEACeDriVE”;
MyCode(MyText,’@’);
cout<<“NEW TEXT:”<<MyText<<endl;
}
Ans. NEW TEXT :@@e@ccddIIe
(½ Mark for writing @,@,e as the first three characters)
376
(½ Mark for writing @,c,c as the next three characters)
(½ Mark for writing d,d, I as the next three characters)
(½ Mark for writing I,e as the next two characters)
Note:Deduct ½ Mark for not mentioning NEW TEXT:
(f) Thefollowingcodeisfromagame,whichgeneratesasetof4randomnumbers.
Prafulisplayingthisgame,helphimtoidentifythecorrectoption(s)outofthe
fourchoicesgivenbelowasthepossiblesetofsuchnumbersgeneratedfrom
the program code so that he wins the game. Justify your answer. 2
#include <iostream.h>
#include <stdlib.h>
const int LOW=25;
void main ()
{
randomize() ;
int P01NT=5,Number;
for (int I=1;I<=4;I++)
{
Number=LOW+random(POINT);
Cout<<Number<<“:”;
P0INT--;
}
}
(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:
Justificationisasfollows:
377
I POINT Number
Minimum Maximum
1 5 25 29
2 4 25 28
3 3 25 27
4 2 25 26
Theonlyoptionthatsatisfiesthesevaluesisoption(iv).
(1 Mark for mentioning correct option)
(1 Mark for any valid justification)
Note: Only ½ Mark to be given if only options (i) & (iv) are mentioned as
correct options; no other combination of options is acceptable;
2. (a) What do you understand by Data Encapsulation and Data Hiding ?’Also,
giveanexampleinC++toillustrateboth. 2
Ans. Data Encapsulation:Wrapping up of data and functions together in a single
unit is known as Data Encapsulation. In a class, we wrap up the data and
functionstogetherinasingleunit.
DataHidina:Keepingthedatainprivate/protectedvisibilitymodeoftheclass
to prevent it from accidental change is known as Data Hiding.
class Computer
{
char CPU[lO] ;int RNM; //Data Hiding
public: //Data Encapeulation
void STOCK();
void SHOW();
};
(½ MarkforeachcorrectexplanationofDataEncapsulationandDataHiding)
(½ Marie for each correct example of Data Encapsulation and Data Hiding)
OR
378
(2 Marks for explaining the concept of the terms through suitable examples)
OR
(Only 1 Mark to be awarded for Explanation given without any example)
(b) Answerthequestions(i)and(ii)aftergoingthroughthefollowingclass: 2
class Exam
{
int Rno,MaxMarks,MinMarks,Marks;
public:
Exam ( ) //Module 1
{
Rno=101;MaxMarks=l00;MinMarks=40;Marks=75;
}
Exam (int Prno, int Pmarks) //Module 2
{
Rno=Prno;MaxMarks=l00;MinMarks=40;Marks=Pmarks;
}
~Exam () //Module 3
{
cout<<“Exam Over”<<endl;
}
void Show () //Module 4
{
cout<<Rno<<“:”<<MaxMarks<<“:”<<MinMarks<<endl;
cout<<“[Marks Got]”<<Marks<<endl;
}
};
379
(i) As per Object Oriented Programming, which concept is illustrated by
Module 1 and Module 2 together?
Ans. Polymorphism
OR
ConstructorOverloading
OR
FunctionOverloading
(1 Mark for mentioning the correct concept)
(ii) What is Module 3 referred as ? When do you think, Module 3 will be
invoked/called?
Ans. Destructor. It is invoked as soon as the scope of the object gets over.
(½ Mark for identifying it as Destructor)
(½ Mark for mentioning correctly when it be called/invoked)
(c) DefineaclassSTOCKinC++withfollowingdescription: 4
PrivateMembers
ICode of type integer (Item Code)
Item of type string (Item Name)
Price of type float (Price of each item)
Qty of type integer (Quantity in stock)
Discountoftypefloat(Discountpercentageontheitem)
AmemberfunctionFindDisc()tocalculatediscountasperthefollowing
rule:
If Qty<=50 Discountis0
If 50<Qty<=100 Discountis5
If Qty>100 Discountis10
PublicMembers
A function Buy() to allow user to enter values for ICode, Item, Price,
QtyandcallfunctionFindDisc()tocalculatetheDiscount.
380
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();
}
void STOCK::FindDisc()
{
if (Qty<=50)
Discount=0;
else if (Qty<=100)
Discount=5; // =0.05;
else
381
Discount=10; // =0.1;
}
void STOCK::ShowAll()
{
cout<<ICode<<’t’<<Item<<’t’<<Price<<’t’<<Qty
<<’t’<<Discount<<endl;
}
(½ Mark for correct syntax for class header)
(½ Mark for correct declaration of data members)
(1 Mark for correct definition of FindDisc())
(1 Mark for correct definition of Buy() with proper invocation of
FindDisc() function)
(1 Mark for correct definition of ShowAll())
NOTE:
Deduct ½ Mark if FindDisc() is not invoked properly inside Buy() function
(d) Answerthequestions(i)to(iv)basedonthefollowing: 4
class Director
{
long DID; //Director Identification Number
char Name[20];
protected:
char Description[40];
void Allocate () ;
public:
Director() ;
void Assign () ;
void Show () ;
} ;
382
class Ractory:public Director
}
int FID; //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) WhichtypeofinheritanceoutofthefollowingisillustratedintheaboveC++
code?
(a) SingleLevelInheritance
(b) MultiLevelInheritance
(c) MultipleInheritance
Ans. (b) MultilevelInheritance
(1 Mark for mentioning correct option)
383
(ii) Write the names of data members, which are accessible by objects of class
typeShowRoom.
Ans. None
(1 Mark for correct answer)
Note: No marks to be awarded for any partial/alternative answer
(iii) Write the names of all member functions which are accessible by objects of
class type ShowRoom.
Ans. Enter(), Display()
(1 Mark for correct answer)
Note:
No marks to be awarded for any partial/alternative answer Ignore men-
tion of Constructor(s)
(iv) Writethenamesofallmembers,whichareaccessiblefrommemberfunctions
of class Factory.
Ans. FID, Address, NOE, Description,
Input(), Output(), Assign(), Show(), Allocate()
(1 Mark for correct answer)
Note:
No marks to be awarded for any partial/alternative answer Ignore men-
tion of Constructor(s)
3. (a) Write a function REASSIGNO in C++, which accepts an array of integers
and its size as parameters and divide all those array elements by 5 which are
divisibleby5andmultiplyotherarrayelementsby2. 3
Sample Input Data of the array
ContentofthearrayaftercallingREASSIGNOfunction
384
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;
}
OR
void REASSIGN(int Arr[ ],int Size)
{
for (int i=0;i<Size;i++)
Arr[i]%5 ? Arr[i]/=5 : Arr[i]*=2;
}
OR
Any other correct equivalent function definition
( ½ Mark for correct Function Header)
( ½ Mark for correct loop)
( ½ Mark for correct checking of divisibility of array elements by 5)
( ½ Mark for correct placing of else OR correct checking of non divisibil-
ity of array elements by 5)
(½ Mark for each correct assignment)
(b) An array T[90][100] is stored in the memory along the column with each of
the elementsoccupying4bytes.Findoutthememorylocationfortheelement
T[10][40], if the BaseAddress of the array is 7200. 3
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 x 90]
385
= 7200 + 4[10+3600]
= 7200 + 4 x 3610
= 7200 + 14440
= 21640
OR
Address of T[I][J] along the column
= BaseAddress + W [(I-LBR)+(J-LBC)* N]
(where N is the number of rows, LBR=LBC = 1)
Address of T[10][40]=BaseAddress + 4[ (10 - 1) +(40 - l)x 90]
= 7200+4[9 + 39 x 90]
= 7200+4[9 + 3510]
= 7200+4 x 3519
= 7200+14076
= 21276
(1 Mark for writing correct formula (for column major) OR. substituting
formula with correct values for calculating Address)
(2 marks for calculating correct address)
(c) Write a complete program in C++ to implement a dynamically allocated
QueuecontainingnamesofCities. 4
Ans. #include <iostream.h>
#include <conio.h>
struct NODE
{
char City[20];
NODE *Next;
};
class Queue
386
{
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;
if (Rear==NULL)
{
Rear=Temp;
Front=Temp;
}
else
{
Rear–>Next=Temp;
Rear=Temp;
}
387
}
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)
{
cout<<Temp->City<<endl;
Temp=Temp->Next;
}
}
Queue:: ~Queue()//Destructor Function
{
while (Front!=NULL)
{
388
NODE *Temp=Front;
Front=Front->Next; delete Temp;
}
}
void main ()
{
Queue QU; char Ch;
do
{
:
:
} while (Ch!=’Q’);
}
(4 Marks for correct program)
OR
(Full 4 Marks for correct logic of either Insertion OR Deletion functions
for Dynamically Allocated Queue.)
OR
(2 Marks for defining class with Constructor, function prototypes for
Insertion & deletion and Destructor or equivalent using Structures.)
(d) Write a function intALTERSUM (int B[ ] [5], int N, int M in C++ to find
andreturnthesumofelementsfromallalternateelementsofatwo-dimensio-
nalarraystartingfromB[0][0]. 2
Hint:Ifthefollowingisthecontentofthearray:
389
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;
}
OR
//Sample Code 2
int ALTERSUM(int B[][5],int N,int M)
{
int Sum=0,J=0;
for (int I=0;I<N;I++)
{
for (;J<M;J+=2)
Sum+=B[I][J] ;
J-=M;
}
return Sum;
}
OR
//Sample Code 3
int ALTERSUM(int B[][5],int N,int M)
390
{
int *P=&B[0][0],Sum=0;
for (int I=0;I<M*N;I+=2)
{
Sum+=(*P);
P+=2;
}
return Sum;
}
OR
//Sample Code 4
int ALTERSUM (int B[][5], int N, int M)
{
int S=0, C=0;
for(int I = 0; 1< N; 1++)
for (int J = 0; J<M; J++ )
{
if (C%2 == 0)
S = S + B[I][J];
C++;
}
return S;
}
OR
//Sample Code 5
int ALTERSUM(int B[][5],int N,int M)
{
391
int Sum=0;
for (int I=0;1<N;1++)
for (int J=0;J<M;J++)
if ((1+J)%2==0)
Sum+=B [I][J] ;
return Sum;
}
OR
//Sample Code 6
int ALTERSUM(int B[][5],int N,int M)
{
int Sum=0;
for (int I=0;1<N;1++)
for (int J=0;J<M;J++)
{
if ((1%2==0 && J%2=0)||(1%2!=0 && J%2!=0))
Sum+=B [I][J] ;
}
return Sum;
}
Note: Kindly note Sample Code 5 and 6 will not work in case of Even Di-
mensionalArrays, but keeping in view of the Sample given for 3x3 array
thesolutionisacceptable.
(½ Mark for correct loops)
(1 Mark for finding Sum of alternate cells)
(½ Mark for returning the Sum)
(e) Evaluatethefollowingpostfixnotationofexpression: 2
(Show status of Stack after each operation)
392
True, False, NOT, OR, False, True, OR, AND
Ans. ElementScanned Stack Content
True True
False True,False
NOT True,True
OR True
False True,False
True True, False,True
OR True,True
AND True
OR
Step 1: Push
True
Step 2: Push
False
True
Step 3: NOT Push
Pop
Op2=False
True
True True
Step 4 OR Push
Pop Pop
Op2=True Op1 =True
Op2=True
True True
393
Step 5: Push
False
True
Step 6: Push
True
False
True
Step 7: OR Push
Pop Pop
Op2=True Op1=False
False Op2=True True
True True True
Step 8: AND Push
Pop Pop
Op2=True Op1=True
Op2=True
True True
Step 9: Pop
Result
True
OR
Any other method for evaluating the given postfix expression showing the
Stack Status.
(½ Mark for correctly evaluating expression up to each operator)
OR
(1 Mark only to be given for writing correct answer without showing the
Stack Status)
4. (a) Observetheprogramsegmentgivenbelowcarefullyandfilltheblanksmar-
ked as Statement 1 and Statement 2 using tellg() and seekp() functions for
performingtherequiredtask. 1
394
#include <fstream.h>
class Customer
{
long Cno;char Name[20],Mobile[12];
public:
//Function to allow 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 (Choc==C.GetCno())
{
C.Modify ();
//Statement 1
int Pos=_____________//To find the current
position of file pointer
//Statement 2
_____//To move the file pointer to write the
//modified record back onto the file
395
//for the desired Cnoc
F.write((char*)&C,sizeof(C));
}
}
F. close( ) ;
}
Ans. Statement 1:
File.tellg() ;
Statement 2:
File.seekp(Pos-sizeof(C));
OR
File.seekp(-l*sizeof(C) ,ios::cur);
(½ Mark for each correct Statement)
(b) Write a function in C++ to count the words “to” and “the” present in a text file
“POEM.TXT”. 2
[Note that the words “to” and “the” are complete words]
Ans. void COUNT ()
{
ifstream Fil;
Fil. open (“POEM.TXT”); OR ifstream Fil (“POEM. TXT”);
char Word[80] ;
int Cl = 0, C2 = 0;
while(!Fil.eof())
{
Fil>>Word;
if (strcmp (Word, “to”) ==0)
Cl++;
else if (strcmp (Word, “the”) ==0)
C2++;



396
}
cout<<”Count of -to- in file:" <<Cl;
cout«”Count of -the- in file:”«C2;
OR cout<<”Count of -to- and -the- in file:”<<Cl+C2;
Fil.close(); //Ignore
}
OR
void COUNT ( )
{
ifstream Fil(“POEM.TXT”);
// OR fstream Fil;
// Fil.open(“POEM.TXT”,ios::in);
char STR[l0];
int Cl=O, C2=0;
while (Fil.getline(STR,l0,''))
{
if (strcmp (STR, “to”) ==0)
Cl++;
else if (strcmp(STR, “the”) ==0)
C2++;
}
cout<<”Count of -to- in file:”<<Cl;
cout<<”Count of -the- in file:”<<C2;
OR cout<<”Count of -to- and -the- in file:”<<Cl+C2;
Fil.close(); //Ignore
}






397
OR
void COUNT()
{
ifstream Fil;
OR ifstream Fill(“POEM.TXT”);
Fil. open (“POEM.TXT”);
char Word[BO], Chi
int Cl =0, C2=0, 1=0;
while(Fil.get(Ch))
{
if (Ch! = ‘ ‘)
Word[1++] = Chi
else
{
Word[I] = ‘0’;
if (strcmp (Word, “to”) ==0)
Cl++;
else if (strcrap (Word, “the”) ==0)
C2++;
1=0;
}
}
cout<<”Count of -to- in file:”<<Cl;
cout<<”Count of -the- in file:”<<C2;
OR cout«”Count of -to- and -the- in
Fil.close(); //1gnore
}
OR






398
Any-othercorrectfunctiondefinition
(½ Mark for opening POEM. TXT correctly)
(½ Mark for reading each word (using any method) from the file)
(½ Mark for comparing the word with ‘to’ and ‘the’ )
(½ Mark for incrementing counter(s))
(c) Write a function in C++ to search and display details. of all trains, whose
destinationis“Delhi”.fromabinaryfile“TRAIN.DAT”.Assumingthebinary
fileiscontainingtheobjectsofthefollowingclass. 3
class TRAIN
{
int 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);}
void Show () {cout<<Tno<<“:”<<From<<“:”<<To<<endl;}
};
Ans. void Read ( )
{
TRAIN T;
ifstream fin;
fin. open (“TRAIN.DAT”, ios::binary);
OR ifstream fin (“TRAIN.DAT”, ios::binary);
while(fin.read((char*)&T, sizeof(T)))
{
if(strcmp(T.GetTo() ,”Delhi”)==O)
T.Show() ;
399
}
fin.close(); //Ignore
}
OR
Anyothercorrectfunctiondefinition
(½ Mark for opening TRAIN .DAT correctly)
(½ Mark for reading each record from TRAIN.DAT)
(½ Mark for correct loop / checking end of file)
(1 Mark for comparing value returned by GetTo() with “Delhi”)
(½ Mark for displaying the matching record)
5. (a) WhatdoyouunderstandbyPrimaryKey?GiveasuitableexampleofPrimary
Keyfromatablecontainingsomemeaningfuldata. 2
Ans. An attribute or set of attributes which are used to identify a tuple uniquely is
known as Primary Key
Table:Item
Ino Item Qty
I01 Pen 300
I02 Pencil 780
I04 CD 450
I09 Floppy 700
(1 Mark for writing correct definition/purpose of valid Primary Key)
(1 Mark for giving suitable example)
OR
(2 Marks for illustrating the purpose of Key with/without showing it as a
part of a Table)
(b) Consider the following tables STOCK and DEALERS and answer (b1) and
(b2) parts of this question:
Table: STOCK
PRIMARY
KEY
400
Table:DEALERS
(b1) WriteSQLcommandsforthefollowingstatements: 4
(i) To display details of all Items in the Stock table in ascending order of
StockDate.
Ans. SELECT * FROM STOCK ORDER BY StockDate;
(1 Mark for correct query)
(½ Mark for partially correct answer)
(ii) To display ItemNo 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;
(1 Mark for correct query)
(½ Mark for partially correct answer)
(iii) Todisplaythedetailsofthoseitemswhosedealercode(Dcode)is102
or Quantity in Stock (Qty) is more than 100 from the table Stock.
Ans. SELECT * FROM STOCK WHERE Dcode=102 OR Qty >100;
(1 Mark for correct query)
(½ Mark for partially correct answer)
401
(iv) TodisplayMaximumUnitPriceofitemsforeachdealerindividuallyas
per Dcode from the table Stock.
Ans. SELECT Dcode, MAX (UnitPrice) FROM STOCK GROUP BY Dcode;
OR
Any other query that will give an equivalent output
(1 Mark for correct query)
(½ Mark for partially correct answer)
(b2) GivetheoutputofthefollowingSQLqueries: 2
(i) SELECT COUNT(DISTINCT Dcode) FROM Stock;
Ans. Count(DISTINCT Dcode)
3
(½ Mark for correct output)
(ii) SELECT Qty*UnitPrice FROM Stock WHERE ItemNo=5006;
Ans. Qty*UnitPrice
4400
(½ Mark for correct output)
(iii) SELECT Item,Dname FROM Stock S, Dealers D
WHERE S.Dcode=D.DcodeAND ItemNo=5004;
Ans. Item Dname
Eraser Big Clear Deals
(½ Mark for correct output)
(iv) SELECT MIN(StockDate) FROM Stock;
Ans. MIN (StockDate)
01-Jan-09
(½ Mark for correct output)
6. (a) Verifythefollowingalgebraically: 2
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
OR
L.H.S.
X’.Y + X.Y’
= (X’.Y+X) (X’.Y+Y’)
= (X’+X).(Y+X).(X’+Y’).(Y+Y’)
= 1.(X+Y).(X’ +Y’).1
= (X+Y).(X’+Y’)
= R.H.S.
(2 Marks for correct verification)
(b) WritetheequivalentBooleanExpressionforthefollowingLogicCircuit: 2
Ans. (U’+V) . (V’+W)
(2 Marks for the final expre~sion (U’+V).(V’+W))
OR
(1 Mark for anv one of the correct terms out of (U'+V) or (V'+W))
(c) Write the SOPform of a Boolean function G, which is represented in a truth
tableasfollows: 1
403
Ans. G(P,Q,R)=P’.Q.R’+P’.Q.R+P.Q’.R’+P.Q.R’+P.Q.R
OR
G(P,Q,R) = Σ(2,3,4,6,7)
(1 Mark for the correct SOP form)
Note: Deduct ½ mark if wrong variable names are used
(d) ReducethefollowingBooleanExpressionusingK-Map: 3
F (A,B,C,D) = Σ (3,4,5,6, 7,13,15)
Ans. A’B’ A’B AB AB’
C’ D’ 0
1
4 12 8
C’ D 1
1
5
1
13 9
C D
1
3
1
7
1
13 11
C D 2
1
6 14 10
OR
C’D’ C’D CD CD’
A’B’ 0 1
1
3 2
A’B
1
4
1
5
1
7
1
6
A B 12
1
13
1
15 14
A B’ 8 9 11 10
404
F(A,B,C,D) = A’B + BD + A’CD
(½ Mark for drawing K-Map with correct variable names)
(½ Mark for placing all 1s at correct positions in K-Map)
(½ Mark for each grouping)
(½ Mark for writing final expression in reduced/minimal form)
7. (a) What was the role ofARPANET in the Computer Network? 1
Ans. ThefirstcomputernetworkwasjointlydesignedbyTheAdvancedResearch
ProjectsAgency(ARPA)andDepartmentofDefence(DoD)ofUnitedStates
in 1969 and was calledARPANET. It was an experimental project, which
connected a few computers from some of the reputed universities of USA
andDoD.ARPANETallowedaccesstocomputerresourcesharingprojects.
ThisARPANETwashandedovertoDefenceCommunicationAgency(DCA)
forfurtherdevelopment.
(1 Mark for mentioning that ARPANET was the first computer network)
OR
(½ Mark if only the expansion of ARPANET is mentioned)
(b) Whichofthefollowingisnotaunitfordatatransferrate? 1
(i) mbps
(ii) kbps
(iii) sbps
(iv) gbps
Ans. (iii)sbps
(1 Mark for the correct option/answer)
(c) What is the difference betweenVirus andWorms in the computers? 1
Ans. Virus:Virus is a malicious program that damages data and files and causes
harmtocomputersystem.
Worms:Worms disrupt services and create system management problems.
In some cases worms can install viruses that cause damage to system.
(1 Mark for mentioning anyone valid difference)
OR
(½ Mark for correct definition of each term)
405
(d) Whattermdoweuseforasoftware/hardwaredevice,whichisusedtoblock
unauthorizedaccesswhilepermittingauthorizedcommunications?Thisterm
isalsousedforadeviceorsetofdevicesconfiguredtopermit,deny,encrypt,
decrypt,orproxyall(inandout)computertrafficbetweendifferentsecurity
domains based upon a set of rules and other criteria. 1
Ans. Firewall
(1 Mark for writing correct term)
(e) “Vidya for All” is an educational NGO. It is setting up its new campus at
Jaipurforitsweb-basedactivities.Thecampushasfourbuildingsasshownin
thediagrambelow: 4
Center to center distances between various buildings as per architectural
drawings(inmeters)isasfollows:
ExpectedNumberofComputersineachBuildingisasfollows:
406
(el) Suggestacablelayoutofconnectionsbetweenthebuildings.
Ans.
OR
(1 Mark for mentioning any valid connectivity or topology or dia-
gram connecting various buildings inside the campus)
(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. TrainingBuildingasitcontainsmaximumnumberofcomputers.
(½ Mark for mentioning the building)
(½ Mark for correct justification)
OR
(1 Mark for any other location with a valid justification)
(e3) Suggesttheplacementofthefollowingdeviceswithjustification:
(i) Repeater
(ii) Hub/Switch
Ans. (i) A Repeater should be placed when the distance between any
twoconnectingbuildingsexceeds70m.
407
(ii) EverybuildingwillneedoneHub/Switch,tosendsignalstoall
of the workstations connected to it
OR
Anydiagrammaticrepresentationwithvalidjustification
(½ Mark for correct placement of Repeater with justification)
(½ Mark for correct placement of Hub/Switch with justification)
(e4) TheNGOisplanningtoconnectitsInternationalofficesituatedinDelhi.
Whichoutofthefollowingwiredcommunicationlinks,willyousuggest
foraveryhighspeedconnectivity?
(i) TelephoneAnalogLine
(ii) OpticalFiber
(iii) EthernetCable
Ans. (ii) OpticalFibre
(1 Mark for correct Option / Answer)
(f) Writethefullformsofthefollowing: 1
(f1) FTP
(f2) FSF
Ans. (f1) FILE TRANSFER PROTOCOL
(f2) FREE SOFTWARE FOUNDATION
(½ Mark. for each full form)
(g) Name any two common Web browsers. 1
Ans. Internetexplorer
Firefox
Netscape
Chrome
Opera
Safari
OR any other Web Browser
(½ Mark each for any two web browsers)
314
COMPUTER SCIENCE
Time allowed : 3 hours Maximum Marks : 70
Instructions:
(i) All questions are compulsory.
(ii) Programming Language: C+ +
QUESTION PAPER CODE 91/1
1. (a) What is the difference between LocalVariable and Global Variable?
Also, give a suitable C++ code to illustrate both. 2
(b) Writethenamesoftheheaderfiles,whichis/areessentiallyrequiredtorun/
executethefollowingC++code:
voidmain()
{
char C, String [ ] = "Excellence Overload";
for (int I=0; String [ I ] ! = ' 0'; I ++ )
if (String [I] ==' ')
cout<<end1;
else
{
C=toupper(String[I]);
cout<<C ;
}
}
(c) Rewritethefollowingprogramafterremovingthesyntacticalerrors(ifany).
Underlineeachcorrection. 2
#include[iostream.h]
315
typedef char Text(80) ;
voidmain()
{
TextT="Indian";
intCount=strlen(T);
cout<<T<<'has'<<Count<< 'characters' <<end1;
}
(d) Findtheoutputofthefollowingprogram: 3
#inc1ude<iostream.h>
voidChangeArray(intNumber,intARR[],intSize)
{
for (int L =0; L<Size; L++)
if(L<Number)
ARR [L] +=L;
e1se
ARR [L] *=L;
}
void Show (intARR [ ], int Size)
{
for (int L=0; L<Size; L++)
(L%2!=0) ?cout<<ARR[L] <<"#": cout<<ARR[L]<<end1 ;
}
voidmain()
{
int Array [ ] = {30, 20, 40, 10, 60, 50};
ChangeArray (3,Array, 6) ;
Show (Array, 6) ;
}
316
(e) Findtheoutputofthefollowingprogram: 2
#include<iostream.h>
voidmain()
{
int Track [ ] = {10, 20, 30, 40}, *Striker ;
Stxiker=Track:
Track [1] += 30 ;
cout<<"Striker>"<<*Striker<<end1;
Striker – =10 ;
Striker++ ;
cout<<"Next@"<<*Striker<<end1 ;
Striker+=2 ;
cout<<"Last@"<<*Striker<<end1;
cout<< "Reset To" <<Track[0] <<end1 ;
}
(f) Go through the C++ code shown below, and find out the possible output or
outputs from the suggested Output Options (i) to (iv).Also, write the least
value and highest value, which can be assigned to the variable Guess. 2
#include<iostream.h>
#include<stdlib.h>
voidmain()
{
randomize ( ) ;
intGuess,High=4;
Guess=random{High)+50;
for{int C=Guess ; C<=55 ; C++)
cout<<C<<"#";
317
}
(i) 50 # 51 # 52 # 53 # 54 # 55 #
(ii) 52 # 53 # 54 # 55
(iii) 53 # 54 #
(iv) 51 # 52 # 53 # 54 # 55
2. (a) Differentiatebetweenmembers,whicharepresentwithintheprivatevisibility
modewiththosewhicharepresentwithinthepublicvisibilitymodes. 2
(b) Write the output of the following C++ code.Also. write the name of feature
of Object Oriented Programming used in the following program jointly
illustratedbythefunction[I]to[IV]. 2
#include<iostream.h>
void Print ( ) //Function[I]
{
for (int K=1 ; K<=60 ; K++) cout<< "-" ;
cout<<end1 ;
}
voidPrint(intN) //Function[II]
{
for (int K=1 ; K<=N ; L++) cout<<"*" ;
cout<<end1 ;
}
voidPrint(intA,int.B) //Function[III]
{
for (int K=1. ;K<=B ;K++) cout <<A*K ;
cout<<end1 ;
}
void Print (char T, int N) //Function[IV]
318
{
for (int K=1 ; K<=N ; K++) cout<<T ;
cout<<end1;
}
voidmain()
{
int U=9, V=4, W=3;
char C='@' ;
Print (C,V) ;
Print (U,W) ;
}
(c) DefineaclassCandidateinC++withfollowingdescription: 4
PrivateMembers
A data member RNo (Registration Number) of type long
A data member Name of type string
A data member Score of type float
A data member Remarks of type string
Amember functionAssignRem( ) to assign Remarks as per the Score
obtained by a candidate. Score range and the respective Remarks are
shownasfollows:
Score Remarks
>=50 Selected
less than 50 Not selected
PublicMembers
A function ENTER ( ) to allow user to enter values for RNo, Name,
Score&callfunctionAssignRem()toassigntheremarks.
AfunctionDISPLAY()toallowusertoviewthecontentofallthedata
members.
319
(d) Answerthequestions(i)to(iv)basedonthefollowing: 4
classStrident
(
intRno;
char Name [20] ;
floatMarks;
protected:
void Result( ) ;
public:
Student( ) ;
void Register( ); void Display( ) ;
} ;
classFaculty
{
long FCode;
char FName[20];
protected:
floatPay;
public:
Faculty ( ) ;
void Enter ( ) ;
void Show ( ) ;
} ;
class Course : public Student, private Faculty
{
long CCode [10]; char CourseName [50] ;
char StartDate[8], EndDate[8] ;
320
public:
Course ( ) ;
void Commence ( ) ;
void CDetail ( ) ;
} ;
(i) Which type of inheritance is illustrated in the above C++ code?
(ii) Writethenamesofthealldatamembers,whichis/areaccessiblefrom
memberfunctionCommenceofclassCourse.
(iii) Writethenamesofmemberfunctions,whichareaccessiblefromobjects
of class Course.
(iv) Write the name of all the members, which are accessible from objects
ofclassFaculty.
3 (a) Write a Get1From2 ( ) function in C++ to transfer the content from two
arrays FIRST[ ] and SECOND[ ] to arrayALL[ ]. The even places (0, 2, 4,
...) of arrayALL[ ] should get the content from the array FIRST[ ] and odd
places (1, 3, 5, ) of the arrayALL[] should get the content from the array
SECOND[ ]. 3
Example:
If the FIRST[ ] array contains
30, 60, 90
And the SECOND[ ] array contains
10, 50, 80
TheALL[]arrayshouldcontain
30, 10, 60, 50, 90, 80
(b) AnarrayP[20][50]isstoredinthememoryalongthecolumnwitheachofits
element occupying 4 bytes, find out the 1ocation of P[15][10], if P[0][0] is
stored at 5200. 3
(c) WriteafunctioninC++toperformInsert:operationonadynamicallyallocated
Queue containing Passenger details as given in the following definition of
NODE. 4
321
struct NODE
{
longPno; //passengerNumber
char Pname[20] ; //passenger Name
NODE *Link.;
} ;
(d) Write a COLSUM( ) function in C++ to find sum of each column of a NxM
Matrix. 2
(e) Evaluatethefollowingpostfixnotationofexpression: 2
50, 60, + , 20, 10, -, *
4. (a) Observetheprogramsegmentgivenbelowcarefullyandfilltheblanksmarked
as Statement 1 and Statement 2 using seekg( ), seekp( ), tellp( ) and tellg( )
functionsforperformingtherequiredtask. 1
#include<fstream.h>
class PRODUCT
{
int Pno; char Pname[20); int Qty;
public:
void ModifyQty( ) ;
//ThefunctionistomodifyquantityofaPRODUCT
} ;
voidPRODUCT::ModifyQty()
{
fstreamFile;
Fil.open("PRODUCT.DAT",ios::binary|ios::in|ios::out);
intMPno;
322
cout<<"Product No to modify quantity : "; cin>>MPNo;
While(Fil.read((char*)this,sizeof(PRODUCT))
{
if (MPno == Pno)
{
Cout<<"PresentQuantity:"<<Qty<<end1;
cout<<"ChangedQuantity:";cin>>Qty;
int Position = _______________; //Statement 1
_________________________; // Statement 2
Fil.write((char*)this,sizeof(PRODUCT));
//Re-writing the record
}
}
Fil.close ( ) ;
}
(b) Write a function in C++ to count the no. of "Me" or "My" words present in a
textfile"DIARY.TXT". 2
Ifthefile"DIARY.TXT"contentisasfollows:
My first book was Me and My
family. It gave me chance to be
known to the world.
Theoutputofthefunctionshouldbe
Count of Me/My in file : 4
(c) WriteafunctioninC++tosearchforalaptopfromabinaryfile"LAPTOP.DAT"
containingtheobjectsofclassLAPTOP(asdefinedbelow).The user should
enter the Model No and the function should search and
display the details of the laptop. 3
classLAPTOP
{
323
long ModelNo ;
float RAM, HDD ;
char Details [120] ;
public:
void StockEnter ( )
{cin>>ModelNo>>RAM>>HDD;gets(Details);}
void StockDisplay ( )
{cout<<ModelNo<<RAM<<HDD<<Details<<endl;}
long ReturnModelNo ( ) {return ModelNo ;}
} ;
5 (a) What do you understand by Union & Cartesian Product operations in rela-
tionalalgebra? 2
Consider the following tables WORKER and PAYYLEVELand answer
(b) and (c) parts of this question: 4
Table:WORKER
ECODE NAME DESIG PLEVEL DOJ DOB
11 RadheShyam Supervisor P001 13- Sep- 2004 23-Aug-1981
12 Chander Nath Operator P003 22-Feb-2010 12-Jul-1987
13 Fizza Operator P003 14-Jun-2009 14-0ct-1983
15 AmeenAhmed Mechanic P002 21-Aug-2006 13-Mar-1984
18 Sanya Clerk P002 19-Dec-2005 09-Jun-1983
Table:PAYLEVEL
PLEVEL PAY ALLOWANCE
P001 26000 12000
P002 22000 10000
P003 12000 6000
324
(b) WriteSQLcommandsforthefollowingstatements:
(i) To display the details of all WORKERs in descending order of DOB.
(ii) TodisplayNAMEandDE;SIGofthoseWORKERs,whosePLEVEL
is either P001 or P002.
(iii) To display the content of all the WORKERs table, whose DOB is in
between '19-JAN-1984' and '18-JAN-1987'.
(iv) Toaddanewrowwiththefollowing:
19, 'Daya Kishore', 'Operator', 'P003', '19-Jun-2008', '11-Jun-1984'
(c) GivetheoutputofthefollowingSQLqueries: 2
(i) SELECTCOUNT(PLEVEL),PLEVELFROMWORKERGROUP
BYPLEVEL;
(ii) SELECT MAX (DOB), MIN (DOJ) FROM WORKER;
(iii) SELECT Name, Pay FROM WORKER W, PAYLEVEL P
WHERE W. PLEVEL = S. PLEVELAND P.ECODE<13 ;
(iv) SELECT PLEVEL, PAY+ALLOWANCE FROM PAYLEVEL
WHERE PLEVEL= 'P003' ;
6 (a) VerifythefollowingusingTruthTable. 2
U. (U' +V) = (U + V)
(b) WritetheequivalentBooleanExpressionforthefollowinglogicCircuit. 2
(c) Write the POS form of a Boolean function F, which is represented in a truth
tableasfollows: 1
325
A B C F
0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1
(d) ReducethefollowingBooleanExpressionusingK-Map: 3
F(P, Q, R, S) = Σ (0,1,2,4,5,6,8, 12)
7. (a) Differentiatebetweenpacketswitchingandmessageswitchingtechniquein
networkcommunication. 1
(b) Differentiate between BUS and STAR topology of networks. 1
(c) What is VoIP? 1
(d) Outofthefollowing,identifyclientsidescript(s)andserversidescript(s). 1
(a) ASP (b) Javascript
(c) VBScript (d) JSP
(e) QuicklearnUniversityissettingupitsAcademicblocksatPrayagNagarand
planning to set up a network. The university has 3 academic blocks and one
Human Resource Center as shown in the diagram below. 4
326
Center to center distance between various block/center is as follows:
Law Block to Business Block 40m
Law Block toTechnology Block 80m
Law Block to HR Center 105m
BusinessBlocktoTechnologyBlock 30m
Business Block to HR Center 35m
Technology Block to HR Center 15m
Number of Computers in each of the Blocks/Centre is follows:
LawBlock 15
TechnologyBlock 40
HR Center 115
BusinessBlock 25
(e1 ) Suggestthemostsuitableplace(i.e.Block/Center)toinstalltheserverofthis
universitywithasuitablereason.
(e2) Suggest an ideal layout for connecting these blocks/centers for a wired con-
nectivity.
(e3) Whichdeviceyouwillsuggesttobeplaced/installedineachoftheseblocks/
centertoefficientlyconnectallthecomputerswithintheseblocks/center.
(e4) Theuniversityisplanningtoconnectitsadmissionofficeintheclosestbigcity,
which is more than 250 km from university, which type of network out of
LAN, MAN or WAN will be formed? Justify your answer.
(f) WhichofthefollowingwillcomeunderCyberCrime? 1
(i) Theft of a brand new sealed pack Laptop
(ii) AccesstoabankaccountforgettingunauthorizedMoneyTransaction
(iii) Modificationinacompanydatawithunauthorizedaccess
(iv) Photocopying a printed report
(g) Compare open source software and proprietary software. 1
327
COMPUTER SCIENCE
QUESTION PAPER CODE 91
1. (a) What isthedifferencebetweenTypeCastingandAutomaticTypeconversion?
Also, give a suitable C++ code to illustrate both. 2
(b) Write the names of the header files, which is/are essentially required torun/
executethefollowingc++code: 1
voidmain()
{
charCH,Text[]="+veAttitude";
for (int I=0 ; Text[I] ! ='0' ;I++)
if (Text[I]== ' ')
cout<<end1;
else
{
CH=toupper (Text [I]) ;
cout<<CH;
}
}
(c) Rewritethefollowingprogramafterremovingthesyntacticalerrors(ifany).
Underlineeachcorrection. 2
include<iostream.h>
typedef char [80] String;
voidmain()
{
StringS="Peace";
intL=strlen(S);
cout<<S<< 'has'<<L<< 'characters'<<end1;
}
328
(d) Findtheoutputofthefollowingprogram: 3
#include<iostream.h>
void SwitchOver(intA[ ], int N, int Split)
{
for (int K=0 ; K<N; K++)
if(K<Split)
A(K]+ =K;
else
A [K]*=K;
}
void Display (intA[ ], int N)
{
for (int K=0 ; K<N ; K++)
(K%2==0)? cout<<A[K]<<"%":cout<<A(K]<<end1;
}
voidmain()
{
int H[ ]= {30,40,50,20,10,5};
SwitchOver (H, 6, 3);
Display(H,6);
}
(e) Findtheoutputofthefollowingprogram: 2
#include<iostream.h>
voidmain()
{
int *Queen, Moves [ ] = {11, 22, 33, 44};
329
Queen = Moves;
Moves [2] + = 22;
Cout<< "Queen @"<<*Queen<<end1;
*Queen - = 11;
Queen + = 2;
cout<< "Now @"<<*Queen<<end1;
Queen++;
cout<<"Finally@"<<*Queen«end1;
cout<< "New Origin @"<<Moves[0]<<end1;
}
(f) Go through the C++ code shown below, and find out the possible output or
outputsfromthesuggestedOutputOptions(i)to(iv).Also,writetheminimum
andmaximumvalues,whichcanbeassignedtothevariableMyNum. 2
#include<iostream.h>
#include<stdlib.h>
voidmain()
{
randomize ( ) ;
intMyNum,Max=5;
MyNum = 20 + random (Max) ;
for (int N=MyNum; 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
330
2. (a) DifferentiatebetweenConstructorandDestructorfunctionwithrespectto
ObjectOrientedProgramming. 2
(b) Write the output of the following C++ code.Also, write the .name of feature
of Object Oriented Programming used in the following program jointly
illustratedbythefunction[I]to[IV] 2
#include<iostream.h>
void Line ( ) //Function[I]
{
for (int L=1;L<=80;L++) cout<<"-";
cout<<end1;
}
voidLine(intN) //Function[II]
{
for(intL=l;L<=N;L++) Cout<<"*";
cout<<endl;
}
void Line (char C, int N) //Function[III]
{
for(intL=l;L<=N;L++) cout<<C;
cout<<end1;
}
void Line (int M, int, N) //Function[IV]
{
for (int L=1;L<=N;L++) cout<<M*L;
cout<<end1;
}
voidmain()
331
{
intA=9, B=4, C=3;
char K= '#' ;
Line(K,B);
Line(A,C);
}
(c) DefineaclassApplicantinC++withfollowingdescription: 4
PrivateMembers
Adata memberANo (Admission Number) of type long
A data member Name of type string
Adata memberAgg (Aggregate Marks) of type float
A data member Grade of type char
AmemberfunctionGradeMe()tofindtheGradeaspertheAggregate
Marks obtained by a student. EquivalentAggregate Marks range and
the respective Grades are shown as follows:
AggregateMarks Grade
>=80 A
less than 80 and >=65 B
less than 65 and >=50 C
less than 50 D
PublicMembers
AfunctionENTER()toallowusertoentervaluesforANo,Name,Agg
& call function GradeMe() to find the Grade.
Afunction_RESULT()toallowusertoviewthecontentofallthedata
members.
(d) Answerthequestions(i)to(iv)basedonthefollowing: 4
classStudent
{
332
intRollno:
char SName[20];
floatMarksl;
protected:
void Result ( ) ;
public:
Student ( ) ;
void Enroll ( ) ;void Display ( ) ;
} ;
classTeacher
{
longTCode;
char TName [20];
protected:
floatSalary;
public:
Teacher ( );
void Enter ( ) ;
void Show ( ) ;
} ;
class Course: public Student, private Teacher
}
long CCode [10]; char CourseName [50];
char StartDate [8] , EndDate [8];
public:
Course ( ) ;
void Commence ( );
void CDetail ( ) ;
} ;
333
(i) Write the names of member functions, which are accessible from objects of
class Course
(ii) Writethenamesofallthedatamembers,whichis/areaccessiblefrommember
functionCommenceofclassCourse
(iii) Write the names of all the-members, which are accessible from objects of
classTeacher.
(iv) Which type of Inheritance is illustrated in the above C++ code?
3. (a) Write a Get2From1() function in C++ to transfer the content from one array
ALL[] to two different arrays Odd[] and Even[]. The Odd[] array should
contain the values from odd positions (1,3,5,...) ofALL[] and Even [] array
should contain the values from even positions (0, 2, 4,…..) ofALL[]. 3
Example
IftheALL[]arraycontains
12, 34, 56, 67, 89, 90
The Odd[] array should contain
34, 67, 90
And the Even [] array should contain
12, 56, 89
(b) An array G[50][20] is stored in the memory along the row with each of its
elementsoccupying8bytes.FindoutthelocationofG[10][15],ifG[0][0]is
stored at 4200. 3
(c) WriteafunctioninC++toperformDelete operationona dynamicallyallocated
QueuecontainingMembersdetailsasgiveninthefollowingdefinitionofNODE: 4
struct NODE
{
longMno //MemberNumber
char Mname[20]; //Member Name
NODE*Link;
};
334
(d) WriteaDSUMOfunctioninC++tofindsumofDiagonalElementsfroma
NxN Matrix. 2
(Assuming that the N is a odd number)
(e) Evaluatethefollowingpostfixnotationofexpression: 2
True, False, NOT,AND, True, True,AND,OR
4. (a) Observetheprogramsegmentgivenbelowcarefullyandfilltheblanksmarked
as Statement 1 and Statement 2 using seekg( ), seekp( ) tellp( ) and tellg( )
functionsforperformingtherequiredtask. 1
#include<fstream.h>
classITEM
{
intIno;charIname[20];floatPrice;
public:
voidModifyPrice();//Thefunctionistomodify
price of a particular ITEM
} ;
voiditem::ModiyPrice()
{
fstreamFile;
File.open("ITEM.DAT",ios::binary|ios::in|ios::out)||;
intCIno;
cout<<"ItemNotomodifyprice:";cin>>CIno;
while(file.read((char*)this,sizeof(ITEM)))
{
if(CIno==Ino)
{
cout<<"PresentPrice:"<<Price<<end1;
cout<<"Changedprice:";cin>>Price;
335
int FilePos = __________ ; //Statement 1,
___________________; //Statement 2
File.write((char*)this,sizeof(ITEM));
// Re-writing the record
}
}
File.close ( ) ;
}
(b) Write a function in C++ to count the no. of "He" or "She" words present in a
textfile"STORY.TXT". 2
Ifthefile"STORY.TXT"contentisasfollows:
Heisplayingintheground.Sheis
Playingwithherdolls.
Theoutputofthefunctionshouldbe
CountofHe/Sheinfile:2
(c) Write a function in C++ to search for a camera from a binary file
"CAMERA.DAT" containing the objects of class" CAMERA (as defined
below). The user should enter the Model No and the function should search
display the details of the camera. 3
classCAMERA
{
longModelNo;
floatMegaPixel;
intZoom;
charDetails[120];
public:
voidEnter(){cin>>ModelNo>>MegaPixel>>Zoom;gets(Details);}
voidDisplay()
{cout<<ModelNo<<MegaPixel<<Zoom<<Details<<endl;}
long GetModelNo ( ) {return ModelNo;}
};
336
5. (a) What do you understand by Selection & Projection operations in relational
algebra? 2
Consider the following tables EMPLOYEE and SALGRADE and answer
(b) and (c) parts of this question:
Table: EMPLOYEE
ECODE NAME DESIG SGRADE DOJ DOB
101 AbdulAhmad EXECUTIVE S03 23-Mar-2003 13-Jan-1980
102 Rav:i.Chander HEAD-IT S02 12-Feb-2010 22-Jul-1987
103 John Ken RECEPTIONIST S03 24-June-2009 24-Feb-1983
105 NazarAmeen GM S02 11-Aug-2006 03-Mar-1984
108 PriyamSen CEO S01 29-Dec-2004 19-Jan-1982
Table:SALGRADE
SGRADE SALARY HRA
S0l 56000 18000
S02 32000 12000
S03 24000 8000
(b) WriteSQLcommandsforthefollowingstatements: 4
(i) TodisplaythedetailsofallEMPLOYEEs,indescendingorderofDOJ
(ii) To display NAME and DE51G of those EMPLOYEEs, whose
SALGRADE is either 502 or 503
(iii) To display the content of all the EMPLOYEEs table, whose DOJ is in
between'09-Feb-2006' and '08-Aug-2009'.
(iv) Toaddanewrowwiththefollowing:
109, 'Harish Roy', 'HEAD-IT', 'S02', '09-Sep-2007, '21-Apr-1983'
(c) Give:theoutputofthefollowingSQLqueries: 2
(i) SELECT COUNT (SGRADE), SGRADE FROM EMPLOYEE
GROUPBYSGRADE;
(ii) SELECT MIN(DOB), MAX (DOJ) FROM EMPLOYEE;
337
(iii) SELECT NAME , SALARYFROM EMPLOYEE E, SALGRADE
S WHERE E.SGRADE= S.SGRADEAND E.ECODE<103;
(iv) SELECTSGRADE,SALARY+HRAET:)MSALGRADEWHERE
SGRADE='S02';
6 (a) YerifythefollowingusingTruthTable: 2
X+Y. Z=(X+Y).(X+Z)
(b) WritetheequivalentBooleanExpressionforthefollowingLogicCircuit: 2
(c) Write the SOPform of a Boolean function F, which is represented in a truth
tableasfollows: 1
U V W F
0 0 0 1
0 0 1 0
0 1 1 1
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 1
(d) ReducethefollowingBooleanExpressionusingK-Map: 3
F(A, B,C, D) = Σ (0,1, 2, 4, 5, 6, 7, 8, 10)
7. (a) In networking, what-is WAN? How is it different from LAN? 1
(b) DifferentiatebetweenXMLandHTML. 1
(c) What is WEB2.0? 1
338
(d) Out of the following, identify client side script (s) and server side script (s). 1
(i) Javascript
(ii) ASP
(iii) vbscript
(iv) JSP
(e) Great Studies University is setting up itsAcademic schools at Sunder Nagar
andplanningtosetupanetwork.Theuniversityhas3academicschoolsand
oneadministrationcenterasshowninthediagrambelow: 4
Center to center distances between various buildings is as follows :
Law School to Business School 60m
Law School to Technology School 90m
Law School toAdmin Center 115m
BusinessSchooltoTechnologySchool 40m
BusinessSchoolto.AdminCenter 45m
TechnologySchooltoAdminCenter 25m
Number of Computers in each of the Schools/Center is follows:
LawSchool 25
TechnologySchool 50
AdminCenter 125
BusinessSchool 35
339
(i) Suggest the most suitable place (i.e. School/Center) to install the
serverofthisuniversitywithasuitablereason.
(ii) Suggest an ideal layout for connecting these schools/ center for a
wiredconnectivity.
(iii) Whichdevicewillyousuggesttobeplaced/installedineachofthese
schools/centertoefficientlyconnectallthecomputerswithinthese
schools / center?
(iv) Theuniversityisplanningtoconnectitsadmissionofficeintheclosest
bigcity,whichismorethan350kmfromtheuniversity.Whichtypeof
network out of LAN, MAN or WAN will be formed? Justify your
answer.
(f) Compare Open Source Software and Proprietary Software. 1
(g) What are cookies? 1
340
Marking Scheme ó Computer Science
General Instructions :
1. TheanswersgiveninthemarkingschemeareSUGGESTIVE,Examinersarerequestedto
awardmarksforallalternativecorrectSolutions/Answersconveyingthesimilarmeaning
2. All programming questions have to be answered with respect to C++ Language only.
3. InC++,ignorecasesensitivityforidentifiers
(Variable/Functions/Structures/ClassNames)
4. In SQL related questions - both ways of text/character entries should be acceptable for
Example: “AMAR” and ‘amar’both are correct.
5. In SQL related questions - all date entries should be acceptable for Example: 'DD-Mon-
YY',"DD/MM/YY",'DD/MM/YY',"MM/DD/YY",'MM/DD/YY',and{MM/DD/YY}
are correct.
6. InSQLrelatedquestions-semicolonshouldbeignoredforterminatingtheSQLstatements
7. InSQLrelatedquestions,ignorecasesensitivity.
QUESTION PAPER CODE 91/1
EXPECTEDANSWERS
1. (a) What is the difference between Local Variable and Global Variable?
Also, give a suitable C++ code to illustrate both. 2
Ans Local Variables: Local variables are those variables which are declared
within a function or a compound statement and these variables can only be
usedwithinthatfunction/scope.
GlobalVariables:Globalvariablesarethosevariableswhicharenotdeclared
within any function or scope. So, these variables can be accessed by any
functionoftheprogram.
Example
#include<iostream.h>
#include<conio.h.>
intG; //Globalvariabledeclared
341
void Fun ( )
{
int L = 25; // Local variable of function Fun ( ) assigned value 25
G=5; // GlobalVariable is accessed and assigned value 5
Cout<<G<<endl; //Value of global variable is displayed as 5
Cout<<L<<endl; //Value of local variable is displayed as 25
}
voidmain()
{
Fun ( ) ; //Functioncall
G = G + 5; //Globalvariableisincrementedby5
cout<<G<<endl; // Global variable is displayed as 10
}
(½ Mark for each correct explanation of Local Variable and Global
Variable)
(½ Mark for each correct example of Local variable and Global Variable)
OR
(Full 2 Maries for correct example(s) demonstrating the meaning of /
difference between Local Variable and Global Variable)
OR
(Only 1 Mark to be awarded if Explanation without supporting examples)
(b) Writethenamesoftheheaderfiles,whichis/areessentiallyrequiredtorun/
executethefollowingC++code:
voidmain()
{
char C, String [ ] = "Excellence Overload";
for (int I=0; String [ I ] ! = ' 0'; I ++ )
if (String [I] ==' ')
342
cout<<end1;
else
{
C=toupper(String[I]);
cout<<C ;
}
}
Ans iostream.h
ctype.h
(½ Mark for writing each correct header file)
(c) Rewritethefollowingprogramafterremovingthesyntacticalerrors(ifany).
Underlineeachcorrection. 2
#include[iostream.h]
typedef char Text(80) ;
voidmain()
{
TextT="Indian";
intCount=strlen(T);
cout<<T<<'has'<<Count<< 'characters' <<end1;
}
Ans #include<iostream.h>
#include<string.h>
typedef char Text [80];
voidmain()
{
TextT="Indian";
intCount=str1en(T);
cout<<T<< "has" <<Count<< "cbaracters"<<end1 ;
343
}
(½Markforwriting#include<iostream.h>
(½Markforwriting#include<string.h>
(½ Mark for writing typedef char Text(80];
(½Markforwriting"has"and"characters")
(d) Findtheoutputofthefollowingprogram: 3
#inc1ude<iostream.h>
voidChangeArray(intNumber,intARR[],intSize)
{
for (int L =0; L<Size; L++)
if(L<Number)
ARR [L] +=L;
e1se
ARR [L] *=L;
}
void Show (intARR [ ], int Size)
{
for (int L=0; L<Size; L++)
(L%2!=0) ?cout<<ARR[L] <<"#": cout<<ARR[L]<<end1 ;
}
voidmain()
{
int Array [ ] = {30, 20, 40, 10, 60, 50};
ChangeArray (3,Array, 6) ;
Show (Array, 6) ;
}
344
Ans 30
21#42
30#240
250#
(½ Mark for each correct value)
Note:
Deduct ½ Mark for not writing # at proper places
Deduct ½ Mark for not considering endl at proaer places
(e) Findtheoutputofthefollowingprogram: 2
#include<iostream.h>
voidmain()
{
int Track [ ] = {10, 20, 30, 40}, *Striker ;
Stxiker=Track:
Track [1] += 30 ;
cout<<"Striker>"<<*Striker<<end1;
Striker – =10 ;
Striker++ ;
cout<<"Next@"<<*Striker<<end1 ;
Striker+=2 ;
cout<<"Last@"<<*Striker<<end1;
cout<< "Reset To" <<Track[0] <<end1 ;
}
Ans Striker>10
Next@50
Last@40
Reset to 0
345
(½forwritingeachlineofoutputcorrectly)
Note:
Deduct½Markifany/allspecialcharactersaremissing
Deduct ½ Mark if endl is not considered at the right positions
(f) Go through the C++ code shown below, and find out the possible output or
outputs from the suggested Output Options (i) to (iv).Also, write the least
value and highest value, which can be assigned to the variable Guess. 2
#include<iostream.h>
#include<stdlib.h>
voidmain()
{
randomize ( ) ;
intGuess,High=4;
Guess=random{High)+50;
for{int C=Guess ; C<=55 ; C++)
cout<<C<<"#";
}
(i) 50 # 51 # 52 # 53 # 54 # 55 #
(ii) 52 # 53 # 54 # 55
(iii) 53 # 54 #
(iv) 51 # 52 # 53 # 54 # 55
Ans (i) 50 # 51 # 52 # 53 # 54 # 55 #
Least value 50
Highestvalue53
(1 Mark for mentioning correct option (i))
( ½ Mark for mentioning correct Least value of Guess)
(½ Mark for mentioning correct Highest value of Guess)
346
2. (a) Differentiatebetweenmembers,whicharepresentwithintheprivatevisibility
modewiththosewhicharepresentwithinthepublicvisibilitymodes. 2
Ans Privatemembersofaclassareaccessibleonlytothememberfunctionsofthe
sameclass.
Publicmembersofaclassareaccessibletothememberfunctionsofthesame
classaswellasmemberfunctionsofitsderivedclass(es)andalsotoanobject
of the class.
Example:
class Base
{
intN;
public:
voidAssign()
{
N=10;
}
};
classDerived:publicBase
{
intX;
public:
voidDisplayBase()
{
cout<<N; //NotAccessible
Assign ( ) ; //Accessible
}
} ;
voidmain()
347
{
Base B;
B.Assign(); //Accessible
}
(1MarkforcorrectexplanationORexampleillustratingnonaccessibilityof
PrivateMembersinsideDerivedclass)
(1MarieforcorrectexplanationORexampleillustratingaccessibilityofPublic
Members inside Derived Class and to object of the class)
(b) Write the output of the following C++ code.Also. write the name of feature
of Object Oriented Programming used in the following program jointly
illustratedbythefunction[I]to[IV]. 2
#include<iostream.h>
void Print ( ) //Function[I]
{
for (int K=1 ; K<=60 ; K++) cout<< "-" ;
cout<<end1 ;
}
voidPrint(intN) //Function[II]
{
for (int K=1 ; K<=N ; L++) cout<<"*" ;
cout<<end1 ;
}
voidPrint(intA,int.B)
{
for (int K=1. ;K<=B ;K++) cout <<A*K ;
cout<<end1 ;
}
void Print (char T, int N) //Function[IV]
348
{
for (int K=1 ; K<=N ; K++) cout<<T ;
cout<<end1;
}
voidmain()
{
int U=9, V=4, W=3;
char C='@' ;
Print (C,V) ;
Print (U,W) ;
}
Ans. @@@@
91827
OR
No Output as L is not declared in void Print (int N)
Polymorphism
OR
FunctionOverloading
(½ Mark for writing each correct line of output)
(1 Mark for writing the feature name correctly)
(c) DefineaclassCandidateinC++withfollowingdescription: 4
PrivateMembers
A data member RNo (Registration Number) of type long
A data member Name of type string
A data member Score of type float
A data member Remarks of type string
349
Amember functionAssignRem( ) to assign Remarks as per the Score
obtained by a candidate. Score range and the respective Remarks are
shownasfollows:
Score Remarks
>=50 Selected
less than 50 Not selected
PublicMembers
A function ENTER ( ) to allow user to enter values for RNo, Name,
Score&callfunctionAssignRem()toassigntheremarks.
AfunctionDISPLAY()toallowusertoviewthecontentofallthedata
members.
Ans class Candidate
{
longRNo;
char Name[20];
float Score;
char Remarks[20];
voidAssignRem();
public:
voidEnter();
voidDisplay();
} ;
voidCandidate::AssignRem()
{
if (Score>=50)
strcpy(Remarks,"Selected");
else
strcpy(Remarks,"Not Selected") ;
}
350
void Candidate: : Enter ( )
{
cin>>RNo ;
gets (Name) ; cin>>Score;
AssignRem();
}
voidCandidate::Display()
{
cout<<RNo<<Name<<Score<<Remarks<<end1;
}
(½ Mark for correct syntax for class header)
(½ Mark for correct declaration of data members)
(1 Mark for correct definition of AssignRem())
(1 Mark for correct definition of Enter() with proper invocation of
AssignRem() function)
(1 Mark for correct definition of Display())
NOTE:
Deduct ½ Mark to be deducted if Assignrem() is not invoked properly
inside Enter( ) function
No marks to be deducted if member function definitions are written
inside the class
(d) Answerthequestions(i)to(iv)basedonthefollowing:
classStrident
(
intRno;
char Name [20] ;
floatMarks;
351
protected:
void Result( ) ;
public:
Student( ) ;
void Register( ); void Display( ) ;
} ;
classFaculty
{
long FCode;
char FName[20];
protected:
floatPay;
public:
Faculty ( ) ;
void Enter ( ) ;
void Show ( ) ;
} ;
class Course : public Student, private Faculty
{
long CCode [10]; char CourseName [50] ;
char StartDate[8], EndDate[8] ;
public:
Course ( ) ;
void Commence ( ) ;
void CDetail ( ) ;
} ;
352
(i) Which type of inheritance is illustrated in the above C++ code?
Ans MultipleInheritance
(1 Mark for correct answer)
(ii) Writethenamesofthealldatamembers,whichis/areaccessiblefrom
memberfunctionCommenceofclassCourse.
Ans CCode, CourseName, StartDate, EndDate, Pay
(1 Mark for correct answer)
Note:
No marks to be awarded for any other alternative answer
(iii) Writethenamesofmemberfunctions,whichareaccessiblefromobjects
of class Course.
Ans Commence( ), CDetail( ), Register( ), Display( )
(1 Mark for correct answer)
Note:
No marks to be awarded for any other alternative answer
Constructor functions to be ignored
(iv) Write the name of all the members, which are accessible from objects
ofclassFaculty.
Ans Enter( ), Show( )
(1 Mark for correct answer)
Note:
No marks to be awarded for any other alternative answer
Constructor functions to be iqnored
3 (a) Write a Get1From2 ( ) function in C++ to transfer the content from two
arrays FIRST[ ] and SECOND[ ] to arrayALL[ ]. The even places (0, 2, 4,
...) of arrayALL[ ] should get the content from the array FIRST[ ] and odd
places (1, 3, 5, ) of the arrayALL[] should get the content from the array
SECOND[ ].
353
Example:
If the FIRST[ ] array contains
30, 60, 90
And the SECOND[ ] array contains
10, 50, 80
TheALL[]arrayshouldcontain
30, 10, 60, 50, 90, 80
Ans void Get1From2 (intALL[],int FIRST[],int SECOND[],
intN,intM)
{
for(int I=0,J=0,K=0;i<N+M; I++)
if(I%2==0)
ALL[I]=FIRST[J++];
else
ALL[I]=SECOND[K++];
}
OR
voidGet1From2(intALL[],intFIRST[],intSECOND[],
int N, int M)
{
int J=0,K=0;
for(int I=0;i<N+M; I++)
{
if(I%2==0)
{
ALL [I] =FIRST [J] ;
J++;
}
354
else
{
ALL[I]=SECOND[K];
K++;
}
}
}
(1 Mark for correct loop)
(½ Mark for checking even locations)
(½ Mark for checking even locations or writing else for odd locations)
( 1 Mark for incrementing FIRST and SECOND Array Locations)
(b) AnarrayP[20][50]isstoredinthememoryalongthecolumnwitheachofits
element occupying 4 bytes, find out the 1ocation of P[15][10], if P[0][0] is
stored at 5200. 3
Ans AssuminqLBR=LBC=0
B=5200
W=4 bytes
Number of Rows(N)=20
NumberofColumns(M)=50
LOC(Arr[I] [J]) = B +(I + J*N)*W
LOC(Arr[15][10]) = 5200+(15+10*20)*4
= 5200 + (215*4)
= 5200 + 860
= 6060
(1 Mark for writing correct formula (for row major) OR substituting
formula with correct values for calculating Address)
(2 marks for calculating correct address)
Note:
1 Mark to be awarded for writing only the correct answer (i.e. 6060)
355
(c) WriteafunctioninC++toperformInsert:operationonadynamicallyallocated
Queue containing Passenger details as given in the following definition of
NODE. 4
struct NODE
{
longPno; //passengerNumber
char Pname[20] ; //passenger Name
NODE *Link.;
} ;
Ans class Queue
{
NODE *Front, *Rear;
public:
Queue ( ) {Front = NULL; Rear = NULL; }
void QueInsert ( ) ;
void QueDel ( ) ;
void QueDis ( ) ;
~Queue ( ) ;
} ;
void Queue: : QueInsert ( )
{
NODE*Temp=new NODE;
cin>>Temp->Pno; gets (Temp->Pname) ;
Temp->Link = NULL;
Rear->Li.nk = Temp;
Rear = Temp ;
}
356
(1 Mark for creating a new NODE dynamically)
(1 Mark for assigning NULL to Link of new NODE)
(1 Mark for linking the Rearmost NODE to the new NODE)
(1 Mark for making the new NODE as the Rearmost NODE)
(d) Write a COLSUM( ) function in C++ to find sum of each column of a NxM
Matrix. 2
Ans void COLSUM(intA[] [100], int N, int M)
{
intSUMC;
for (int j=0; j<M; j++)
{
SUMC = 0;
for (int i=0; i<N; i++)
SUMC = SUMC + A[i] [j] ;
Cout<< "Sum of Column "<<j<<" = "<<SUMC ;
}
}
(½ Mark for writing correct outer loop)
(½ Mark for initializing SUMC with 0 for each column)
(½ Mark tor writing correct inner loop)
(½ Mark for finding sum of each column)
(e) Evaluatethefollowingpostfixnotationofexpression: 2
50, 60, + , 20, 10, -, *
Ans ElementScanned STACK
50 50
60 50, 60
+ 110
357
20 110, 20
10 110, 20, 10
– 110, 10
* 1100
(2 Mark for evaluating 1100 as the final answer)
Note:
(½ Mark for writing only the final answer as 1100 without showing the
operations or Stack)
4. (a) Observetheprogramsegmentgivenbelowcarefullyandfilltheblanksmarked
as Statement 1 and Statement 2 using seekg( ), seekp( ), tellp( ) and tellg( )
functionsforperformingtherequiredtask. 1
#include<fstream.h>
class PRODUCT
{
int Pno; char Pname[20); int Qty;
public:
:
void ModifyQty( ) ;
//ThefunctionistomodifyquantityofaPRODUCT
} ;
voidPRODUCT::ModifyQty()
{
fstreamFile;
Fil.open("PRODUCT.DAT",ios::binary|ios::in|ios::out);
intMPno;
cout<<"Product No to modify quantity : "; cin>>MPNo;
While(Fil.read((char*)this,sizeof(PRODUCT))
358
{
if (MPno == Pno)
{
Cout<<"PresentQuantity:"<<Qty<<end1;
cout<<"ChangedQuantity:";cin>>Qty;
int Position = _______________; //Statement 1
_________________________; // Statement 2
Fil.write((char*)this,sizeof(PRODUCT));
//Re-writing the record
}
}
Fil.close ( ) ;
}
Ans Option 1
Statement1: File. tellp ( ) ;
OR File.tellg();
Statement2: File.seekp (FilePos - sizeof (PRODUCT)) ;
OR File.seekp (-sizeof (PRODUCT), ios: :cur));
OR File.seekg (FilePos - sizeof (PRODUCT));
OR File.seekg(-sizeof(PRODUCT),ios::cur));
Option 2
Statement1: File.tellp ( ) - sizeof (PRODUCT) ;
OR File.tellg() - sizeof (PRODUCT) ;
Statement2: File. seekp (FilePos) ;
OR File.seekg (FilePos) ;
(½ Mark for writing Statement 1 correctly)
(½ Mark for writing Statement 2 correctly)
Note:
File / Fil both are acceptable as the name of the File object
359
(b) Write a function in C++ to count the no. of "Me" or "My" words present in a
textfile"DIARY.TXT". 2
Ifthefile"DIARY.TXT"contentisasfollows:
My first book was Me and My
family. It gave me chance to be
known to the world.
Theoutputofthefunctionshouldbe
Count of Me/My in file : 4
Ans void COUNT ( )
{
ifstreamFil("DIARY.TXT");
char STR [10] ;
int count = 0 ;
while(!Fil.eof())
{
Fil>>STR;
if (strcmp (STR, "Me")==0 | | strcmp (STR, "My") ==0)
count++;
}
Cout<<"CountofMe/Myinfile:"<<count<<end1;
Fil.close( ) ; //Ignore
}
OR
Any other correct function definition performing the desired operation
(½ Mark for opening DIARY. TXT correctly)
(½ Mark for reading each word (Whichever method adopted) from, the file)
(½ Mark for comparing the word with 'Me' and 'My' and incrementing counter)
(½ Mark for displaying the number of 'Me/My' with/without the Text Message)
NOTE:
Ignore case sensitivity check for Me/My
360
(c) Write a function in C++ to search for a laptop from a binary file
"LAPTOP.DAT"containingtheobjectsofclassLAPTOP(asdefinedbelow).
The user should enter the Model No and the function should search and
display the details of the laptop. 3
classLAPTOP
{
long ModelNo ;
float RAM, HDD ;
char Details [120] ;
public:
void StockEnter ( )
{cin>>ModelNo>>RAM>>HDD;gets(Details);}
void StockDisplay ( )
{cout<<ModelNo<<RAM<<HDD<<Details<<endl;}
long ReturnModelNo ( ) {return ModelNo ;}
} ;
Ans void Search( )
{
LAPTOPL;
longmodelnum;
cin>>modelnum;
ifstreamfin;
fin.open("LAPTOP.DAT",ios::binary|ios::in);
while(fin.read((char*)&L,sizeof(L)))
{
if(L.ReturnModelNo()==modelnum)
L.StockDisplay ( ) ;
361
}
Fin.close();//Ignore
}
OR
voidSearch(longmodelnum)
{
LAPTOPL;
ifstreamfin;
fin.open("LAPTOP.DAT",ios::binary|ios::in);
while(fin.read((char*)&L,sizeof(L)))
{
if(L.ReturnModelNo()==modelnum)
L.StockDisplay ( ) ;
}
fin.close ( ) ; //Ignore
}
(½ Mark for declaring and entering a model number for a LAPTOP to
search OR passing it as a parameter to the function)
(½ Mark for opening LAPTOP.DA T correctly)
(½ Mark for reading each record from LAPTOP.DA T)
(½ Mark for correct loop / checking end of file)
(½ Mark for comparing value returned by ReturnModelNo() with model
number entered)
(½ Mark for displaying the matching record)
5 (a) What do you understand by Union & Cartesian Product operations in rela-
tionalalgebra? 2
Ans Cartesian Product (binary operator): It operates on two relations and is
denoted by X. For example Cartesian product of two relations R1 and R2 is
362
represented by R = R1 X R2. The degree of R is equal to sum of degrees of
R1andR2.ThecardinalityofRisproductofcardinalityofR1andcardinality
of R2.
Example:
Relation:R1
RollNo Student Name Class
1 Akash XII
4 Debakar X
10 Rishi XI
Relation:R2
Teacher Code Teacher Name
102 MsRinee
309 MrTanmoy
Resultant: R = R1 × R2
Col1 Col2 Col3 Col4 Col5
1 Akash XII 102 MsRinee
1 Akash XII 309 MrTanmoy
4 Debakar X 102 MsRinee
4 Debakar X 309 MrTanmoy
10 Rishi XI 102 MsRinee
10 Rishi XI 309 MrTanmoy
Union (binary operator): It operates on two relations and is indicated by U.
For example, R=R1 U R2 represents union operation between two relations
R1 and R2. The degree of R is equal to degree of R1. The cardinality of R is
sumofcardinalityofR1andcardinalityofR2.
Following have to be considered for the operation R1 U R2.
Degree of R1 = Degree of R2
jth attribute of R1 and jth attribute of R2 must have a common domain.
363
Example:
Relation:R1
Student_I D Name
R490 Fatima
R876 Faraz
R342 Gauri
Relation:R2
Student_Code Student_Name
S123 Rekha
S456 Tushi
Resultant Relation: R = R1 U R2
Column1 Column2
R490 Fatima
R876 Faraz
R342 Gauri
S123 Rekha
S456 Tushi
(1 Marie for explaining Union correctly)
(1 Marie for explaining Cartesian Product correctly)
Consider the following tables WORKER and PAYYLEVELand answer
(b) and (c) parts of this question: 4
Table:WORKER
ECODE NAME DESIG PLEVEL DOJ DOB
11 RadheShyam Supervisor P001 13- Sep- 2004 23-Aug-1981
12 Chander Nath Operator P003 22-Feb-2010 12-Jul-1987
13 Fizza Operator P003 14-Jun-2009 14-0ct-1983
15 AmeenAhmed Mechanic P002 21-Aug-2006 13-Mar-1984
18 Sanya Clerk P002 19-Dec-2005 09-Jun-1983
364
Table:PAYLEVEL
PLEVEL PAY ALLOWANCE
P001 26000 12000
P002 22000 10000
P003 12000 6000
(b) WriteSQLcommandsforthefollowingstatements:
(i) To display the details of all WORKERs in descending order of DOB.
SELECT FROM WORKER ORDER BY DOB DESC;
(1 Mark for correct query)
(½ Mark for partially correct answer)
(ii) TodisplayNAMEandDE;SIGofthoseWORKERs,whosePLEVEL
is either P001 or P002.
SELECT NAME, DESIG FROM WORKER
WHERE PLEVEL IN ('P001', 'P002') ;
OR
SELECT NAME, DESIG FROM WORKER
WHERE PLEVEL = 'P001' OR PLEVEL= 'P002';
(1 Marie for correct query)
(½ Marie for partially correct answer)
(iii) To display the content of all the WORKERs table, whose DOB is in
between '19-JAN-1984' and '18-JAN-1987'.
SELECT * FROM WORKER
WHERE DOB BETWEEN '19-JAN-1984' AND '18-JAN-1987' ;
OR
SELECT * FROM WORKER
WHERE DOB >= '19-JAN-1984' AND DOB<='18-JAN-1987';
OR
365
SELECT * FROM WORKER
WHERE DOB > '19-JAN-1984' AND DOB<'18-JAN-1987' ;
(1 Mark for correct query)
(½ Mark for partially correct answer)
(iv) Toaddanewrowwiththefollowing:
19, 'Daya Kishore', 'Operator', 'P003', '19-Jun-2008', '11-Jun-1984'
INSERT INTO WORKER
VALUES (19, 'Daya Kishore', 'Operator' , 'P003' , '11-Jun-1984');
(1 Mark for correct query)
(½ Mark for partially correct answer)
(c) GivetheoutputofthefollowingSQLqueries: 2
(i) SELECTCOUNT(PLEVEL),PLEVELFROMWORKERGROUP
BYPLEVEL;
Ans. COUNT (PLEVEL) PLEVEL
1 P001
2 P002
2 P003
( ½ Mark for correct output)
(ii) SELECT MAX (DOB), MIN (DOJ) FROM WORKER;
MAX (DOB) MIN (DOJ)
12-Jul-1987 13-Sep-2004
( Mark for correct output)
(iii) SELECT Name, Pay FROM WORKER W, PAYLEVEL P
WHERE W. PLEVEL = S. PLEVELAND P.ECODE<13 ;
Name Pay
RadheShyam 26000
Chander Nath 12000
366
OR
P.ECode does not exist
(½ Mark for correct output)
OR
( Mark for writing No Output)
(iv) SELECT PLEVEL, PAY+ALLOWANCE FROM PAYLEVEL
WHERE PLEVEL= 'P003' ;
PLEVEL PAY+ALLOWANCE
P003 118000
(½ Mark for correct output)
6 (a) VerifythefollowingusingTruthTable. 2
U. (U' +V) = (U + V)
Ans U V U' U'+V U.(U'+V) U+V
0 0 1 1 0 0
0 1 1 1 0 1
1 0 0 0 0 1
1 1 0 1 1 1
VERIFIED FALSE
(2 Marks to be awarded if Truth Table is made OR any equivalent term
conveyingthesamemeaning)
(b) WritetheequivalentBooleanExpressionforthefollowinglogicCircuit. 2
367
Ans F=(X+Y').(X+Z')
(2 Marks for the final expression (X+Y').(X+Z')
OR
(1 Mark for anyone of the correct terms out of (X+Y’) or (X+ Z’)
(c) Write the POS form of a Boolean function F, which is represented in a truth
tableasfollows: 1
A B C F
0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1
Ans F(A,B,C) = (A+B+C).(A+B'+C').(A'+B+C').(A'+B'+C)
(1 Mark for the correct POS form)
Note: Deduct ½ mark if wrong variable names are used
(d) ReducethefollowingBooleanExpressionusingK-Map: 3
F(P, Q, R, S) = E (0,1,2,4,5,6,8, 12)
P' Q' P' Q P Q P Q'
R' S' 1 1 1 1
R' S 1 1
R S
R S' 1 1
OR
368
R' S' R' S R S R S'
P' Q' 1 1 1
P' Q 1 1 1
P Q 1
P Q' 1
Ans F(P,Q,R,S) = P'R' + R'S' + P'S'
(½ Mark for placing all 1s at correct positions in K-Map)
(½ Mark for each grouping)
(1 Mark for writing final expression in reduced/minimal form)
Note: Deduct ½ mark if wrong variable names are used
7. (a) Differentiatebetweenpacketswitchingandmessageswitchingtechniquein
networkcommunication. 1
Ans Packet switching: In packet switching, a fixed size of data packet that can be
transmittedacrossthenetworkisspecifiedandthenthedatapacketsaresent
throughswitchingstationstothefinaldestination.Allthepacketsarestoredin
the main memory instead of disk. As a result accessing time of packets is
reduced.
Message switching: The source computer sends data (message) to the
switching station, which stores data in a buffer. It then looks for a free link to
anotherswitchingstationandsendsdatatothatstation.Thisprocesscontinues
until data is delivered to the destination computer. This type of switching
techniqueisalsoknownas"storeandforward"switching.
(½ Marks for written OR diagrammatic explanation of correct Packet
Switching)
(½ Marks for written OR diagrammatic explanation of correct Message
Switching)
(b) Differentiate between BUS and STAR topology of networks. 1
Ans BusTopology StarTopology
Slower as compared to star Expensive as compared to Bus
topologiesofnetwork topology
369
Breakage of wire at any point Longwirelength
disturbstheentirenetwork
(½ Marks for written or diagrammatic explanation of correct Bus
Topology)
(½ Marks for written or diagrammatic explanation of correct Star
Topology)
(c) What is VoIP? 1
Ans VoiceoverInternetProtocol(VoiceoverIP,VoIP)iscommunicationprotocols
and transmission technologies for delivery of voice communications and
multimediasessionsoverInternetProtocol(IP)networks,suchastheInternet.
Also, we can say,VoIPare IPtelephony, Internet telephony and broadband
telephony.
(1 Mark for explaining VoIP)
Note: 1 Mark for writing full form of VoIP
(d) Outofthefollowing,identifyclientsidescript(s)andserversidescript(s). 1
(a) ASP (b) Javascript
(c) VBScript (d) JSP
Ans Java script & VB script are client side scripts
JSP &ASPare server side scripts
(½ Mark for writing correct Client Side Scripts)
(½ Mark for writing correct Server Side Scripts)
(e) QuicklearnUniversityissettingupitsAcademicblocksatPrayagNagarand
planning to set up a network. The university has 3 academic blocks and one
Human Resource Center as shown in the diagram below. 4
370
Center to center distance between various block/center is as follows"
Law Block to Business Block 40m
Law Block toTechnology Block 80m
Law Block to HR Center 105m
BusinessBlocktoTechnologyBlock 30m
Business Block to HR Center 35m
Technology Block to HR Center 15m
Number of Computers in each of the Blocks/Centre is follows:
LawBlock 15
TechnologyBlock 40
HR Center 115
BusinessBlock 25
(e1 ) Suggestthemostsuitableplace(i.e.Block/Center)toinstalltheserverofthis
universitywithasuitablereason.
Ans HRcenter:
Reasonasithasthemaximumnumberofcomputers
OR
BusinessBlock
ReasonasitisclosesttoallotherCenters(minimumcablelengthrequired)
(½ Mark for mentioning any correct place)
(½ Mark for correct reason)
OR
(1 Mark for any other location with a valid reason)
(e2) Suggest an ideal layout for connecting these blocks/centers for a wired con-
nectivity.
371
Ans. Option1:
Option2:
(1 Mark for mentioning any valid connectivity or topology or diagram
connecting various compounds inside the campus)
(e3) Whichdeviceyouwillsuggesttobeplaced/installedineachoftheseblocks/
centertoefficientlyconnectallthecomputerswithintheseblocks/center.
Ans Switch
(1 Mark for mentioning correct device)
Note:
(1 mark to be awarded if Switch / Hub is mentioned)
372
(e4) Theuniversityisplanningtoconnectitsadmissionofficeintheclosestbigcity,
which is more than 250 km from university, which type of network out of
LAN, MAN or WAN will be formed? Justify your answer.
Ans WAN as the given distance is more than the range of LAN and MAN.
(1 Mark for correct network type)
(f) WhichofthefollowingwillcomeunderCyberCrime? 1
(i) Theft of a brand new sealed pack Laptop
(ii) AccesstoabankaccountforgettingunauthorizedMoneyTransaction
(iii) Modificationinacompanydatawithunauthorizedaccess
(iv) Photocopying a printed report
Ans. (ii) and (iii)
Note:
No marks to be awarded for any other alternative answer
(½ Mark for each correct option)
(g) Compare open source software and proprietary software. 1
Ans. Open source software refers to a program or software in which the source
code (the form of the program when a programmer writes a program in a
particular programming language) is available to the general public for use
and/ormodificationfromitsoriginaldesignfreeofcharge.
Proprietarysoftwareissoftwarethatisownedbyanindividualoracompany
(usuallytheonethatdevelopedit).Therearealmostalwaysmajorrestrictions
on its use, and its source code is almost always kept secret.
(½ Mark for each correct explanation/comparison)
MARKING SCHEME COMPUTER SCIENCE
QUESTION PAPER CODE 91
EXPECTEDANSWERS
1. (a) What isthedifferencebetweenTypeCastingandAutomaticTypeconversion?
Also, give a suitable C++ code to illustrate both.
Ans AutomaticTypeConversion:Itisanimplicitprocessofconversionofadata
from one type to another. For example:
373
int N = 65;
char C = N; //Automatic type conversion ; conversion
cout<<C;
Type Casting: It is an explicit process of conversion of a data from one type
to another. For example
intA=1, B=2;
float C = (float)A/B; //Type Casting
cout<<C;
(½ Mark for each correct explanation of Automatic Type Conversion
and Type Casting)
(½ Mark for each correct example of Automatic Type Conversion and
Type Casting)
OR
(Full 2 Marks for correct example(s) demonstrating the meaning of /
difference between Automatic Type Conversion and Type Casting)
OR
(Only 1 Mark to be awarded if Explanation is given without supporting
example)
(b) Write the names of the header files, which is/are essentially required torun/
executethefollowingc++code:
voidmain()
{
charCH,Text[]="+veAttitude";
for (int I=0 ; Text[I] ! ='0' ;I++)
if (Text[I]== ' ')
cout<<end1;
else
{
374
CH=toupper (Text [I]) ;
cout<<CH;
}
}
Ans iostream.h
ctype.h
(½ Mark for writing each correct header file)
(c) Rewritethefollowingprogramafterremovingthesyntacticalerrors(ifany).
Underlineeachcorrection. 2
include<iostream.h>
typedef char [80] String;
voidmain()
{
StringS="Peace";
intL=strlen(S);
cout<<S<< 'has'<<L<< 'characters'<<end1;
}
Ans #include<string.h>
#include<iostream.h>
typedef char String [80];
voidmain()
{
String S = "Peace";
intL=strlen(S);
cout<<S<< "has" << L << "characters"<<end1;
}
375
(½ Mark for writing # include<string.h>
(½ Mark for adding # before include<iostream.h>
(½ Mark for writing typedef char string[80];)
(½ Mark for writing "has" and "characters")
(d) Findtheoutputofthefollowingprogram: 3
#include<iostream.h>
void SwitchOver(intA[ ], int N, int Split)
{
for (int K=0 ; K<N; K++)
if(K<Split)
A(K]+ =K;
else
A [K]*=K;
}
void Display (intA[ ], int N)
{
for (int K=0 ; K<N ; K++)
(K%2==0)? cout<<A[K]<<"%":cout<<A(K]<<end1;
}
voidmain()
{
int H[ ]= {30,40,50,20,10,5};
SwitchOver (H, 6, 3);
Display(H,6);
}
376
Ans 30%41
52%60
40%25
(1 Mark for each line with correct values)
Note:
Deduct½Markifany/all'%tmissing
Deduct ½ Mark if endl is not considered at the right positions
(e) Findtheoutputofthefollowingprogram: 2
#include<iostream.h>
voidmain()
{
int *Queen, Moves [ ] = {11, 22, 33, 44};
Queen = Moves;
Moves [2] + = 22;
Cout<< "Queen @"<<*Queen<<end1;
*Queen - = 11;
Queen + = 2;
cout<< "Now @"<<*Queen<<end1;
Queen++;
cout<<"Finally@"<<*Queen«end1;
cout<< "New Origin @"<<Moves[0]<<end1;
}
Ans Queen @11
Now @55
Finally@44
New origin @0
377
(½ Mark for writing each line of output correctly)
Note:
Deduct ½ Mark if any/all '@' missing or/and endl is not considered at
the right positions
(f) Go through the C++ code shown below, and find out the possible output or
outputsfromthesuggestedOutputOptions(i)to(iv).Also,writetheminimum
andmaximumvalues,whichcanbeassignedtothevariableMyNum. 2
#include<iostream.h>
#include<stdlib.h>
voidmain()
{
randomize ( ) ;
intMyNum,Max=5;
MyNum = 20 + random (Max) ;
for (int N=MyNum; 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
Ans ii) 22*23*24*25*
Minimumvalue20
Maximumvalue24
(1 Marie for mentioning correct option)
(½ Mark for mentioning correct minimum value of MyNum)
(½ Marie for mentioning correct maximum value of MyNum)
378
2. (a) DifferentiatebetweenConstructorandDestructorfunctionwithrespectto
ObjectOrientedProgramming. 2
Ans Constructor Destructor
It is a special member function of class It is a special member function of class
withthefollowinguniquefeatures: withthefollowinguniquefeatures:
It has same name as the name of the It has same name as the name of the
class they belong to. class preceded by a symbol ~ (tilde).
It has no return type. It has no return type.
Itisdefinedinpublicvisibilitymode Itisdefinedinpublicvisibilitymode
Itisautomaticallycalledand Itisautomaticallycalledand
executed at the time of executed when scope of an object
creation/declaration of the object gets over
Constructor can be overloaded. Moreover,destructorfunctionscan
NOT be overloaded.
classTrial classItem
} {
inta,b; public:
public: Item ( )
Trial ( ) {a=0;b=0;}//Constructor {cout<<"ItemManufactured.."<<endl}
void Disp ( ) void Working ( )
{ {cout<<"ItemisWorking"<<endl;}
cout<<a<<b<<endl; ~Item()//Destructor
} {cout<<"Itemdestroyed..."«end1}
} ; } ;
voidmain() voidmain()
{ {
TrialT;//Constructorinvoked ItemI;
T . Disp ( ) ; I . Working ( ) ;
379
} for (int C=0; C<2; C++)
{
ItemJ;
J.Working ( ) ;
}// Call of Destructor for J
}// Call of Destructor for I
(1 Marie for correct explanation OR example illustrating a Constructor)
(1 Marie for correct explanation OR example illustrating a Destructor)
(b) Write the output of the following C++ code.Also, write the .name of feature
of Object Oriented Programming used in the following program jointly
illustratedbythefunction[I]to[IV] 2
#include<iostream.h>
void Line ( ) //Function[I]
{
for (int L=1;L<=80;L++) cout<<"-";
cout<<end1;
}
voidLine(intN) //Function[II]
{
for(intL=l;L<=N;L++) Cout<<"*";
cout<<endl;
}
void Line (char C, int N) //Function[III]
{
for(intL=l;L<=N;L++) cout<<C;
cout<<end1;
}
380
void Line (int M, int, N) //Function[IV]
{
for (int L=1;L<=N;L++) cout<<M*L;
cout<<end1;
}
voidmain()
{
intA=9, B=4, C=3;
char K= '#' ;
Line(K,B);
Line(A,C);
}
Ans ####
91827
PolymorphismORFunctionOverloading
(½ Mark for writing each correct line of output)
(1 Mark for writing the feature. name correctly)
(c) DefineaclassApplicantinC++withfollowingdescription: 4
PrivateMembers
Adata memberANo (Admission Number) of type long
A data member Name of type string
Adata memberAgg (Aggregate Marks) of type float
A data member Grade of type char
AmemberfunctionGradeMe()tofindtheGradeaspertheAggregate
Marks obtained by a student. EquivalentAggregate Marks range and
the respective Grades are shown as follows:
381
AggregateMarks Grade
>=80 A
less than 80 and >=65 B
less than 65 and >=50 C
less than 50 D
PublicMembers
AfunctionENTER()toallowusertoentervaluesforANo,Name,Agg
& call function GradeMe() to find the Grade.
Afunction_RESULT()toallowusertoviewthecontentofallthedata
members.
Ans classApplicant
{
longANo;
char Name [20] ;
floatAgg;
char Grade;
void Grademe ( ) ;
public:
void Enter ( ) ;
void Result ( ) ;
} ;
voidApplicant::GradeMe()
{
if(Agg>=80)
Grade=' A' ;
elseif(Agg>=65)
Grade=' B' ;
382
elseif(Agg>=50)
Grade=' C' ;
else
Grade=' D' ;
}
voidApplicant::Enter()
{
cin>>ANo;
gets (Name) ;
cin>>Agg;
GradeMe() ;
}
voidApplicant::Result()
{
cout<<ANo<<Name<<Agg<<Grade<<end1;
}
(½ Mark for correct syntax for class header)
(½ Mark for correct declaration of data members)
(1 Mark for correct definition of GradeMe( ))
(1 Mark for correct definition of Enter() with proper invocation of
GradeMe( ) function)
(1 Mark for correct definition of Result())
NOTE:
½ mark to be deducted if Grademe() is not invoked within Enter()
No marks to be deducted if member function definitions are inside the
Class
383
(d) Answerthequestions(i)to(iv)basedonthefollowing: 4
classStudent
{
intRollno:
char SName[20];
floatMarksl;
protected:
void Result ( ) ;
public:
Student ( ) ;
void Enroll ( ) ;void Display ( ) ;
} ;
classTeacher
{
longTCode;
char TName [20];
protected:
floatSalary;
public:
Teacher ( );
void Enter ( ) ;
void Show ( ) ;
} ;
class Course: public Student, private Teacher
}
long CCode [10]; char CourseName [50];
char StartDate [8] , EndDate [8];
384
public:
Course ( ) ;
void Commence ( );
void CDetail ( ) ;
} ;
(i) Write the names of member functions, which are accessible from objects of
class Course
Ans Commence()
CDetail()
Enroll()
Display()
(1 Mark for correct answer)
Note:
No marks to be awarded for a partially correct answer
Constructorfunctionstobeignored
ii) Writethenamesofallthedatamembers,whichis/areaccessiblefrommember
functionCommenceofclassCourse
Ans CCode
CourseName
StartDate
EndDate
Salary
(1 Mark for correct answer)
Note:
No marks to be awarded for a partially correct answer
iii) Write the names of all the-members, which are accessible from objects of
classTeacher.
Ans Enter( ), Show( )
385
(1 Mark for correct answer)
Note:
No marks to be awarded for a partially correct answer
Constructorfunctionstobeignored
iv) Which type of Inheritance is illustrated in the above C++ code?
Ans MultipleInheritance
(1 Mark for correct answer)
Note:
No marks to be awarded for a partially correct answer
3. (a) Write a Get2From1() function in C++ to transfer the content from one array
ALL[] to two different arrays Odd[] and Even[]. The Odd[] array should
contain the values from odd positions (1,3,5,...) ofALL[] and Even [] array
should contain the values from even positions (0, 2, 4,…..) ofALL[]. 3
Example
IftheALL[]arraycontains
12, 34, 56, 67, 89, 90
The Odd[] array should contain
34, 67, 90
And the Even [] array should contain
12,56,89
Ans voilGet2From1(intAll[],intEven[],intOdd[],intSize)
{
int J=0,K=0;
for (int I=0 ;I<Size; 1++)
{
if(I%2==0)
{
386
Even[J]=All[I];
J++;
}
else
{
Odd[K]=All[I);
K++;
}
}
}
(1 Mark for correct loop)
(½ Mark for checking even locations)
(½ Mark for checking odd locations or writing else for even locations)
(½ Mark for assigning elements to the corresponding Even and Odd Array)
(½ Mark for incrementing Even and Odd Array Locations)
(b) An array G[50][20] is stored in the memory along the row with each of its
elementsoccupying8bytes.FindoutthelocationofG[10][15],ifG[0][0]is
stored at 4200. 3
Ans AssumingLBR=LBC=0
B=4200
W=8 bytes
Number of Rows(N)=50
Number of Columns (M)=20
LOC(Arr[I] [J]) = B +(I*M + J) *W
LOC (Arr [10] [15]) = 4200+ (10*20+15)*8
= 4200 + (215*8)
= 4200+1720
= 5920
387
(1 Mark for writing correct formula (for row major)
OR substituting formula with correct values for calculating Address)
(2 marks for calculating correct address)
Note:
1 mark to be awarded for writing only the correct answer i.e. 5920, without
showinganyformula/calculation.
(c) WriteafunctioninC++toperformDelete operationona dynamicallyallocated
QueuecontainingMembersdetailsasgiveninthefollowingdefinitionofNODE: 4
struct NODE
{
longMno //MemberNumber
char Mname[20]; //Member Name
NODE*Link;
};
Ans class Queue
{
NODE *Front, *Rear;
public:
Queue ( ) {Front = NULL; Rear = NULL; }
void QueAdd ( );
void QueDel ( );
void QueDis ( );
~Queue();
} ;
void Queue: :QueDel ( )
{
if(Front!=NULL)
388
{
NODE *Temp=Front;
cout<<Front->Mno<< " " ;
cout<<Front->Mname<<"Deleted";
Front=Front->Link;
deleteTemp;
if (Front==NULL) Rear=NULL;
}
else
cout<<"Underflow!Queueisempty..";
}
(1 Mark for checking Empty Queue)
(½ Mark for assigning Front to Temp)
(1 Mark for reassigning Front with Front->Link)
(1 Mark for deleting Temp)
(½ Mark for assigning Rear with NULL if Queue becomes Empty)
(d) WriteaDSUMOfunctioninC++tofindsumofDiagonalElementsfroma
NxN Matrix. 2
(Assuming that the N is a odd number)
Ans void DSUM (intA[ ] [100] ,int N)
{
int SUMR =0, SUML=0;
for(inti=0;i<N;i++}
{
SUMR=SUMR +A[i] [i] ;
SUML = SUML +A[i] [N-1-i] ;
}
389
cout<< " Sum of Diagonal Elements = "<<SUMR + SUML –
A[N/2] [N/2] ;
}
OR
void DSUM (intA[] [100], int N)
{
int SUMR =0, SUML=0;
for (int i=0; i<N; i++)
{
SUMR = SUMR +A[i] [i] ;
SUML = SUML +A[i] [N-1-i] ;
}
cout<<"SumofRightDiagonalElements="<<SUMR<<end1;
cout<<"SumofLeftDiagonalElements="<<SUML<<end1;
}
OR
void DSUM (intA[] [100] , int N)
{
int SUMR =0, SUML=0;
for (int i = 0; i<N; i++)
{
for (int j = 0; j<N; j++)
{
if(i==j)
SUMR=SUMR +A[i] [j] ;
else if (i+j == N-1)
SUML= SUML+A[i] [j];
390
}
}
cout<< "Sum of Diagonal Elements ="<< SUMR + SUML-A[N/2] [N/2];
}
(½ Mark for writing correct Function Header)
(½ Mark for writing correct loop)
(1 Mark for finding sum of Right Diagonal Elements and/or Left Diagonal
Elements)
(e) Evaluatethefollowingpostfixnotationofexpression: 2
True, False, NOT,AND, True, True,AND,OR
Ans Element Scanned STACK Status
True TRUE
False TRUE,FALSE
NOT TRUE,TRUE
AND TRUE
True TRUE,TRUE
True TRUE,TRUE,TRUE
AND TRUE,TRUE
OR TRUE
FinalResult:TRUE
(½ Mark for evaluating each operator correctly)
OR
(½ Mark only for writing TRUE as the final answer without showing
any calculation/Stack)
4. (a) Observetheprogramsegmentgivenbelowcarefullyandfilltheblanksmarked
as Statement 1 and Statement 2 using seekg( ), seekp( ) tellp( ) and tellg( )
functionsforperformingtherequiredtask. 1
391
#include<fstream.h>
classITEM
{
intIno;charIname[20];floatPrice;
public:
voidModifyPrice();//Thefunctionistomodify
price of a particular ITEM
} ;
voiditem::ModiyPrice()
{
fstreamFile;
File.open("ITEM.DAT",ios::binary|ios::in|ios::out)||;
intCIno;
cout<<"ItemNotomodifyprice:";cin>>CIno;
while(file.read((char*)this,sizeof(ITEM)))
{
if(CIno==Ino)
{
cout<<"PresentPrice:"<<Price<<end1;
cout<<"Changedprice:";cin>>Price;
int FilePos = __________ ; //Statement 1,
___________________; //Statement 2
File.write((char*)this,sizeof(ITEM));
// Re-writing the record
}
}
File.close( ) ;
}
392
Ans Option 1
Statement 1: File.tellp ( ) ; OR File. tellg ( ) ;
Statement 2: File.seekp (FilePos - sizeof (ITEM) ) ;
OR File.seekp(-sizeof(ITEM),ios::cur));
OR File.seekg(FilePos-sizeof(ITEM));
OR. File.seekg(-sizeof(ITEM),ios::cur));
Ogtion2
Statement 1: File. tellp ( ) – sizeof (ITEM) ;
OR File.tellg()-sizeof(ITEM);
Statement 2: File.seekp (FilePos) ;
OR File.seekg (FilePos) ;
(½ Mark for writing Statement 1 correctly)
(½ Mark for writing Statement 2 correctly)
(b) Write a function in C++ to count the no. of "He" or "She" words present in a
textfile"STORY.TXT". 2
Ifthefile"STORY.TXT"contentisasfollows:
Heisplayingintheground.Sheis
Playingwithherdolls.
Theoutputofthefunctionshouldbe
CountofHe/Sheinfile:2
Ans void COUNT ( )
{
ifstreamFil("STORY.TXT");
char STR [10];
int count = 0;
while(!Fil.eof())
{
393
Fil>>STR;
if (strcmp (STR, "He") ==0 | | strcmp (STR, "She") = =0)
count++;
}
Cout<<"CountofHe/Sheinfile:"<<count<<end1;
Fil.close();//Ignore
}
OR
Anyothercorrectfunctiondefinitionperformingthedesiredoperation
(½ Mark for opening STORY. TXT correctly)
(½ Mark for reading each word (Whichever method adopted) from the file)
(½ Mark for comparing the word with 'He' and 'She' and incrementing counter)
(½ Mark for displaying the count of 'He/She' with/without the Text Message)
Note:IgnorecasesensitivityforHe/She
(c) Write a function in C++ to search for a camera from a binary file
"CAMERA.DAT" containing the objects of class" CAMERA (as defined
below). The user should enter the Model No and the function should search
display the details of the camera. 3
classCAMERA
{
longModelNo;
floatMegaPixel;
intZoom;
charDetails[120];
public:
voidEnter(){cin>>ModelNo>>MegaPixel>>Zoom;gets(Details);}
voidDisplay()
{cout<<ModelNo<<MegaPixel<<Zoom<<Details<<endl;}
long GetModelNo ( ) {return ModelNo;}
};
394
Ans void Search ( )
{
CAMERAC;
longmodelnum;
cin>>modelnum;
ifstreamfin;
fin.open("CAMERA.DAT",ios::binary|ios::in);
while(fin.read((char*)&C,sizeof(C)))
{
if (C. GetModelNo ( ) modelnum)
C.Display();
}
Fin.close( ) ; //Ignore
}
OR
voidSearch(longmodelnum)
{
CAMERAC;
ifstreamfin;
fin.open("CAMERA.DAT",ios::binary|ios::in);
while(fin.read((char*)&C,sizeof(C)))
{
if (C.GetModelNo() = = modelnum)
C. Display ();
}
Fin.close();//Ignore
}
395
(½ Mark for declaring and entering a model number for a camera to
search
OR passing it as a parameter to the function)
(½ Marie for opening CAMERA.DAT in correct mode)
(½ Marie for reading each record from CAMERA.DAT)
(½ Marie for correct loop / checking end of file)
(½ Marie for comparing value returned by GetModelNo() with model
number entered)
(½ Marie for displaying the matching record)
5. (a) What do you understand by Selection & Projection operations in relational
algebra? 2
Ans Projectionforselectingthecolumnsoftable
Selection for selecting the rows of table
(1 Marie for correct explanation of Projection)
(1 Marie for correct explanation of Selection correctly)
OR
(Full 2 Marks for correct example(s) demonstrating the meaning of
Projection & Selection)
Consider the following tables EMPLOYEE and SALGRADE and answer
(b) and (c) parts of this question:
Table: EMPLOYEE
ECODE NAME DESIG SGRADE DOJ DOB
101 AbdulAhmad EXECUTIVE S03 23-Mar-2003 13-Jan-1980
102 Rav:i.Chander HEAD-IT S02 12-Feb-2010 22-Jul-1987
103 John Ken RECEPTIONIST S03 24-June-2009 24-Feb-1983
105 NazarAmeen GM S02 11-Aug-2006 03-Mar-1984
108 PriyamSen CEO S01 29-Dec-2004 19-Jan-1982
396
Table:SALGRADE
SGRADE SALARY HRA
S0l 56000 18000
S02 32000 12000
S03 24000 8000
(b) WriteSQLcommandsforthefollowingstatements:
(i) To display the details of all EMPLOYEEs, in descending order of DOJ
Ans SELECT * FROM EMPLOYEE ORDER BY DOJ DESC;
(1 Mark for correct query)
OR
(½ Mark for partially correct answer)
(ii) TodisplayNAMEandDE51GofthoseEMPLOYEEs,whose5ALGRADE
is either 502 or 503
Ans SELECT NAME, DESIG FROM EMPLOYEE
WHERE SGRADE = 'S02' OR SGRADE= 'S03';
OR
SELECT NAME, DESIG FROM EMPLOYEE
WHERE SALGRADE ='S02' OR SALGRADE='S03';
(1 Mark for correct query)
OR
(½ Mark for partially correct answer)
(iii) To display the content of all the EMPLOYEEs table, whose DOJ is in
between'09-Feb-2006' and '08-Aug-2009'.
Ans SELECT * FROM EMPLOYEE
WHERE DOJ BETWEEN '09-Feb-2006'and '08-Aug-2009';
OR
SELECT * FROM EMPLOYEE
WHERE DOJ > = '09-Fab-2006' and DOJ <='08-Aug-2009';
397
OR
SELECT * FROM EMPLOYEE
WHERE DOJ > '09-Feb-2006' and DOJ <' 08-Aug-2009" ;
(1 Mark for correct query)
OR
(½ Mark for partially correct answer)
(iv) Toaddanewrowwiththefollowing:
109, 'Harish Roy', 'HEAD-IT', 'S02', '09-Sep-2007, '21-Apr-1983'
Ans INSERT INTO EMPLOYEE
VALUES(109,'Harish Roy' ,'HEAD-IT' ,'S02' ,'09-Sep-2007' ,'21-Apr-
1983' ) ;
(1 Mark for correct query)
OR
(½ Mark for partially correct answer)
(c) Give:theoutputofthefollowingSQLqueries: 2
(i) SELECT COUNT (SGRADE),SGRADE FROM EMPLOYEE GROUP
BYSGRADE;
Ans COUNT (SGRADE) SGRADE
1 S01
2 S02
2 S03
(½ Mark. for correct output)
(ii) SELECT MIN(DOB), MAX (DOJ) FROM EMPLOYEE;
Ans MIN (DOB) MAX (DOJ)
13-Jan-1980 12-Feb-2010
(½ Mark for correct output)
398
(iii) SELECT NAME , SALARYFROM EMPLOYEE E, SALGRADE S WHERE
E.SGRADE= S.SGRADEAND E.ECODE<103;
Ans Name Salary
AbdulAhmad 24000
RaviChander 32000
(½ Mark for correct output)
(iv) SELECTSGRADE,SALARY+HRAET:)MSALGRADEWHERESGRADE=
'S02';
Ans SGRADE SALARY+HRA
S02 44000
(½ Mark for correct output)
6 (a) YerifythefollowingusingTruthTable: 2
X+Y. Z=(X+Y).(X+Z)
Ans X Y Z Y.Z X+Y.Z X+Y X+Z (X+Y).(X+Z)
0 0 0 0 0 0 0 0
0 0 1 0 0 0 1 0
0 1 0 0 0 1 0 0
0 1 1 1 1 1 1 1
1 0 0 0 1 1 1 1
1 0 1 0 1 1 1 1
1 1 0 0 1 1 1 1
1 1 1 1 1 1 1 1
VERIFIED
( 2 Mark for correct verification using Truth Table)
NOTE: No marks are to be awarded if only algebraic proof is given.
399
(b) WritetheequivalentBooleanExpressionforthefollowingLogicCircuit: 2
Ans F = P.Q' + P.R'
(2 Marks for the final expression P.Q'+P.R')
OR
(1 Mark for anyone of the correct terms out of P .Q' or P .R'
(c) Write the SOPform of a Boolean function F, which is represented in a truth
tableasfollows: 1
U V W F
0 0 0 1
0 0 1 0
0 1 1 1
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 1
Ans F(U, V, W) = U'.V'.W'+ U'.V.W + U.V.W'+ U.V.W
(1 Mark for the correct SOP form)
Note: Deduct ½ mark if wrong variable names are used
(d) ReducethefollowingBooleanExpressionusingK-Map: 3
F(A, B,C, D) = Σ (0,1, 2, 4, 5, 6, 7, 8, 10)
400
A' B' A' B AB AB'
C' D' 1 1 1
C' D 1 1
C D
C D' 1 1 1
OR
C'D' C'D CD CD'
A' B' 1 1 1
A' B 1 1 1
AB
AB' 1 1
Ans F (A,B,C,D) = A'C' + A'D' + B'D'
(½ Mark for placing all 1s at correct positions in K-Map)
(½ Mark for each grouping)
(1 Mark for writing final expression in reduced/minimal form)
Note : Deduct ½ mark if wrong variable names are used
7. (a) In networking, what-is WAN? How is it different from LAN? 1
Ans A WAN (wide area network), is not restricted to a geographical location,
althoughitmightbeconfinedwithintheboundsofastateorcountry.AWAN
connects several LANs, and may be limited to an enterprise (a corporation
or an organization) or accessible to the public. The technology is high speed
and relatively expensive. The Internet is an example of a worldwide public
WAN.
A LAN (local area network) is a group of computers and network devices
connectedtogether,usuallywithinthesamebuildingorcampus.
(½ Marks for writing WAN correctly)
(½ Marks for writing LAN correctly)
401
(b) DifferentiatebetweenXMLandHTML. 1
Ans TheExtensibleMarkupLanguage(XML)wasinitiallyvisualizedasalanguage
for defining new document formats for the World WideWeb. XMLis text-
based formats that provide mechanisms for describing document structures
with the help of user defined Tags.
HTML - short for Hypertext Markup Language is the predominant markup
language for the creation of web pages. It provides a means to describe the
structureoftext-basedinformationinadocumentbydenotingcertaintextas
headings,paragraphs,lists,andtosupplementthattextwithinteractiveforms,
embedded images, and other objects using predefined Tags.
(½ Marks for explaining XML correctly)
(½ Marks for explaining HTML correctly)
OR
(½ Mark Only if correct expansion of both the terms XML and HTML
are given)
(c) What is WEB2.0? 1
Ans The term Web 2.0 is associated with web applications that facilitate
participatoryinformationsharing,interoperability,user-centereddesign,
and collaboration on the World Wide Web. Web 2.0 is also used for
social networking. Example: Social Networking Sites, Blogs, Facebook,
VideoSharingSites,VideoConferencingApplicationsetc.
(1 Mark for correctly explaining Web 2.0 - anyone of the highlighted
text to be consider appropriate)
Note: Only ½ Mark for mentioning an example or an improved Web
Application of WWW
(d) Out of the following, identify client side script (s) and server side script (s). 1
(i) Javascript
(ii) ASP
(iii) vbscript
(iv) JSP
402
Ans Javascript & vbscript are client side scripts
JSP &ASPare server side scripts
(½ Mark for writing correct 'Client Side Scripts)
( ½ Mark for writing correct Server Side Scripts)
(e) Great Studies University is setting up itsAcademic schools at Sunder Nagar
andplanningtosetupanetwork.Theuniversityhas3academicschoolsand
oneadministrationcenterasshowninthediagrambelow: 4
Center to center distances between various buildings is as follows :
Law School to Business School 60m
Law School to Technology School 90m
Law School toAdmin Center 115m
BusinessSchooltoTechnologySchool 40m
BusinessSchoolto.AdminCenter 45m
TechnologySchooltoAdminCenter 25m
Number of Computers in each of the Schools/Center is follows:
LawSchool 25
TechnologySchool 50
AdminCenter 125
BusinessSchool 35
403
(i) Suggest the most suitable place (i.e. School/Center) to install the server of this
universitywithasuitablereason. 1
Ans Option 1 :
Admin center as it has the most number of computers
Option 2.
BusinessSchoolasitwillrequireminimumcablelengthtoconnectotherblocks
(½ Mark for mentioning the correct place)
(½ Mark for mentioning a valid reason)
OR
(1 Mark for any other location with a valid reason)
(ii) Suggest an ideal layout for connecting these schools/ center for a wired
connectivity. 1
Ans Option1:
Option2:
404
(1 Mark for mentioning any valid connectivity or topology or diagram
connecting various compounds inside the campus)
(iii) Which device will you suggest to be placed/installed in each of these schools /
centertoefficientlyconnectallthecomputerswithintheseschools/center? 1
Ans Switch
(1 Mark for mentioning correct device)
NOTE:Award1fullmarkifHub/Switchismentioned.
(iv) Theuniversityisplanningtoconnectitsadmissionofficeintheclosestbigcity,
whichismorethan350kmfromtheuniversity.Whichtypeofnetworkoutof
LAN, MAN or WAN will be formed? Justify your answer. 1
Ans WAN as the distance is more than the range of LAN or MAN. 1
(1 Mark for correct network type)
(f) Compare Open Source Software and Proprietary Software. 1
Ans Open source software refers to a program or software in which the source
code (the form of the program when a programmer writes a program in a
particular programming language) is available to the general public for use
and/ormodificationfromitsoriginaldesignfreeofcharge.
Proprietarysoftwareissoftwarethatisownedbyanindividualoracompany
(usuallytheonethatdevelopedit).Therearealmostalwaysmajorrestrictions
on its use, and its source code is almost always kept secret.
(1 Mark for correct/valid comparison)
OR
( Mark for defining each term correctly)
(g) What are cookies? 1
Ans A small piece of information that a server sends to a client. When a person
visitsaWebsitewithcookiecapabilities,itsserversendscertaininformation
about him/her to the browser, which is stored on his/her hard drive as a text
file.At some later time (such as returning to the site the next day), the server
retrieves the cookie.
(1 Mark for correct definition)
1
COMPUTER SCIENCE (Theory)
Class XII - Code : 083
Blue Print
S.No. UNIT VSA SA I SA II LA TOTAL
(1 Mark) (2 Marks) (3 Marks) (4 Marks)
1 Review of C++ covered in Class XI 1 (1) 8 (4) 3 (1) 12 (6)
2 Object Oriented Programming in C++
a) Introduction to OOP using C++ 2 (1) 4 (1) 6 (2)
b) Constructor & Destructor 2 (1) 2 (1)
c) Inheritance 4 (1) 4 (1)
3 Data Structure & Pointers
a) Address Calculation 3 (1) 3 (1)
b) StaticAllocation of Objects 2 (1) 3 (1) 5 (2)
c) DynamicAllocation of Objects 4 (1) 4 (1)
d) Infix & Postfix Expressions 2 (1) 2 (1)
4 Data File Handling in C++
a) Fundamentals of File Handling 1 (1) 1 (1)
b) Text File 2 (1) 2 (1)
c) Binary Files 3 (1) 3 (1)
5 Databases and SQL
a) Database Concepts 2 (1) 2 (1)
b) Structured Query Language 2 (1) 4 (1) 6 (2)
2
6 Boolean Algebra
a) Introduction to BooleanAlgebra
& Laws 2 (1) 2 (1)
b) SOP & POS 1 (1) 1 (1)
c) Karnaugh Map 3 (1) 3 (1)
d) Basic Logic Gates 2 (1) 2 (1)
7 Communication & Open Source
Concepts
a) Introduction to Networking 2 (2) 2 (2)
b) Media,Dvices,Topologies &
Protocols 4 (1) 4 (1)
c) Security 2 (2) 2 (2)
d) Webservers 1 (1) 1 (1)
e) Open Source Terminologies 1 (1) 1 (1)
TOTAL 9 (9) 26 (13) 15 (5) 20 (5) 70 (32)
3
COMPUTER SCIENCE (Theory)
Class XII - Code : 083
Design of Question Paper for 2009-2010
TIME : 3 Hrs MM : 70
Weightage of marks over different dimensions of the question paper shall be as follows:
A. Weightage to different topics/content units
S.No Topics Marks
1 Review of C++ covered in Class XI 12
2 Object Oriented Programming in C++ 12
3 Data Structure & Pointers 14
4 Data File Handling in C++ 06
5 Databases and SQL 08
6 BooleanAlgebra 08
7 Communication and Open Source Concepts 10
Total 70
B. Weightage to different forms of questions
S.No Forms of Questions Marks for No. of Total
each question Questions Marks
1 Very ShortAnswer questions (VSA) 01 09 09
2 Short answer questions - Type I (SAI) 02 13 26
3 Short answer questions - Type II (SAII) 03 05 15
4 Long answer questions (LA) 04 05 20
Total 32 70
C. Scheme of Options
There will be no overall choice.All questions are compulsory.
D. Difficulty level of questions
S.No. Estimated difficulty level Percentage of marks
1 Easy 15%
2 Average 70%
3 Difficult 15%
• Based on the above design, two sets of sample papers along with their blue prints and Mark-
ing schemes have been included in this document.
• About 20% weightage has been assigned to questions testing higher order thinking (HOT)
skills of learners.
4
COMPUTER SCIENCE (Theory) - Class XII
Sample Question Paper–I
Subject Code - 083
TIME : 3 Hrs MM : 70
1.
(a) What is the difference between Global Variable and Local Variable? Also, give
a suitable C++ code to illustrate both. 2
(b) Which C++ header file(s) will be essentially required to be included to run /
execute the following C++ code: 1
void main()
{
char Msg[ ]="Sunset Gardens";
for (int I=5;I<strlen(Msg);I++)
puts(Msg);
}
(c) Rewrite the following program after removing the syntactical errors (if any).
Underline each correction. 2
#include [iostream.h]
class MEMBER
{
int Mno;float Fees;
PUBLIC:
void Register(){cin>>Mno>>Fees;}
void Display{cout<<Mno<<" : "<<Fees<<endl;}
};
void main()
{
MEMBER M;
Register();
M.Display();
}
No. Questions Marks
5
No. Questions Marks
(d) Find the output of the following program: 3
#include <iostream.h>
struct GAME
{ int Score, Bonus;};
void Play(GAME &g, int N=10)
{
g.Score++;g.Bonus+=N;
}
void main()
{
GAME G={110,50};
Play(G,10);
cout<<G.Score<<":"<<G.Bonus<<endl;
Play(G);
cout<<G.Score<<":"<<G.Bonus<<endl;
Play(G,15);
cout<<G.Score<<":"<<G.Bonus<<endl;
}
(e) Find the output of the following program: 2
#include <iostream.h>
void Secret(char Str[ ])
{
for (int L=0;Str[L]!='0';L++);
for (int C=0;C<L/2;C++)
if (Str[C]=='A' || Str[C]=='E')
Str[C]='#';
else
{
char Temp=Str[C];
6
No. Questions Marks
Str[C]=Str[L-C-1];
Str[L-C-1]=Temp;
}
}
void main()
{
char Message[ ]="ArabSagar";
Secret(Message);
cout<<Message<<endl;
}
(f) In the following program, if the value of Guess entered by the user is 65, what
will be the expected output(s) from the following options (i), (ii), (iii) and (iv)? 2
#include <iostream.h>
#include <stdlib.h>
void main()
{
int Guess;
randomize();
cin>>Guess;
for (int I=1;I<=4;I++)
{
New=Guess+random(I);
cout<<(char)New;
}
}
(i) ABBC
(ii) ACBA
(iii) BCDA
(iv) CABD
7
No. Questions Marks
2.
(a) What do you understand by Data Encapsulation and Data Hiding? Also, give
a suitable C++ code to illustrate both. 2
(b) Answer the questions (i) and (ii) after going through the following class: 2
class Seminar
{
int Time;
public:
Seminar() //Function 1
{
Time=30;cout<<"Seminar starts now"<<end1;
}
void Lecture() //Function 2
{
cout<<"Lectures in the seminar on"<<end1;
}
Seminar(int Duration) //Function 3
{
Time=Duration;cout<<"Seminar starts now"<<end1;
}
~Seminar()
//Function 4
{
cout<<"Vote of thanks"<<end1;
}
};
i) In Object Oriented Programming, what is Function 4 referred as and when does it get
invoked/called?
ii) In Object Oriented Programming, which concept is illustrated by Function 1 and
Function 3 together? Write an example illustrating the calls for these functions.
8
No. Questions Marks
(c) Define a class TEST in C++ with following description: 4
Private Members
• TestCode of type integer
• Description of type string
• NoCandidate of type integer
• CenterReqd (number of centers required) of type integer
• A member function CALCNTR() to calculate and return the number of centers as
(NoCandidates/100+1)
Public Members
• Afunction SCHEDULE() to allow user to enter values for TestCode,
Description, NoCandidate & call function CALCNTR() to calculate the number of
Centres
• A function DISPTEST() to allow user to view the content of all the data members
(d) Answer the questions (i) to (iv) based on the following: 4
class PUBLISHER
{
char Pub[12];
double Turnover;
protected:
void Register();
public:
PUBLISHER();
void Enter();
void Display();
};
class BRANCH
{
char CITY[20];
protected:
float Employees;
9
No. Questions Marks
public:
BRANCH();
void Haveit();
void Giveit();
};
classAUTHOR : private BRANCH , public PUBLISHER
{
int Acode;
charAname[20];
floatAmount;
public:
AUTHOR();
void Start();
void Show();
};
(i) Write the names of data members, which are accessible from objects belong-
ing to classAUTHOR.
(ii) Write the names of all the member functions which are accessible from ob-
jects belonging to class BRANCH.
(iii) Write the names of all the members which are accessible from member func-
tions of classAUTHOR.
(iv) How many bytes will be required by an object belonging to classAUTHOR?
3. (a) Write a function in C++ to merge the contents of two sorted arrays A & B into
third array C. Assuming array A and B are sorted in ascending order and the
resultant array C is also required to be in ascending order.
(b) An array S[40][30] is stored in the memory along the row with each of the ele-
ment occupying 2 bytes, find out the memory location for the element S[20][10],
if the Base Address of the array is 5000.
(c) Write a function in C++ to perform Insert operation in a dynamically
allocated Queue containing names of students.
(d) Write a function in C++ to find the sum of both left and right diagonal ele-
3
3
4
2
10
No. Questions Marks
ments from a two dimensional array (matrix).
(e) Evaluate the following postfix notation of expression:
20, 30, +, 50, 40, - ,*
4.
(a) Observe the program segment given below carefully and fill the blanks
marked as Statement 1 and Statement 2 using seekp() and seekg() functions
for performing the required task. 1
#include <fstream.h>
class Item
{
int Ino;char Item[20];
public:
//Function to search and display the content from a particular record number
void Search(int );
//Function to modify the content of a particular record number
void Modify(int);
};
void Item::Search(int RecNo)
{
fstream File;
File.open("STOCK.DAT",ios::binary|ios::in);
______________________ //Statement 1
File.read((char*)this,sizeof(Item));
cout<<Ino<<"==>"<<Item<<endl;
File.close();
}
void Item::Modify(int RecNo)
{
fstream File;
File.open("STOCK.DAT",ios::binary|ios::in|ios::out);
2
11
No. Questions Marks
cout>>Ino;cin.getline(Item,20);
______________________ //Statement 2
File.write((char*)this,sizeof(Item));
File.close();
}
(b) Write a function in C++ to count the number of lines present in a text file
"STORY.TXT". 2
(c) Write a function in C++ to search for a BookNo from a binary file "BOOK.DAT",
assuming the binary file is containing the objects of the following class. 3
class
{
int Bno;
char Title[20];
public:
int RBno(){return Bno;}
void Enter(){cin>>Bno;gets(Title);}
void Display(){cout<<Bno<<Title<<endl;}
};
5.
(a) What do you understand by Degree and Cardinality of a table? 2
Consider the following tables ACTIVITY and COACH and answer
(b) and (c) parts of this question:
Table: ACTIVITY
A Code ActivityName Stadium Participants Prize Schedule
Num Money Date
1001 Relay 100x4 StarAnnex 16 10000 23-Jan-2004
1002 High jump StarAnnex 10 12000 12-Dec-2003
1003 Shot Put Super Power 12 8000 14-Feb-2004
1005 Long Jump StarAnnex 12 9000 01-Jan-2004
1008 Discuss Throw Super Power 10 15000 19-Mar-2004
12
No. Questions Marks
Table: COACH
PCode Name Acode
1 Ahmad Hussain 1001
2 Ravinder 1008
3 Janila 1001
4 Naaz 1003
(b) Write SQL commands for the flowing statements: 4
(i) To display the names of all activities with their Acodes in descending order.
(ii) To display sum of PrizeMoney for theActivities played in each of the Stadium
separately.
(iii) To display the coach's name and ACodes in ascending order of ACode from
the table COACH
(iv) To display the content of theActivity table whose ScheduleDate earlier than
01/01/2004 in ascending order of ParticipantsNum.
(c) Give the output of the following SQL queries: 2
(i) SELECT COUNT(DISTINCT ParticipantsNum) FROMACTIVITY;
(ii) SELECT MAX(ScheduleDate),MIN(ScheduleDate) FROMACTIVITY;
(iii) SELECT Name,ActivityName FROMACTIVITYA,COACH C
WHERE A.Acode=C.AcodeAND A.ParticipantsNum=10;
(iv) SELECT DISTINCTAcode FROM COACH;
6.
(a) State and verify Demorgan's Laws algebraically. 2
(b) Write the equivalent Boolean Expression for the following Logic Circuit 2
13
No. Questions Marks
(c) Write the POS form of a Boolean function F, which is represented in a truth table as
follows: 1
U V W F
0 0 0 1
0 0 1 0
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 1
1 1 1 1
(d) Reduce the following Boolean Expression using K-Map: 3
F(A,B,C,D)= (0,1,2,4,5,6,8,10)
7.
a) Compare any two Switching techniques. 1
b) Which of the following is not a Client Side script: 1
(i) VB Script (ii) Java Script
(iii) ASP (iv) PHP
c) If someone has hacked your Website, to whom you lodge the Complain? 1
d) What do you mean by IP Address? How is it useful in Computer Security? 1
e) Knowledge Supplement Organisation has set up its new center at Mangalore
for its office and web based activities. It has 4 blocks of buildings as shown
in the diagram below: 4
14
No. Questions Marks
Center to center distances between various blocks
Black A to Block B 50 m
Block B to Block C 150 m
Block C to Block D 25 m
Block A to Block D 170 m
Block B to Block D 125 m
Block A to Block C 90 m
Number of Computers
BlackA 25
Block B 50
Block C 125
Block D 10
e1) Suggest a cable layout of connections between the blocks.
e2) Suggest the most suitable place (i.e. block) to house the server of this organisation
with a suitable reason.
e3) Suggest the placement of the following devices with justification
(i) Repeater
(ii) Hub/Switch
e4) The organization is planning to link its front office situated in the city in a hilly region
where cable connection is not feasible, suggest an economic way to connect it with
reasonably high speed?
f) What do you mean by Spam Mails? How can you protect your mailbox from Spams? 1
g) Mention any two advantages of Open Source Software over Proprietary Software. 1
15
COMPUTER SCIENCE (Theory) - Class XII
Marking Scheme
Sample Question Paper–I
Subject Code - 083
TIME : 3 Hrs MM : 100
1.
(a) Global Variable Local Variable 2
l It is a variable which is declared l It is a variable which is declared with
outside all the functions in a function or with in a compound
statement
l It is accessible throughout l It is accessible only within a function/
the program compound statement in which it is
declared
#include <iostream.h>
float NUM=900; //NUM is a global variable
void LOCAL(int T)
{
int Total=0; //Total is a local variable
for (int I=0;I<T;I++)
Total+=I;
cout<<NUM+Total;
}
void main()
{
LOCAL(45);
}
(1 Mark for two differences)
No. Answers Marks
16
(1 Mark for the suitable example)
OR
(Full 2 Mark for explanation of differences with the help of an example)
OR
(1 Mark for only example with no explanation)
(b) (i) string.h (ii) stdio.h 1
( ½ Mark for mentioning each correct header filename)
(c) #include <iostream.h> 2
class MEMBER
{
int Mno;float Fees;
public:
void Register(){cin>>Mno>>Fees;}
void Display(){cout<<Mno<<":"<<Fees<<endl;}
};
void main()
{
MEMBER M;
M.Register();
M.Display();
}
( ½ Mark each correction)
(d) 111:60 3
112:70
113:85
(1 Mark for each correct line of output)
No. Answers Marks
17
(e) #agaSbarr 2
(2 Marks for correct line of output)
(f) (i) ABBC 2
(2 Marks for mentioning correct option)
2.
(a) Data Encapsulation: Wrapping up of data and functions together in a single unit is 2
known as Data Encapsulation. In a class, we wrap up the data and functions together
in a single unit.
Data Hiding: Keeping the data in private visibility mode of the class to prevent it from
accidental change is known as Data Hiding.
class Computer
{
char CPU[10];int RAM;
public: Data Encapsulation
void STOCK();
void SHOW();
};
( ½ Mark each for appropriate definitions)
(1 Mark for appropriate example showing both)
(b) i) Destructor, it is invoked as soon as the scope of the object gets over. 2
( ½ Mark for mentioning destructor)
( ½ Mark for remaining answer)
ii) Constructor Overloading (or Function Overloading or Polymorphism)
Seminar S1; //Function 1
Seminar S2(90); //Function 3
( ½ Mark for mentioning the correct concept)
( ½ Mark for the example)
No. Answers Marks
18
(c) class TEST 4
{
int TestCode;
char Description[20];
int NoCandidate,CenterReqd;
void CALCNTR();
public:
void SCHEDULE();
void DISPTEST();
};
void TEST::CALCNTR()
{
CenterReqd=NoCandidate/100 + 1;
}
void TEST::SCHEDULE()
{
cout<<"Test Code :";cin>>TestCode;
cout<<"Description :";gets(Description);
cout<<"Number :";cin>>NoCandidate;
CALCNTR();
}
void TEST::DISPTEST()
{
cout<<"Test Code :"<<TestCode<<endl;
cout<<"Description :"<<Description<<endl;
cout<<"Number :"<<NoCandidate<<endl;;
cout<<"Centres :"<<CenterReqd<<endl;;
}
(½ Mark for correct syntax for class header)
(½ Mark for correct declarations of data members)
(1 Mark for appropriate definition of function CALCNTR())
(1 Mark for appropriate definition of SCHEDULE() with a call for CALCNTR())
(1 Mark for appropriate definition of DISPTEST())
(d) (i) None of data members are accessible from objects belonging to class 4
AUTHOR.
No. Answers Marks
19
No. Answers Marks
(1 Mark for correct answer)
(ii) Haveit(), Giveit()
(1 Mark for correct answer)
(iii) Data members: Employees,Acode, Aname,Amount
Member function: Register(), Enter(), Display(), Haveit(), Giveit(), Start(), Show(),
(1 Mark for correct answer)
(iv) 70
(1 Mark for correct answer)
3. (a) voidAddNSave(int A[ ],int B[ ],int C[ ],int N,int M, int &K) 3
{
int I=0,J=0;
K=0;
while (I<N && J<M)
if (A[I]<B[J])
C[K++]=A[I++];
else
if (A[I]>B[J])
C[K++]=B[J++];
else
{
C[K++]=A[I++];
J++;
}
for(;I<N;I++)
C[K++]=A[I];
for (;J<M;J++)
C[K++]=B[J];
}
( ½ Mark for correct Function Header)
( ½ Mark for correct initialization of required variables)
( ½ Mark for correct formation of loop)
( ½ Mark for appropriate conditions and assignments in the loop)
( ½ Mark for appropriately transferring the remaining elements from first array)
( ½ Mark for appropriately transferring the remaining elements from second array)
20
No. Answers Marks
(b) Given, 3
W=2
N=40
M=30
Base(S)=5000
Row Major Formula:
Loc(S[I][J]) =Base(S)+W*(M*I+J)
Loc(S[20][10]) =5000+2*(30*20+10)
=5000+2*(600+10)
=5000+1220
=6220
(1 Mark for writing correct formula (for column major) OR substituting formula with
correct values)
(1 Mark for writing calculation step - at least one step)
(1 Mark for correct address)
(c) struct NODE 4
{
char Name[20];
NODE *Link;
};
class QUEUE
{ NODE *R,*F;
public:
QUEUE();
void Insert();
void Delete();
};
void QUEUE::Insert()
{
21
No. Answers Marks
NODE *Temp;
Temp=new NODE;
gets(Temp->Name);
Temp->Link=NULL;
if (Rear==NULL)
{
Rear=Temp;
Front=Temp;
}
else
{
Rear->Link=Temp;
Rear=Temp;
}
}
(1 Mark for creating a new node and assigning/entering appropriate values in it)
(1 Mark for checking if Queue is Empty)
(1 Mark for assigning Rear and Front as Temp - if Queue is Empty)
(1 Mark for eassigning Rear->Link as Front and Rear as Temp)
(d) void DiagSum(int M[][4],int N,int M) 2
{
int SumD1=0,SumD2=0;
for (int I=0;I<N;I++)
{
SumD1+=M[I][I];SumD2+=M[N-I-1][I];
}
cout<<"Sum of Diagonal 1:"<<SumD1<<endl;
cout<<"Sum of Diagonal 2:"<<SumD2<<endl;
22
No. Answers Marks
}
( ½ Mark for correct function header)
( ½ Mark for initialization of SumD1 and SumD2 as 0)
( ½ Mark for appropriate loop)
( ½ Mark for correct expression for adding each diagonal elements)
(e) 2
23
(½ Mark for correctly evaluating each operator)
(½ Mark for the correct result)
4. a) 1
File.seekg(RecNo*sizeof(Item)); //Statement 1
File.seekp(RecNo*sizeof(Item)); //Statement 2
(½ Mark for each correct Statement)
(b) 2
void CountLine()
{
ifstream FIL("STORY.TXT");
int LINES=0;
char STR[80];
No. Answers Marks
24
No. Answers Marks
while (FIL.getline(STR,80))
LINES++;
cout<<"No. of Lines:"<<LINES<<endl;
f.close();
}
(½ Mark for opening STORY.TXT correctly)
(½ Mark for initializing a counter variable as 0)
(½ Mark for correctly reading a line from the file)
(½ Mark for correctly incrementing the counter)
(c) void BookSearch() 3
{
fstream FIL;
FIL.open("BOOK.DAT",ios::binary|ios::in);
BOOK B;
int bn,Found=0;
cout<<"Enter Book No. to search…"; cin>>bn;
while (FIL.read((char*)&S,sizeof(S)))
if (FIL.RBno()==bn)
{
S.Display();
Found++;
}
if (Found==0) cout<<"Sorry! Book not found!!!"<<endl;
FIL.close();
}
( ½ Mark for opening BOOK.DAT correctly)
( ½ Mark for reading each record from BOOK.DAT)
( ½ Mark for correct loop / checking end of file)
( 1 Mark for comparing Book number)
( ½ Mark for displaying the matching record)
25
No. Answers Marks
5.
(a) Degree: Number of Columns in a table 2
Cardinality: Number of rows in a table
(1 Mark for each definition)
(b) (i) SELECTAcodes,ActivityName FROM ACTIVITY ORDER BYAcode DESC; 4
(1 Mark for correct query)
OR
(½ Mark for partially correct answer)
(ii) SELECT SUM(PrizeMoney), Stadium FROMACTIVITY GROUP BY Stadium;
(1 Mark for correct query)
OR
(½ Mark for partially correct answer)
(iii) SELECT Name, Acode FROM COACH ORDER BY Acode;
(1 Mark for correct query)
OR
(½ Mark for partially correct answer)
(v) SELECT * FROMACTIVITY WHERE SchduleDate<'01-Jan-2004'
ORDER BY ParticipantsNum;
1 Mark for correct query)
OR
(½ Mark for partially correct answer)
(c) 2
(i) 3
(½ Mark for correct output)
(ii) 19-Mar-2004 12-Dec-2003
(½ Mark for correct output)
26
No. Answers Marks
(iii) Ravinder Discuss Throw
(½ Mark for correct output)
(iv) 1001
1003
1008
(½ Mark for correct output)
6. 2
(X+Y)' = X'.Y'
Verification
(X+Y)'.(X+Y) = X'.Y'.(X+Y)
0 = X'.Y'.X + X'.Y'.Y
0 = X'.X .Y'+ X'.0
0 = 0 .Y'+ 0
0 = 0 + 0
0 = 0
L.H.S = R.H.S
(1 Mark for stating any one of the Demorgan's Law)
(1 Mark for verifying the law)
(b) 2
F(P,Q)=(P'+Q).(P+Q')
(2 Marks for the final expression )
OR
(1 Mark for any one of the correct terms out of P'+Q or P+Q')
(c) F(U,V,W) = (U+V+W').(U+V'+W').(U'+V+W') 1
(1 Mark for the correct expression )
27
No. Answers Marks
(d) 3
F(A,B,C,D)=A'C'+A'D'+B'D'
( ½ Mark for placing all 1s at correct positions in K-Map)
( ½ Mark for each grouping)
(1 Mark for writing final expression in reduced/minimal form)
Note: Deduct ½ mark if wrong variable names are used
7.
a) Appropriate comparison between any two out of Circuit Switching, Message 1
Switching, Packet Switching
(1 Mark for writing Appropriate comparison between any two switching technique)
b) (iii) ASP and (iv) PHP are not client side scripts 1
(1 Mark for correct answer)
c) The complaint has to be lodged with the Police under ITAct 1
(1 Mark for correct answer)
d) An Internet Protocol (IP) address is a numerical identification and logical address 1
that is assigned to devices connected in a computer network.
An IPAddress is used to uniquely identify devices on the Internet and so one can
quickly know the location of the system in the network.
( ½ Mark for meaning of IP Address)
( ½ Mark for mentioning the usefulness in network security)
28
No. Answers Marks
e) e1) (Any of the following option) 4
Layout Option 1:
Layout Option 2: Since the distance between Block A and Block B is quite short
(1 Mark for showing any of the above suitable cable layout)
e2) The most suitable place / block to house the server of this organisation would
be Block C, as this block contains the maximum number of computers, thus
decreasing the cabling cost for most of the computers as well as increasing
the efficiency of the maximum computers in the network.
( ½ Mark for suggesting suitable place and ½ for appropriate reason)
29
No. Answers Marks
e3) (i) For Layout 1, since the cabling distance between Blocks A and C, and that
between B and C are quite large, so a repeater each, would ideally be needed
along their path to avoid loss of signals during the course of data flow in these
routes.
For layout 2, since the distance between Blocks A and C is large so a repeater would
ideally be placed in between this path
( ½ Mark for suggesting suitable place for connecting repeater)
30
No. Answers Marks
(ii) In both the layouts, a hub/switch each would be needed in all the blocks, to
interconnect the group of cables from the different computers in each block
Layout 1
Layout 2
( ½ Mark for suggesting suitable place for connecting hub)
e4) The most economic way to connect it with a reasonable high speed would be to use
radio wave transmission, as they are easy to install, can travel long distances, and
penetrate buildings easily, so they are widely used for communication, both indoors
and outdoors. Radio waves also have the advantage of being omni directional, which
is they can travel in all the directions from the source, so that the transmitter and
receiver do not have to be carefully aligned physically.
( 1 Mark for appropriate answer)
f) Spam mails, also known as junk e-mail, is a subset of spam that involves nearly 1
identical messages sent to numerous recipients by e-mail.
We can protect our mailbox from spams by creating appropriate filters.
( ½ Mark for the definition of Spam Mails)
( ½ Mark for the appropriate suggestion for protecting mailbox from it)
31
No. Answers Marks
g) Open Source's proponents often claim that it offers significant benefits when com- 1
pared to typical Proprietary Software. Proprietary Software typically favour visible
features (giving marketing advantage) over harder-to measure qualities such as sta-
bility, security and similar less glamorous attributes.
Open Source Software developers are evidently motivated by many factors but
favouring features over quality is not noticeable amongst them. For many developers,
peer review and acclaim is important, so it's likely that they will prefer to build software
that is admired by their peers. Highly prized factors are clean design, reliability and
maintainability, with adherence to standards and shared community values preeminent.
( 1 Mark for appropriate answer)
32
No. Questions Marks
COMPUTER SCIENCE (Theory) - Class XII
Sample Question Paper–II
Subject Code - 083
TIME : 3 Hrs MM : 70
1.
(a) What is the difference between Actual Parameter and Formal Parameters?
Also, give a suitable C++ code to illustrate both 2
(b) Write the names of the header files to which the following belong: 1
(i) frexp() (ii) isalnum()
(c) Rewrite the following program after removing the syntactical errors (if any).
Underline each correction. 2
#include <iostream.h>
struct Pixels
{ int Color,Style;}
void ShowPoint(Pixels P)
{ cout<<P.Color,P.Style<<endl;}
void main()
{
Pixels Point1=(5,3);
ShowPoint(Point1);
Pixels Point2=Point1;
Color.Point1+=2;
ShowPoint(Point2);
}
(d) Find the output of the following program: 3
#include <iostream.h>
void Changethecontent(intArr[ ], int Count)
{
for (int C=1;C<Count;C++)
33
No. Questions Marks
Arr[C-1]+=Arr[C];
}
void main()
{
intA[]={3,4,5},B[]={10,20,30,40},C[]={900,1200};
Changethecontent(A,3);
Changethecontent(B,4);
Changethecontent(C,2);
for (int L=0;L<3;L++) cout<<A[L]<<'#';
cout<<endl;
for (L=0;L<4;L++) cout<<B[L] <<'#';
cout<<endl;
for (L=0;L<2;L++) cout<<C[L] <<'#';
}
(e) Find the output of the following program: 2
#include <iostream.h>
struct Game
{
char Magic[20];int Score;
};
void main()
{
Game M={"Tiger",500};
char *Choice;
Choice=M.Magic;
Choice[4]='P';
Choice[2]='L';
M.Score+=50;
cout<<M.Magic<<M.Score<<endl;
34
No. Questions Marks
Game N=M;
N.Magic[0]='A';N.Magic[3]='J';
N.Score-=120;
cout<<N.Magic<<N.Score<<endl;
}
(f) In the following program, if the value of N given by the user is 20, what
maximum and minimum values the program could possibly display? 2
#include <iostream.h>
#include <stdlib.h>
void main()
{
int N,Guessnum;
randomize();
cin>>N;
Guessnum=random(N-10)+10;
cout<<Guessnum<<endl;
}
2.
(a) What do you understand by Polymorphism? Give a suitable example of the
same. 2
(b) Answer the questions (i) and (ii) after going through the following program: 2
class Match
{
int Time;
public:
Match()
//Function 1
{
Time=0;
cout<<"Match commences"<<end1;
35
No. Questions Marks
}
void Details() //Function 2
{
cout<<"Inter Section Basketball Match"<<end1;
}
Match(int Duration) //Function 3
{
Time=Duration;
cout<<"Another Match begins now"<<end1;
}
Match(Match &M) //Function 4
{
Time=M.Duration;
cout<<"Like Previous Match "<<end1;
}
};
i) Which category of constructor - Function 4 belongs to and what is the purpose
of using it?
ii) Write statements that would call the member Functions 1 and 3
(c) Define a class in C++ with following description: 4
Private Members
• A data member Flight number of type integer
• A data member Destination of type string
• A data member Distance of type float
• A data member Fuel of type float
• A member function CALFUEL() to calculate the value of Fuel as per the
following criteria
Distance Fuel
<=1000 500
more than 1000 and <=2000 1100
36
No. Questions Marks
more than 2000 2200
Public Members
" A function FEEDINFO() to allow user to enter values for Flight Number,
Destination, Distance & call function CALFUEL() to calculate the quantity of Fuel
" AfunctionSHOWINFO()toallowusertoviewthecontentofallthedatamembers
(d) Answer the questions (i) to (iv) based on the following: 4
class CUSTOMER
{
int Cust_no;
char Cust_Name[20];
protected:
void Register();
public:
CUSTOMER();
void Status();
};
class SALESMAN
{
int Salesman_no;
char Salesman_Name[20];
protected:
float Salary;
public:
SALESMAN();
void Enter();
void Show();
};
class SHOP : private CUSTOMER , public SALESMAN
{
37
No. Questions Marks
char Voucher_No[10];
char Sales_Date[8];
public:
SHOP();
void Sales_Entry();
void Sales_Detail();
};
(i) Write the names of data members which are accessible from objects belonging to
class CUSTOMER.
(ii) Write the names of all the member functions which are accessible from objects
belonging to class SALESMAN.
(iii) Write the names of all the members which are accessible from member functions of
class SHOP.
(iv) How many bytes will be required by an object belonging to class SHOP?
3.
(a) Write a function in C++ to combine the contents of two equi-sized arrays A
and B by adding their corresponding elements as the formula A[i]+B[i]; where
value i varies from 0 to N-1 and transfer the resultant content in the third same
sized array C. 3
(b) An array P[20][30] is stored in the memory along the column with each of the
element occupying 4 bytes, find out the Base Address of the array, if an
element P[2][20] is stored at the memory location 5000. 3
(c) Write a function in C++ to perform Push operation on a dynamically allocated
Stack containing real numbers. 4
(d) Write a function in C++ to find sum of rows from a two dimensional array. 2
(e) Evaluate the following postfix notation of expression: 2
True, False,AND, True, True, NOT, OR,AND
4.
(a) Observe the program segment given below carefully and fill the blanks marked
as Statement 1 and Statement 2 using seekg() and tellg() functions for
performing the required task. 1
#include <fstream.h>
class Employee
38
No. Questions Marks
{
int Eno;char Ename[20];
public:
//Function to count the total number of records
int Countrec();
};
int Item::Countrec()
{
fstream File;
File.open("EMP.DAT",ios::binary|ios::in);
______________________ //Statement 1
int Bytes =
______________________ //Statement 2
int Count = Bytes / sizeof(Item);
File.close();
return Count;
}
(b) Write a function in C++ to count the number of alphabets present in a text file
"NOTES.TXT". 2
(c) Write a function in C++ to add new objects at the bottom of a binary file
"STUDENT.DAT", assuming the binary file is containing the objects of the
following class. 3
class STUD
{
int Rno;
char Name[20];
public:
void Enter(){cin>>Rno;gets(Name);}
void Display(){cout<<Rno<<Name<<endl;}
};
- To take the file pointer to
the end of file.
- To return total number of
bytes from the beginning of
file to the file pointer.
39
No. Questions Marks
5.
(a) What do you understand by Primary Key & Candidate Keys? 2
Consider the following tables GAMES and PLAYER and answer (b) and (c) parts
of this question:
Table: GAMES
GCode GameName Type Number Prize Schedule
Money Date
101 Carom Board Indoor 2 5000 23-Jan-2004
102 Badminton Outdoor 2 12000 12-Dec-2003
103 Table Tennis Indoor 4 8000 14-Feb-2004
105 Chess Indoor 2 9000 01-Jan-2004
108 Lawn Tennis Outdoor 4 25000 19-Mar-2004
Table: PLAYER
PCode Name Gcode
1 Nabi Ahmad 101
2 Ravi Sahai 108
3 Jatin 101
4 Nazneen 103
(b) Write SQL commands for the flowing statements: 4
(i) To display the name of all GAMES with their GCodes
(ii) To display details of those GAMES which are having PrizeMoney more than
7000.
(iii) To display the content of the GAMES table in ascending order of Schedule
Date.
(iv) To display sum of PrizeMoney for each Type of GAMES
(c) Give the output of the following SQL queries: 2
(i) SELECT COUNT(DISTINCT Number) FROM GAMES;
(ii) SELECT MAX(ScheduleDate),MIN(ScheduleDate) FROM GAMES;
(ii) SELECT Name, GameName FROM GAMES G, PLAYER P
WHERE G.Gcode=P.GcodeAND G.PrizeMoney>10000;
40
No. Questions Marks
(iv) SELECT DISTINCT Gcode FROM PLAYER;
6.
(a) State and algebraically verify Absorption Laws. 2
(b) Write the equivalent Boolean Expression for the following Logic Circuit 2
(c) Write the SOP form of a Boolean function G, which is represented in a truth
table as follows: 1
P Q R G
0 0 0 0
0 0 1 0
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 1
1 1 1 1
(d) Reduce the following Boolean Expression using K-Map: 3
F(U,V,W,Z)= π(0,1,2,4,5,6,8,10)
7.
a) Define the term Bandwidth. Give any one unit of Bandwidth. 1
b) When do you prefer XML over HTML and why? 1
c) How firewall protect our Network? 1
d) What is the importance of URL in networking? 1
e) Ravya Industries has set up its new center at Kaka Nagar for its office and
web based activities. The company compound has 4 buildings as shown in
the diagram below: 4
41
No. Questions Marks
Center to center distances between various buildings is as follows:
Harsh Building to Raj Building 50 m
Raz Building to Fazz Building 60 m
Fazz Building to Jazz Building 25 m
Jazz Building to Harsh Building 170 m
Harsh Building to Fazz Building 125 m
Raj Building to Jazz Building 90 m
Number of Computers in each of the buildings is follows:
Harsh Building 15
Raj Building 150
Fazz Building 15
Jazz Bulding 25
e1) Suggest a cable layout of connections between the buildings.
e2) Suggest the most suitable place (i.e. building) to house the server of this organisation
with a suitable reason.
e3) Suggest the placement of the following devices with justification:
(i) Internet Connecting Device/Modem
(ii) Switch
e4) The organisation is planning to link its sale counter situated in various parts of the
same city, which type of network out of LAN, MAN or WAN will be formed? Justify
your answer.
f) Compare freeware and Shareware. 1
g) How Trojan Horses are different from Worms? Mention any one difference. 1
42
COMPUTER SCIENCE (Theory) - Class XII
Marking Scheme
Sample Question Paper–II
Subject Code - 083
TIME : 3 Hrs MM : 100
1.
(a) Actual Parameter Formal Parameter 2
It is a parameter, which is used in It is a parameter, which is used in
function call to send the value from function header, to receive the value
calling environment from actual parameter
#include <iostream.h>
void Calc(int T) //T is formal parameter
{
cout<<5*T;
}
void main()
{
intA=45;
Calc(A);//A is actual parameter
}
(1 Mark for two differences)
(1 Mark for the suitable example)
OR
(Full 2 Mark for explanation of differences with the help of an example)
(b) (i) math.h (ii) ctype.h 1
( ½ Mark for mentioning each correct header filename)
No. Answers Marks
43
No. Answers Marks
(c) #include <iostream.h> 2
struct Pixels
{ int Color,Style;};
void ShowPoint(Pixels P)
{ cout<<P.Color<<P.Style<<endl;}
void main()
{
Pixels Point1={5,3};
ShowPoint(Point1);
Pixels Point2=Point1;
Point1.Color+=2;
ShowPoint(Point2);
}
( ½ Mark for each correction)
(d) 7#9#5# 3
30#50#70#40#
2100#1200#
(1 Mark for each line of output)
(e) TiLeP550 2
AiLJP430
(1 Mark for each line of output)
(f) Maximum Value: 19 Minimum Value: 10 2
(2 Marks for correct values)
44
No. Answers Marks
2.
(a) Polymorphism: It is a method of using the same operator or function (method) to work 2
using different set of inputs. Function overloading is one of the examples of polymor-
phism, where more than one function carrying same name behave differently with
different set of parameters passed to them.
void Display()
{
cout<<"Hello!"<<endl;
}
void Display(int N)
{
cout<<2*N+5<<endl;
}
(1 Mark each for appropriate definition)
(1 Mark for appropriate example)
(b) i) Copy constructor, It will help to copy the data from one object to another. 2
( ½ Mark for mentioning copy constructor)
( ½ Mark for remaining answer)
ii) Match M; //Function 1
Match N(10); //Function 3
( ½ Mark for each statement)
(c) class FLIGHT 4
{
int Fno;
char Destination[20];
float Distance, Fuel;
void CALFUEL();
public:
45
No. Answers Marks
void FEEDINFO();
void SHOWINFO();
};
void FLIGHT::CALFUEL()
{
if (Distance<=1000)
Fuel=500;
else
if (Distance<=2000)
Fuel=1100;
else
Fuel=2200;
}
void FLIGHT::FEEDINFO()
{
cout<<"Flight No :";cin>>Fno;
cout<<"Destination :";gets(Destination);
cout<<"Distance :";cin>>Distance;
CALFUEL();
}
void FLIGHT::SHOWINFO()
{
cout<<"Flight No :"<<Fno<<endl;
cout<<"Destination :"<<Destination<<endl;
cout<<"Distance :"<<Distance<<endl;;
cout<<"Fuel :"<<Fuel<<endl;;
}
(½ Mark for correct syntax for class header)
(½ Mark for correct declarations of data members)
46
No. Answers Marks
(1 Mark for appropriate definition of function CALFUEL())
(1 Mark for appropriate definition of FEEDINFO() with a call for CALFUEL())
(1 Mark for appropriate definition of SHOWINFO())
(d) 4
(i) None of data members are accessible from objects belonging to class
AUTHOR.
(1 Mark for correct answer)
(ii) Enter(), Show()
(1 Mark for correct answer)
(iii) Data members: Voucher_No, Sales_Date, Salary
Member function:Sales_Entry(),Sales_Detail(),Enter(),Show(),Register(),
Status()
(1 Mark for correct answer)
(iv) 66
(1 Mark for correct answer)
3. (a) voidAddNSave(intA[ ],int B[ ],int C[ ],int N) 3
{
for (int i=0;i<N;i++)
C[i]=A[i]+B[i];
}
(1 Mark for correct Function Header with appropriate parameters)
(1 Mark for appropriate loop)
(1 Mark for correct expression for addition of corresponding elements)
(b) Given, 3
W=4
N=20
M=30
Loc(P[2][20])=5000
47
No. Answers Marks
Column Major Formula:
Loc(P[I][J]) =Base(P)+W*(N*J+I)
Loc(P[2][20]) =Base(P)+4*(20*20+2)
Base(P) =5000 -4*(400+2)
=5000-1608
=3392
(1 Mark for writing correct formula (for column major) OR substituting formula with
correct values)
(1 Mark for writing calculation step - at least one step)
(1 Mark for correct address)
(c) struct NODE 3
{
float Data; NODE *Link;
};
class STACK
{
NODE *Top;
public:
STACK();
void Push();
void Pop();
void Display();
~STACK();
};
void STACK::Push()
{
NODE *Temp;
Temp=new NODE;
48
No. Answers Marks
cin>>Temp->Data;
Temp->Link=Top;
Top=Temp;
}
(1 Mark for declaring Temp pointer)
(1 Mark for creating a new node and assigning/entering appropriate values in it)
(1 Mark for connecting link part of new node to top)
(1 Mark for assigning Top as the new node i.e. Temp)
(d) void MatAdd(int M[][4],int N,int M) 2
{
for (int R=0;R<N;R++)
{
int SumR=0;
for (int C=0;C<M;C++)
SumR+=M[C][R];
cout<<SumR<<endl;
}
}
( ½ Mark for correct function header)
( ½ Mark for appropriate outer loop)
( ½ Mark for appropriate inner loop)
( ½ Mark for correctly initializing SumR and calculatin the sum)
(e) 2
(½ Mark for correctly evaluating each operator)
OR
49
No. Answers Marks
(1 Mark for correct answer)
50
No. Answers Marks
4. (a) File.seekg(0,ios::end); //Statement 1 1
File.tellg(); //Statement 2
(½ Mark for each correct Statement)
(b) void CountAlphabet() 2
{
ifstream FIL("NOTES.TXT");
int CALPHA=0;
char CH=FIL.get();
while (!FIL.eof())
{
if (isalpha(CH))
CALPHA++;
CH=FIL.get();
}
cout<<"No. ofAlphabets:"<<CALPHA<<endl;
}
(½ Mark for opening NOTES.TXT correctly)
(½ Mark for initializing a counter variable as 0)
(½ Mark for correctly reading a character from the file)
(½ Mark for correctly incrementing the counter)
(c) voidAddnew() 3
{
fstream FIL;
FIL.open("STUDENT.DAT",ios::binary|ios::app);
STUD S;
char CH;
do
{
51
No. Answers Marks
S.Enter();
FIL.write((char*)&S,sizeof(S));
cout<<"More(Y/N)?";cin>>CH;
}
while(CH!='Y');
FIL.close();
}
( ½ Mark for opening STUDENT.DAT correctly)
( ½ Mark for user input for the new object)
(1 Mark for appropriate loop)
( 1 Mark for writing the record on to the binary file)
5.
(a) An attribute or set attributes which are used to identify a tuple uniquely is known as 2
Primary Key. If a table has more than one such attributes which identify a tuple uniquely
than all such attributes are known as Candidate Keys.
(1 Mark for each definition)
(b) Write SQL commands for the flowing statements: 4
(i) SELECT GameName,Gcode FROM GAMES;
(1 Mark for correct query)
OR
(½ Mark for partially correct answer)
(ii) SELECT * FROM Games WHERE Prizemoney>7000;
(1 Mark for correct query)
OR
(½ Mark for partially correct answer)
(iii) SELECT * FROM Games ORDER BY ScheduleDate;
(1 Mark for correct query)
52
No. Answers Marks
OR
(½ Mark for partially correct answer)
(iv) SELECT SUM(Prizemoney),Type FROM Games GROUP BY Type;
(1 Mark for correct query)
OR
(½ Mark for partially correct answer)
(c) (i) 2 2
(½ Mark for correct output)
(ii) 19-Mar-2004 12-Dec-2003
(½ Mark for correct output)
(iii) Ravi Sahai Lawn Tennis
(½ Mark for correct output)
(iv) 3
(½ Mark for correct output)
6.
(a) X+X.Y = X 2
L.H.S = X+X.Y
= X.1+X.Y
= X.(1+Y)
= X.1
= X
= R.H.S
X+X'.Y = X+Y
L.H.S. = X+X'.Y
53
No. Answers Marks
= (X+X').(X+Y)
= 1.(X+Y)
= X+Y
= R.H.S
(1 Mark for stating any one of the Absorption Law)
(1 Mark for verifying the law)
(b) F(U,V)=U'.V+U.V' 2
(2 Marks for the final expression )
OR
(1 Mark for any one of the correct terms out of U'.V or U.V')
(c) F(P,Q,R) = P'.Q'R'+P'.Q'R+P'.Q.R+P.Q'.R 1
(1 Mark for the correct expression )
(d)
F(U,V,W,Z)=UV+WZ+UZ 3
( ½ Mark for placing all 1s at correct positions in K-Map)
( ½ Mark for each grouping)
(1 Mark for writing final expression in reduced/minimal form)
Note: Deduct ½ mark if wrong variable names are used
U’V’ U’V UV UV’
W’Z’ 0 4 8
W’Z 1 8 9
WZ 11
WZ’ 2 6 10
1
12
1
3
1
5
1
14
1
7
1
3
54
No. Answers Marks
7.
a) Bandwidth is referred to the volume of information per unit of time that a transmission 1
medium (like an Internet connection) can handle.
OR
The amount of data that can be transmitted in a fixed amount of time is known as
bandwidth.
For digital devices, the bandwidth is usually expressed in bits per second(bps) or
bytes per second. For analog devices, the bandwidth is expressed in cycles per
second, or Hertz (Hz).
( ½ Mark for writing appropriate definition)
( ½ Mark for giving the unit of bandwidth)
b) The first benefit of XML is that because you are writing your own markup language, 1
you are not restricted to a limited set of tags defined by proprietary vendors.
Rather than waiting for standards bodies to adopt tag set enhancements (a process
which can take quite some time), or for browser companies to adopt each other's
standards (yeah right!), with XML, you can create your own set of tags at your own
pace.
(1 Mark for writing appropriate explanation)
c) A firewall is a part of a computer system or network that is designed to block unautho 1
-rized access while permitting authorized communications. It is 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 for writing appropriate explanation)
d) AUniform Resource Locator (URL) is used to specify, where an identified resource 1
is available in the network and the mechanism for retrieving it.AURL is also referred
to as a Web address.
( 1 Mark for writing appropriate explanation)
55
No. Answers Marks
e) Suggest a cable layout of connections between the buildings. 4
Layout 1:
Layout 2: Since the distance between Fazz Building and Jazz Building is quite short
(1 Mark for any one of the two suggested layouts)
e2) The most suitable place / block to house the server of this organisation would be Raj
Building, as this block contains the maximum number of computers, thus decreasing
the cabling cost for most of the computers as well as increasing the efficiency of the
maximum computers in the network.
( 1 Mark for correct answer with suitable reason)
e3) (i) Raj Building
(ii) In both the layouts, a hub/switch each would be needed in all the buildings, to
interconnect the group of cables from the different computers in each block
( ½ Mark for each correct answer)
e4) The type of network that shall be formed to link the sale counters situated in various
parts of the same city would be a MAN, because MAN (MetropolitanArea Networks)
are the networks that link computer facilities within a city.
(1 Mark for correct answer with suitable justification)
56
No. Answers Marks
f) Freeware, the name derived from words "free" and"software". It is a computer soft 1
ware that is available for use at no cost or for an optional fee. Freeware is generally
proprietary software available at zero price, and is not free software. The author usu-
ally restricts one or more rights to copy, distribute, and make derivative works of the
software.
Shareware is usually offered as a trial version with certain features only available after
the license is purchased, or as a full version, but for a trial period. Once the trial period
has passed the program may stop running until a license is purchased. Shareware is
often offered without support, updates, or help menus, which only become available
with the purchase of a license. The words "free trial" or "trial version" are indicative of
shareware.
(1 Mark for appropriate difference)
g) ATrojan horse is a term used to describe malware that appears, to the user, to per 1
form a desirable function but, in fact, facilitates unauthorized access to the user's
computer system
A computer worm is a self-replicating computer program. It uses a network to send
copies of itself to other nodes (computers on the network) and it may do so without any
user intervention.
(1 Mark for appropriate difference)

Cbse marking scheme 2006 2011

  • 1.
    264 COMPUTER SCIENCE Time allowed: 3 hours Maximum Marks : 70 Instructions : (i) All questions are compulsory. (ii) Programming Language : C++ QUESTION PAPER CODE 91/1 1. (a) Nametheheaderfiletowhichthefollowingbelong 1 (i) abs( ) (ii) isupper( ) (b) Illustrate the use of #define in C++ to define a macro. 2 (c) Rewritethefollowingprogramafterremovingthesyntacticalerror(s),if any.Underlineeachcorrection. 2 #include<iostream.h> voidmain() { struct STUDENT { charstu_name[20]; charstu_sex; intstu_age=17; } student; gets(stu_name); gets(stu_sex); } (d) Findtheoutputofthefollowingprogram: 3 #include<iostream.h> #include<string.h> class state { char*state_name; intsize; public: state( ); { size=0; state_name=new char[size+1]; } state(char *s)
  • 2.
    265 { size =strlen(s) ; state_name = new char[size+1]; strcpy(state_name,s); } voiddisplay(){cout<<state_name<<endl;} void Replace (state & a, state & b) { size = a.size + b.size; deletestate_name; state_name=newchar[size+l]; strcpy(state_name,a.state_name); strcat(state_name,b.state_name); } }; voidmain() { char*temp=“Delhi”; state state1 (temp), state2(“Mumbai”), state3(“Nagpur”), S1, S2; S1.Replace(state1, state2); S2. Replace(S1, state3); S1.display(); S2.display(); } (e) Findtheoutputofthefollowingprogram: 2 #include<iostream.h> voidmain() { long NUM= 1234543; int F=0, S=0; do { int Rem = NUM% 10 ; if (Rem % 2 !=0) F+=R; else S+=R; NUM /=10; }while(NUM>0); cout<<F-S; } (f) What are Nested Structures ? Give an example. 2
  • 3.
    266 2. (a) DefineMultilevelandMultipleinheritanceincontextofObjectOrientedProgramming. Givesuitableexampletoillustratethesame.2 (b) Answerthequestions(i)and(ii)aftergoingthroughthefollowingclass: classInterview { intmonth; public: Interview(inty) {month=y;} //Constructor 1 Interview(Interview&t); //Constructor 2 }; (i) Create an object, such that it invokes Constructor 1 1 (ii) WritecompletedefinitionforConstructor2 1 (c) DefineaclassnamedADMISSIONinC++withthefollowingdescriptions: 4 Privatemembers: AD_NO integer (Ranges 10 - 2000) NAME Arrayofcharacters(String) CLASS Character FEES Float PublicMembers: • Function Read_Data( ) to read an object ofADMISSION type • Function Display( ) to display the details of an object • Function Draw-Nos( ) to choose 2 students randomly. Anddisplaythedetails.Userandomfunctiontogenerateadmission nos. to match withAD_NO. (d) Answer the questions (i) to (iii) based on the following code : classstationary { charType; charManufacturer[10]; public: stationary(); void Read_sta_details( ); voidDisp_sta_details(); }; classoffice:publicstationary {
  • 4.
    267 intno_of_types; floatcost_of_sta; public: voidRead_off_details(); voidDisp_off_details(); }; classprinter:privateoffice { intno_of_users; char delivery _date[10]; public: voidRead_pri_details(); voidDisp_pri_details(); }; voidmain() { printer MyPrinter; } (i) Mention the member names which are accessible by MyPrinter declared in main()function 1 (ii) What is the size of MyPrinter in bytes ? 1 (iii) Mention the names of functions accessible from the member function Read_pri_details( ) of class printer. 2 3. (a) Write a function in C++ which accepts an integer array and its size as arguments/parameters and assign the elements into a two dimensional array of integersinthefollowingformat If the array is 1, 2, 3, 4, 5, 6 If the array is 1, 2, 3 3 Theresultant2Darrayisgiven The resultant2Darrayisgiven below below 1 2 3 4 5 6 1 2 3 1 2 3 4 5 0 1 2 0 1 2 3 4 0 0 1 0 0 1 2 3 0 0 0 1 2 0 0 0 0 1 0 0 0 0 0
  • 5.
    268 (b) An arrayMAT[30][10] is stored in the memory column wise with each element occupying 8 bytes of memory. Find out the base address and the address of element MAT[20][5], if the location of MAT[5][7] is stored at the address 1000. 4 (c) classqueue 4 { intdata[10]; intfront,rear; public: queue( ) {front = -1; rear=-1;} voidadd(); // to add an element into the queue voidremove(); // to remove an element from the queue voidDelete(intITEM); //To deleteallelementswhichareequal // to ITEM }; CompletetheclasswithallfunctiondefinitionsforacirculararrayQueue.Use another queue to transfer data temporarily (d) WriteafunctioninC++toperformPushoperationonadynamicallyallocated stackcontainingrealnumber. 3 (e) Writetheequivalentinfixexpressionfor a, b, AND, a, c, AND, OR 2 4. (a) voidmain() { char ch='A'; fstreamfileout(“data.dat”,ios::out); fileout<<ch; intp=fileout.tellg(); cout<<p; Whatistheoutputifthefilecontentbeforetheexecutionoftheprogramisthe string “ABC” (Note that “ ” are not part of the file) (b) Write a function to count the number of words present in a text file named “PARA.TXT”. Assume that each word is separated by a single blank/space character and no blanks/spaces in the beginning and end of thefile. 2
  • 6.
    269 (c) Following isthe structure of each record in a data file named “COLONY.DAT”. 3 struct COLONY { char Colony_Code[10]; charColony_Name[10]; intNo_of_People; }; WriteafunctioninC++toupdatethefilewithanewvalueofNo_of_People.Thevalue of Colony_Code and No_of_People are read during the execution of the program. 5. (a) What is anAlternate Key ? 2 (b) Study the following tables DOCTOR and SALARY and write SQL commands for the questions (i) to (iv) and give outputs for SQL queries (v) to (vi): 6 TABLE : DOCTOR ID NAME DEPT SEX EXPERIENCE 101 John ENT M 12 104 Smith ORTHOPEDIC M 5 107 George CARDIOLOGY M 10 114 Lara SKIN F 3 109 K George MEDICINE F 9 105 Johnson ORTHOPEDIC M 10 117 Lucy ENT F 3 111 Bill MEDICINE F 12 130 Morphy ORTHOPEDIC M 15 TABLE : SALARY ID BASIC ALLOWANCE CONSULTATION 101 12000 1000 300 104 23000 2300 500 107 32000 4000 500 114 12000 5200 100 109 42000 1700 200 105 18900 1690 300 130 21700 2600 300
  • 7.
    270 (i) Display NAMEof all doctors who are in “MEDICINE” having more than 10 years experience from the table DOCTOR. (ii) Displaytheaveragesalaryofalldoctorsworkingin“ENT”departmentusing the tables DOCTOR and SALARY. Salary = BASIC +ALLOWANCE (iii) DisplaytheminimumALLOWANCEoffemaledoctors, (iv) Displaythehighestconsultationfeeamongallmaledoctors, (v) SELECT count(*) from DOCTOR where SEX = “F” (vi) SELECT NAME, DEPT, BASIC from DOCTOR, SALARY where DEPT= “ENT” and DOCTOR.ID = SALARY.ID 6. (a) StateandverifyDistributiveLaw. 2 (b) WritetheequivalentexpressionforthefollowingLogicalCircuit: 2 (c) Express P + Q’R in canonical SOP form. 1 (d) ReducethefollowingBooleanexpressionusingK-Map. F(P, Q, R, S) = ÿ (0, 3, 5, 6, 7, 11, 12, 15) 3 7. (a) DifferentiatebetweenInternetandIntranet. 1 (b) Expandthefollowingterms (i) CDMA (ii) URL (iii) HTTP (iv) WAN 2 (c) Write one advantage of STAR topology as compared toTBUS topology. 1 (d) UNIVERSITY OF CORRESPONDENCE in Allahabad is setting up the network between its different wings. There.are 4 wings named as Science (S), Journalism (J),ARTS (A) and Home Science(H).
  • 8.
    271 Distancebetweenvariouswingsaregivenbelow Wing A toWing S 100 m Wing A to Wing J 200 m Wing A to Wing H 400 m Wing S to Wing J 300 m Wing S to Wing H 100 m Wing J to Wing H 450 m Number of Computers Wing A 150 Wirig S 10 Wing J 5 Wing H 50 (i) SuggestasuitableTopologyfornetworkingthecomputerofallwings 1 (ii) Name the wing where the Server to be installed. Justify your answer, 1 (iii) SuggesttheplacementofHub/Switchinthenetwork. 1 (iv) Mention an economic technology to provide internet accessibility to all wings. 1 QUESTION PAPER CODE 91 1. (a) Nametheheaderfiletowhichthefollowingbelong: 1 (i) pow() (ii) random() (b) IllustratetheuseofinlinefunctioninC++withthehelpofanexample. 2 (c) Rewrite the followingprogram afterremovingthe syntactical error(s), ifany. Underlineeachcorrection. 2 #include<idstream.h> voidmain() { structmovie { charmovie_name[20]; charmovie_type; int ticket_cost = 100;
  • 9.
    272 }MOVIE; gets(movie_name); gets(movie_type); } (d) Findtheoutputofthefollowingprogram: 3 #include<iostream.h> #include<string.h> classstudent {char*name; intl; public: student() { 1=0; name=new char[1+1]; } student(char*s) { 1=strlen(s);name=newchar[1+1]; strcpy(name,s); } voiddisplay(){cout<<name<<endl;} void manipulate(student & a, student & b) { 1=a.1 + b.1; deletename; name=newchar[l+l]; strcpy(name,a.name); strcat(name,b.name); } }; voidmain() { char * temp =''Jack''; student name1(temp), name2('' Jill''), name3('' John'' ),S1,S2; S1.manipulate(name1,name2); S2.manipulate(S1,name3); S1.display(); S2.display(); }
  • 10.
    273 (e) Findtheoutputofthefollowingprogram: 2 #include<iostream.h> voidmain() {long Number = 7583241; int First=0, Second=0; do { int R = Number%10; if(R%2==0) First+=R; else Second+=R; Number /=10; }while(Number>0); cout<<First-Second; } (f) What is a default constructor ? How does it differ from destructor ? 2 2. (a) What is “this” pointer ? Give an example to illustrate the use of it in C++. 2 (b) Answerthequestions(i)and(ii)aftergoingthroughthefollowingclass: classExam { intyear; public: Exam(inty) {year=y;} //Constructor1 Exam(Exam&t); //Constructor 2 }; (i) Create an object, such that it invokes Constructor 1. 1 (ii) WritecompletedefinitionforConstructor2. 1 (c) DefineaclassnamedHOUSINGinC++withthefollowingdescriptions: 4 Privatemembers REG_NO integer(Ranges 10 - 1000) NAME Arrayofcharacters(String) TYPE Character COST Float
  • 11.
    274 PublicMembers • Function Read_Data()to read an object of HOUSING type • FunctionDisplay()todisplaythedetailsofanobject • Function Draw_Nos()to choose and display the details of 2 houses selected randomly from an array of 10 objects of type HOUSING. Use randomfunctiontogeneratetheregistrationnos.tomatchwithREG_NO fromthearray. (d) Answer the questions (i) to (iii) based on the following code : classfurniture { charType; char Model[10]; public: furniture(); voidRead_fur_details(); voidDisp_fur_details(); }; classsofa:publicfurniture { intno_of_seats; floatcost_of_sofa; public: voidRead_sofa_details(); voidDisp_sofa_details(); }; classoffice:privatesofa { intno_of_pieces; chardelivery_date[10]; public: voidRead_office_details(); voidDisp_office_details(); }; voidmain() { officeMyFumiture; }
  • 12.
    275 (i) MentionthemembernameswhichareaccessiblebyMyFumituredeclaredin main()function. 1 (ii)WhatisthesizeofMyFumiture inbytes? 1 (iii) Mention the names of functions accessible from the member function Read_office_details()ofclassoffice. 2 3. (a) Write a function in C++ which accepts an integer array and its size as arguments/ parameters and assign the elements into a two dimensional array of integers in the followingformat: 3 If the array is 1, 2, 3, 4, 5, 6 If the array is 1, 2, 3 The resultant 2 D array is given below The resultant 2 D array is given below 1 0 0 0 0 0 1 0 0 1 2 0 0 0 0 1 2 0 1 2 3 0 0 0 1 2 3 1 2 3 4 0 0 1 2 3 4 5 0 1 2 3 4 5 6 (b) An array MAT[20][10] is stored in the memory along the row with each element occupying 4 bytes of memory. Find out the base address and the address of element MAT[10][5], if the location of MAT[3][7] is stored at the address 1000. 4 (c) Introduction class stack { int data[10]; int top; public: stack() {top=-l) void push(); // to push an element into the stack void pop(); // to pop an element from the stack void Delete(int ITEM); // To delete all elements which are equal to ITEM }; Complete the class with all function definitions. Use another stack to transfer data temporarily. 4 (d) WriteafunctioninC++toperformInsertoperationindynamicallyallocatedQueue containingnamesofstudents. 3 (e) Writetheequivalentinfixexpressionfor 2 10, 3, *, 7, 1, -, *, 23, +
  • 13.
    276 4. (a) voidmain() {char ch='A'; fstreamfileout(“data.dat”,ios::app); fileout<<ch; intp=fileout.tellg(); cout<<p; } Whatistheoutputifthefilecontentbeforetheexecutionoftheprogramisthestring? “ABC” (Note that “”are not part of the file) 1 (b) Write a function to count the number of blanks present in a text file named “PARA.TXT. 2 (c) Following is the structure of each record in a data file named PRODUCT.DAT”. struct PRODUCT { char Product_Code[10]; charProduct_Description[10]; intStock; }; Write a function in C++ to update the file with a new value of Stock. The Stock and the Product_Code, whose Stock to be updated, are read during the execution of the program. 3 5. (a) What are DDL and DML ? 2 (b) Study the following tables FLIGHTS and FARES and write SQLcommands for the questions (i) to (iv) and give outputs for SQL queries (v) to (vi). TABLE : FLIGHTS FL_NO STARTING ENDING NO_FLIGHTS NO_STOPS IC301 MUMBAI DELHI 8 0 IC799 BANGALORE DELHI 2 1 MC101 INDORE MUMBAI 3 0 IC302 DELHI MUMBAI 8 0 AM812 KANPUR BANGALORE 3 1 IC899 MUMBAI KOCHI 1 4 AM501 DELHI TRIVANDRUM 1 5 MU499 MUMBAI MADRAS 3 3 IC701 DELHI AHMEDABAD 4 0
  • 14.
    277 TABLE : FARES FL_NOAIRLINES FARE TAX% IC701 IndianAirlines 6500 10 MU499 Sahara 9400 5 AM501 JetAirways 13450 8 IC899 IndianAirlines 8300 4 IC302 IndianAirlines 4300 10 IC799 IndianAirlines 10500 10 MC101 DeccanAirlines 3500 4 (i) Display FL_NO and NO_FLIGHTS from “KANPUR” to “BANGALORE”fromthetableFLIGHTS. (ii) Arrange the contents of the table FLIGHTS in the ascending order of FL_NO. (iii) Display the FL_NO and fare to be paid for the flights from DELHI to MUMBAI using the tables FLIGHTS and FARES, where the fare to be paid=FARE+FARE*TAX%/100. (iv) Display the minimum fare “IndianAirlines” is offering from the table FARES. (v) SELECTFL_NO,NO_FLIGHTS,AIRLINESfromFLIGHTS,FARES whereSTARTING=“DELHI”andFLIGHTS.FL_NO=FARES.FL_NO. (vi) SELECTcount(distinctENDING)fromFLIGHTS. 6. (a) StateandverifyAssociativeLaw. 2 (b) Writetheequivalentexpressionforthefollowinglogicalcircuit: 2
  • 15.
    278 (c) Express P+ Q'R in POS form. 1 (d) ReducethefollowingBooleanexpressionusingK-Map: 3 F(P, Q, R, S) = π (0, 3, 5, 6, 7, 11, 12, 15) 7. (a) Nametwotransmissionmediafornetworking. 1 (b) Expandthefollowingterms: 1 (i) XML (ii) GSM (iii) SMS (iv) MAN (c) Differentiate between Hackers and Crackers. (d) INDIANPUBLICSCHOOLinDarjeelingissettingupthenetworkbetweenits differentwings.Thereare4wingsnamedasSENIOR(S),JUNIOR(J),ADMIN(A) and HOSTELCH). Distancebetweenvariouswingsaregivenbelow: WingAtoWingS 100 m WingAtoWingJ 200 m WingAtoWingH 400 m Wing S toWing J 300 m WingStoWingH 100 m WingJtoWingH 450 m Number of Computers WingA 10 WingS 200 WingJ 100 WingH 50 (i) SuggestasuitableTopologyfornetworkingthecomputerofallwings. 1 (ii) Name the wing where the Server is to be installed. Justify your answer. 1 (iii) SuggesttheplacementofHub/Switchinthenetwork. 1 (iv) Mentionaneconomictechnologytoprovideinternetaccessibilitytoallwings. 1
  • 16.
    279 Marking Scheme ---Computer Science General Instruction : 1. Theanswersgiveninthemarkingschemearemerelysuggestive; Examiners are requested to consider all alternative correct answers conveying the similarmeaning. 2. Allprogrammingquestions-havetobeansweredwithrespecttoC++languageonly. 3. In SQL related questions - both ways text i.e. character entries should be acceptable. (Forexample:‘Amar’or“Amar”) 4. InSQLrelatedquestions-ignoresemicolon / terminationforqueries. 5. In SQLrelated questions - ignore case sensitivity. 6. InC++questions—Ignorecasesensitivityforfunctionnamesandvariablenames. QUESTION PAPER CODE 91/1 EXPECTEDANSWERS/VALUEPOINTS 1. (a) (i) math.h (ii) ctype.h ( ½ Marks for each correct Header File) (b) #defineisapreprocessordirectivethatisusedtodefineasymbolicconstant. The symbolic constant defined, replaces the word / statement wherever it appears in the program as a macro substitution. Syntax: #definesymbolic_namevalue Example: #define Pi 3.14 #defineWELCOME cout<<”HelloWorld !n”; (Full 2 marks for illustrating the concept of #define using example) OR (1 mark if only definition is written) (c) Corrected Program: #include<iostream.h> #include<stdio.h> // Error 1 void main() { struct STUDENT { char stu_name[20]; char stu_sex; int stu_age; //Error 2
  • 17.
    280 } student; gets(student.stu_name); //Error3 cin>>student.stu_sex; //Error 4 student.stu_age = 17; //Ignored } ( ½ mark each for removing four errors) OR (1 Mark to be given for only identification of all the errors without rectification) Note: If student replaces gets by cin>> or cin.getline( )and does not mention <stdio.h> then full marks to be given if other errors are corrected. (d) DelhiMumbai DelhiMumbaiNagpur (3 full marks for identifying error in definition of the constructor state() in Line 7) OR (3 marks for the correct lines of output) OR (2 marks for any one correct line of output) OR (1 Mark for showing the output starting with Delhi) (e) 2 (assumingRasRem) (2 marks for correct output as 2) OR (2 marks for identifying error as R is not declared) OR (Full 2 marks to be awarded to the students who have scored at least 1 mark in the entire Q. No. 1 i.e. from 1(a) to 1(f)) (f) — Note: Students are exposed to the concept of “Structures” and “Nested Loops”,butnotexposedspecificallytotheconceptof “Nestedstructures”. So benefit of doubt should be given to the students. (2 marks for correct definition or example) OR (Full 2 marks to be awarded to the students who have scored at least 1 mark in the entire Q. No. 1 i.e. from 1(a) to 1(f))
  • 18.
    281 2. (a) InMultilevelinheritance,aclassinheritsit’spropertiesfromanotherderived classtransitively. InMultipleinheritance,aderivedclassinheritsfrommultiplebaseclasses. (1/2mark each for any correct definition) (1/2 mark each for any correct example – diagrammatic/C++ representation) OR (Full 2 marks for explaining the 2 types of inheritance with the help of suitable examples or diagram) (b) Interview Ob1(5); OR int N=5; Interview Ob1(N); (1 mark for proper declaration of Object) Interview(Interview &t) { month = t.month; } (1 mark for writing proper statements inside definition of Constructor 2) OR (1 mark for writing the conceptual definition of the copy constructor) OR (Only ½ mark for mentioning the term: copy constructor) Note: Any valid statement in C++ working with t as an object of Interview must be accepted while defining the constructor. BA A B C C
  • 19.
    282 (c) class ADMISSION { intAD_NO; char NAME[20]; //or any constant size char CLASS; float FEES; public: void Read_Data() { do { cin>>AD_NO; }while (AD_NO<10 || AD_NO>2000); gets(NAME); cin>>CLASS; cin>>FEES; } void Display() { cout<<AD_NO; cout<<NAME; cout<<CLASS; cout<<FEES; } void Draw_Nos(); }; (1 mark for proper syntax of class definition with correct class name and a semicolon to end the class definition) (1 mark for proper declaration of private members) (1 mark for proper definition of Read_Data()) (1 mark for proper definition of Display()) Note: No marks should be deducted for Not checking the range for AD_NO Not declaring or defining Draw_Nos(). (Mentioned as Draw- Nos() in the question paper)
  • 20.
    283 (d) (i) Read_pri_details(),Disp_pri_details() (1mark for correct function names) (ii) 29 bytes OR 33 bytes (1 mark for correct answer) (iii) Disp_pri_details(),Read_off_details(),Disp_off_details(), Read_sta_details(),Disp_sta_details() (2 marks for all correct member functions) Note: No partial marks to be given for any of the parts. Ignore the constructor and function itself 3. (a) const int R = 100, C = 100; void Arrayconvert(int A1D[], int N) { int A2D[R][C]={0}; for(int I = 0; I<N; I++) for (int J = 0; J <N-I; J++) A2D[I][J] = A1D[J]; } OR const int R = 100, C = 100; void Arrayconvert(int A1D[], int N) { int A2D[R][C]; for(int I = 0; I<N; I++) for (int J = 0; J <N; J++) if (J<N-I) A2D[I][J] = A1D[J]; else A2D[I][J] = 0; }
  • 21.
    284 OR const int R= 100, C = 100; void Arrayconvert(int A1D[], int N) { int A2D[R][C], I, J; for(I = 0; I<N; I++) for (J = 0; J <N; J++) A2D[I][J] = 0; for(I = 0; I<N; I++) for (J = 0; J <N-I; J++) A2D[I][J] = A1D[J]; } OR Any other equivalent code (1 mark for function header) (1 mark for correct use of nested loops) ( ½ mark for correctly assigning the values from 1D array to 2D array) ( ½ mark for assigning 0 to the rest of the elements) Note: Ignore declaration of the 2D array. (b) ForColumnwiseallocation Address ofA[I][J] = BA+ W[ (J –LBC) x M + (I - LBR)] Where BA= BaseAddress W = Size of each element in bytes = 8 bytes (given) M = No. of rows in the 2DArray = 30 (given) Address of MAT[5][7] given is 1000. Assumption 1 : LBR=LBC=0 Therefore 1000 = BA + 8 (7 × 30 + 5) = BA + 8 × 215 = BA + 1720 BA = 1000 – 1720 = -720 Therefore, Base Address = - 720 Thus,Address of MAT[20][5] = -720 + 8 ( 5 × 30 + 20) = -720 + 8 × 170 = -720 + 1360 = 640
  • 22.
    285 Assumption 2 :LBR=LBC=1 Therefore 1000 = BA + 8 [(7-1) × 30 +(5-1)] = BA + 8[6 × 30 + 4] = BA + 8 ×184 = BA + 1472 BA = 1000 – 1472 = -472 Therefore, Base Address = - 472 Thus,Address of MAT[20][5] = -472 + 8 ( 4 × 30 + 19) = -472 + 8 × 139 = -472 + 1112 = 640 (2 marks for writing the correct column major formula or sustitution of values in the correct formula) (1 mark for calculating Base Address) (1 mark for calculating final address of MAT[20][5]) (c) void queue::add( ) { if ( (rear + 1) % 10 != front ) { if (rear == -1 ) front = rear = 0 ; else rear = (rear + 1) %10; cin>>data[rear]; } else cout<<”Queue full !! Overflow Error !!n”; } void queue::remove() { if (front != -1) { cout<< data[front]<<” deleted ”; if(front==rear) front=rear=-1; else front = (front+1)%10; } else cout<<”Queue empty ! Underflow Error!!n”; }
  • 23.
    286 OR void queue::add( ) { if( (rear + 1) % 10 != front )//Ignoring –1 initial values { rear = (rear + 1) %10; cin>>data[rear]; } else cout<<”Queue full !! Overflow Error !!n”; } void queue::remove() { if (front != rear) //Ignoring –1 initial values { front = (front+1)%10; cout<< data[front]<<” deleted…”; } else cout<<”Queue empty ! Underflow Error!!n”; } OR void queue::add() { int item; if((front==0 && rear==9) || front==rear+1) cout<<”nQueue overflow error”; else { cout<<”nEnter an item to add : “; cin>>item; if(front= =-1) { front=0;rear=0; } else rear=rear+1; if(rear==10) rear=0; data[rear]=item; } }
  • 24.
    287 void queue::remove() { if((front==-1) cout<<”nQueue Underflow Error”; else { int item=data[front]; if(front==rear) front=rear=-1; elseif(front==9) front=0; else front=front+1; cout<<”nDeleteditemis:“<<item; } } OR Anyotherequivalentcode (2 marks for any correct add( )function code) ( ½ mark for checking Overflow condition) (1 mark for changing the values of rear counter ) ( ½ mark for assigning the new value at the correct position) (2 marks for any correct remove( )function code) (1 mark for checking Underflow condition) (1 mark for changing the values of front counter) Note: There is a conceptual contradiction for the function void Delete(int ITEM) , thus the benefit of doubt is given to the student and therefore the definition of the function is to be ignored . (d) struct Node { float Data;Node *Link; }; class Stack { Node *Top; public: Stack() { Top = NULL ; } void Push( );void Pop ( );void Display ( ); };
  • 25.
    288 void Stack::Push() { Node *Temp= new Node; cin>>Temp->Data; Temp->Link = Top; Top = Temp; } OR Any other code demonstrating proper Push( ) for a dynamic stack. ( ½ mark for creating new node dynamically) ( ½ mark for assigning a real number to the info part) ( 1 mark for linking new node to the Top of the Stack) ( 1 mark for assigning the new value to the Top) (e) S.No. Element Operation InfixExpression scanned 1 A Push a a 2 B Push b a, b 3 AND Pop, Pop, Push (a AND b) a AND b 4 A Push a a AND b, a 5 C Push c a AND b, a, c 6 AND Pop, Pop, Push(aANDc) a AND b, a AND c 7 OR Pop, Pop, Push (aAND b OR aAND c a AND b OR a AND c Ans: aAND b OR a AND c (2 marks for writing correct expression) OR (2 full marks if any other part of Q3 is correctly attempted as students are familiar with infix to postfix conversion only) 4. (a) 1 (1 mark for correct output) OR (Full 1 mark if error is mentioned due to usage of tellg( ) with out mode as the students generally associate tellg( ) with only ios::in mode) OR (Full 1 mark if student gets at least 1 Mark in any part of question 4)
  • 26.
    289 (b) void countwords() { ifstream fin; fin.open(“Para.txt”); char ch ; int count = 1; while(!fin.eof()) { ch = fin.get(); if (ch == ‘ ’) count ++; } cout<<”nNumber of words = “<<count; // Optional fin.close(); //Optional } OR void countwords( ) { ifstream fin“Para.txt”); char str[30] ; int count = 0; while(fin) { fin>>str; count++; } cout<<”nNumber of words = “<<count; // Optional fin.close(); //Optional } OR void countwords( ) { fstream fin; fin.open(“Para.txt”, ios::in); char ch[80] ; int count = 1; while(fin) {
  • 27.
    290 fin.getline(str,80); for(int i=0;str[i]!=’0’;i++) if (ch== ‘ ’) count++; } cout<<”nNumber of words = “<<count; // Optional fin.close(); //Optional } OR void countwords( ) { fstream fin(“Para.txt”, ios::in); char ch[80] ; int count = 0; while(fin) { fin.getline(str,80, ‘ ’); count++; } cout<<”nNumber of words = “<<count; // Optional fin.close(); //Optional } OR Anyotherequivalentcode (1/2 mark for opening file in correct mode either using ifstream or ios::in) (1/2 mark for correct loop) (1/2 mark for checking for blank space/equivalent code) (1/2 mark for counting number of words) (c) void update() { fstream f; COLONY c; char C_Code[10]; cout<<”nEnter the Colony Code : “; cin>>C_Code; // OR gets(C_Code); f.open(“COLONY.DAT”,ios::binary|ios::in|ios::out); while(f.read((char*)&c,sizeof(COLONY))) { if(strcmp(c.Colony_Code, C_Code)==0)
  • 28.
    291 { cout<<”nEnter the newNumber of people : “; cin>>c.No_of_People; f.seekp(f.tellg()- sizeof(c)); //OR f.seekp(f.tellg()- sizeof(c), ios::beg); //OR f.seekp(- sizeof(c), ios::curr); f.write((char*)&c, sizeof(COLONY)); } } f.close(); } OR Anyotherequivalentcode ( ½ mark for reading Colony_ Code and No_of_People ) (1 mark for opening the file(s) in correct mode) (½ mark for correct loop) (1 mark for read function) Note: Since search condition is not clearly mentioned in the question, search and updation to be ignored 5. (a) Candidate key(s), which is not selected as Primary Key, is known as Alternatekey(s). (2 marks for any equivalent correct definition) (b) (i) SELECT NAME FROM DOCTOR WHERE DEPT = ‘MEDICINE’ AND EXPERIENCE >10; (½ mark for correct Select statement) (½ mark for correct Where clause) (ii) SELECT AVERAGE(S.BASIC + S.ALLOWANCE) FROM DOCTOR D, SALARY S WHERE D.DEPT = ‘ENT’ AND D.ID = S.ID; OR SELECT AVERAGE(BASIC + ALLOWANCE) FROM DOCTOR, SALARY WHERE DEPT = ‘ENT’ AND DOCTOR.ID = SALARY.ID; (1/2 mark for correct Select statement) (1/2 mark for correct Where clause) OR (1 mark for students who have correctly attempted any two parts of Q5b)
  • 29.
    292 (iii) SELECT MIN(S.ALLOWANCE) FROMDOCTOR D, SALARY S WHERE D.SEX = ‘F’ AND D.ID = S.ID; OR SELECT MIN(ALLOWANCE) FROM DOCTOR, SALARY WHERE SEX = ‘F’ AND DOCTOR.ID = SALARY.ID; (½ mark for correct Select statement) (½ mark for correct Where clause) (iv) SELECT MAX(S.CONSULTATION) FROM DOCTOR D, SALARY S WHERE D.SEX = ‘M’ AND D.ID = S.ID; OR SELECT MAX(CONSULTATION) FROM DOCTOR , SALARY WHERE SEX = ‘M’ AND DOCTOR.ID = SALARY.ID; (1/2 mark for correct Select statement) (1/2 mark for correct Where clause) (v) 4 (1 mark for correct answer) (vi) NAME DEPT BASIC John ENT 12000 (1 mark for correct answer) 6. (a) DistributiveLawsare: (a) A (B + C) = A B + A C (b) A + (B C) = (A + B) (A + C)
  • 30.
    293 Verificationoffirstdistributivelawusingtruthtable: A B CB+C A(B+C) AB AC AB+AC 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 1 0 1 0 0 0 0 0 1 1 1 0 0 0 0 1 0 0 0 0 0 0 0 1 0 1 1 1 0 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 ComparingColumnNumbers5and8,Distributivelawisverified. (1 Mark for writing either of the distributive law) (1 Mark for verification using truth table) (b) (2 Marks for correct expression) OR ( ½ Mark each for (AC)’, (AB)’,( BC)’ and the final expression) (c) (P + Q’R) = P ( Q+Q’)(R+R’) + Q’R(P+P’) = (PQ +PQ’) (R + R’) + PQ’R + P’Q’R = PQR + PQ’R + PQR’ + PQ’R’ + PQ’R + P’Q’R = PQR + PQ’R + PQR’ + PQ’R’ + P’Q’R (1 mark for the canonical expression) AC AB BC AC AB BC AC+AB+BC
  • 31.
    294 (d) P'O' P'OPO PO' R'S' 1 1 R'S 1 RS 1 1 1 1 RS' 1 OR R'S' R'S RS RS' P'O' 1 1 P'O 1 1 1 PO 1 1 PO' 1 F= RS + P’QS + P’QR + P’Q’R’S’ + PQR’S’ (1 Mark for correct placing of 1s) (1 Mark for correct grouping) (1 Mark for final reduced expression) 7. (a) Internet is a network of computer networks which operates world-wide usingacommonsetofcommunicationsprotocols. Intranetisaninter-connectednetworkwithinoneorganizationthatusesWeb technologiesforthesharingofinformationinternally. (Full 1 Mark for correctly defining internet only as Intranet is not directly specified in the syllabus) (b) (i) Code Divison MultipleAccess (ii) UniformResourceLocator(Location)/UniversalResourceLocator(Location) (iii) HypeTextTransfer(Transmission)Protocol (iv) WideArea Network ( ½ mark for each term) (c) Fault detection is easy. Faultisolationiseasy. OR Anyothervalidadvantage. (1 mark for any one correct advantage)
  • 32.
    295 (d) (i) Staror Bus or any other valid topology or diagram. (1 mark for mentioning any of the above topologies) (1 mark for diagrammatic representation of any of the above topologies) (ii) WingA,becausemaximumnumberofcomputersare locatedatWingA. (1 mark for the correct answer) OR ( ½ mark if only Wing A is mentioned without justification) (ii) Hub/Switchinallthewings. OR CorrectdiagramdepictingplacementofHub/Switchinallthewings. (1 mark for correct placement) (iv) Coaxial cable / Modem / LAN / TCP-IP / Dialup/ DSL/ Leased Line ORanyothervalidtechnology(anyone). Note: Optical fiber, Satellite link and Microwave NOT to be considered as valid answers. (1 Mark for any valid technology) QUESTION PAPER CODE 91 EXPECTEDANSWERS/VALUEPOINTS 1. (a) (i) math.h / complex.h (ii) stdlib.h (1/2 Marks for each correct Header File) (b) — Note:Astheterminlinefunctionisnotmentionedinthecurriculum,benefitof doubt should be given to the students. (Full 2 marks to be awarded to the students who have scored at least 1 mark in the entire Q. No. 1 i.e. from 1(a) to 1(f)) (c) #include<iostream.h> #include<stdio.h> // Error 1 - needed for gets() void main() { struct movie { char movie_name[20]; char movie_type; int ticket_cost = 100; //Error 2 - assignment not //possible inside structure definition }MOVIE;
  • 33.
    296 gets(MOVIE.movie_name);//Error 3 -membersmust be //accessed using object cin>>MOVIE.movie_type; //Error 4 -cant use gets for //char variable and member must //be accessed using object. } #include<iostream.h> void main() { struct movie { char movie_name[20]; char movie_type; int ticket_cost = 100; //Error 1 – initialization‘ not //possible inside structure definition }MOVIE; cin.getline(MOVIE.movie_name,20);//Error 2 -members must //be accessed using object cin>>MOVIE.movie_type; //Error 3 -cant use gets for //char variable and member must //be accessed using object. } (1 mark for identifying and correcting any one Error) (1 ½ mark for identifying and correcting any two errors) (2 marks for identifying and correcting more than two errors) OR (1 mark for only identifying all errors) (d) JackJill JackJillJohn (2 marks for any one correct line) (Full 3 marks for both lines correct) (½ mark to be deducted from full 3 marks, if endl is not considered) (e) -2 (Full 2 marks for correct output) OR (Full 2 marks for mentioning values of First as 14 and Second as 16, as representation of minus sign is not very prominent) OR (Full 2 marks for mentioning syntax error with justification as insertion operator << expected in between First and Second)
  • 34.
    297 (f) Aconstructor thataccepts no parameters is called the default constructor. The compiler supplies a default constructor, if a class has no explicit constructor defined. It initializes the data members by a dummy value. It is also used to create objects with default values. Destructorisusedtodestroytheobjectsanddeallocatethememoryresources that have been allocated by a constructor. It has same name as the class preceded by tilde (~). It takes no arguments and no return types can be specified. (1 mark for each correct definition / example of default constructor) (1 mark for any difference / correct definition / correct example for destructor) 2. (a) Studentsareexposedtotheconceptofpointers,butnotexposedspecifically to the concept of “this” pointer. So benefit of doubt should be given to the students. (Full 2 marks to be given to students who have correctly attempted for at least 1 mark in the entire Q. No. 2 (a) to 2 (d)) (b) (i) Exam E(5); (1 mark for proper declaration of Object) (ii) Exam (Exam &t) {year = t.year;} OR Copy constructor: It is an overloaded constructor, in which object of the same class is passed as parameter. (1 mark for writing proper statements inside definition of Constructor 2) OR (1 mark for any valid statement in C++ working with t as an object of Exam) OR (1 mark for writing the definition/explanation of the concept of copy constructor) OR (1/2 mark for mentioning only the term copy constructor)
  • 35.
    298 (c) class HOUSING { intREG_NO; char NAME[20]; char TYPE; float COST; public: void Read_Data(); void Display(); void Draw_Nos(HOUSING S); }; void HOUSING::Read_Data() { cin>>REG_NO; //Validation not required cin>>NAME; //OR gets(NAME); cin>>TYPE; cin>>COST; } void HOUSING::Display() { cout<<REG_NO<<NAME<<TYPE<<COST<<endl; } void HOUSING::Draw_Nos();//Ignore (1/2 mark for proper syntax of class definition with correct class name and a semicolon to end the class definition) (1/2 mark for mentioning the proper visibility modes (private / public)) (1 mark for proper declaration of private data members) (1 mark for proper definition of Read_Data() with user entry for data members OR declaring a local object and entering the values of data members of this object ) (1 mark for proper definition of Display()) Note:As language of Third part of this question has ambiguity, it is required to be ignored. Moreover, if anyone has partially attempted thethirdpart(i.e.,Draw_nosfunction)andnotattempted/notcorrectly attempted Read/Display function, he/she should be given 2 Marks for Third part taking into consideration the marks for this question should not exceed the max. marks allocated (i.e. 4 marks) to this question 2 (c).
  • 36.
    299 (d) (i) Read_office_details Disp_office_details. (1mark for correct names) (ii) 29 bytes OR 33 Bytes (1 mark for correct answer) (iii) Read_fur_details(), Disp_fur_details, Read_sofa_details(), Disp_sofa_details(), Disp_office_details() Read_office_details() (Optional) (2 marks for correct answer) 3. (a) const int R = 100, C = 100; void Arrayconvert(int A1D[ ], int N) { int A2D[R][C]={0}; for(int I = 0; I<N; I++) for (int J = 0; J <=I; J++) A2D[I][J] = A1D[J]; } ( 1 mark for proper function header ) ( 1 mark for proper use of loops) ( 1 mark for proper assignment of values) (b) ForRowwiseallocation Address ofA[I][J] = BA+ W( (I-LBR) x N + (J-LBC)) Where BA= BaseAddress W = Size of each element in bytes = 4 bytes (given) N = No. of columns in the 2DArray = 10 (given) Address of MAT[3][7] given is 1000. Therefore (Assumption 1: LBR = LBC = 0) MAT[3][7]=100 = BA + 4 (10 (3-0) + (7-0)) = BA + 148 BA = 1000 – 148 = 852
  • 37.
    300 Therefore, Base Address =852 Thus,Address of MAT[10][5] = 852 + 4 ( 10 (10-0) + (5-0)) = 852+420 = 1272 OR (Assumption 2: LBR = LBC = 1) MAT[3][7]=1000 = BA + 4 (10 (3-1) + (7-1)) = BA + 104 BA = 1000 – 104 = 896 Therefore, Base Address = 896 Thus,Address of MAT[10][5] = 896 + 4 ( 10 (10-1) + (5-1)) = 896+376 = 1272 (1 mark for writing the correct formula / correct substituted values, for row major properly, for calculating Base Address) (1 mark for calculating correct Base Address) (1 mark for writing the correct formula / correct substituted values, for row major properly, for calculating Address of MAT [10][5] ) (1 mark for calculating correct address of MAT [10][5]) (c) void stack::push() { int n; cout<<”Enter a value”;cin>>n; if (top==10) cout<<”Stack Overflow”; else data[++top]=n; } void stack::pop() { if (top==-1) cout<<”Stack Underflow”; else cout<<data[top--]; } void stack::Delete(int ITEM);//Ignore this part
  • 38.
    301 [PushOperation] (1/2 mark forchecking overflow condition) (1/2 mark for using increment in Top variable) (1 mark for correct assignment of data in stack) [PopOperation] (1/2 mark for checking underflow condition) (1/2 mark for using decrement in Top variable) (1 mark for displaying or returning value of the popped element from the stack) Note:As language of Third part of this question has ambiguity with respect to Stack Operation, it is required to be ignored. Moreover, if anyone has partially attempted the third part (i.e. Delete function) and not attempted/not correctly attempted Push/Pop should be given 2 Marks for Third part taking into consideration the marks for this question should not exceed the max. marks allocated (i.e. 4 marks) to this question 3 (c). (d) struct Student { char Name[20];Student *Link; }; class Queue { Student *FRONT, *REAR; public: Queue() { FRONT = NULL ; REAR = NULL} void Insert( ); }; void Queue::Insert() { Student *Temp = new Student; gets(Temp->Name); Temp->Link = NULL; if(REAR==NULL) { FRONT=Temp; REAR = Temp; } else { REAR->Link = Temp; REAR=Temp; } }
  • 39.
    302 OR Any other codedemonstrating proper Insert() for a dynamic Queue. (1 mark for creating a dynamic Node and entering / assigning the value for Name) (1 mark for creating a Link with the previous Node) (1 mark for assigning new value of Rear.) Note: 1. Ignorethestructandclassimplementationwhileawardingmarks in this question 2. Equivalent code with DynamicArray should also be considered as correct solution (e) 10*3*(7-1)+23 (Full 2 marks to be given to students who have correctly attempted for at least 1 mark in the entire Q. No. 3 (a) to 3 (e)) Note:AsstudentsareexposedtoConversionfromINFIXtoPOSTFIX and Evaluation of POSTFIX only, he/she may not be able to comprehend the conversion from POSTFIX to INFIX. 4. (a) 4 (1 mark for correct output) OR (1 mark if error mentioned due to usage of tellg() with app mode) (b) void CountSpace() { fstream fin; fin.open(“PARA.TXT”, ios::in); OR ifstream fin(“PARA.TXT”); char ch ; int count = 0; while(!fin.eof()) { ch = fin.get(); if (ch == ‘ ‘) //(ch==32) OR (ch==255) count ++; } cout<<”Number of spaces = “<<count; //Ignore fin.close(); //Ignore }
  • 40.
    303 OR Any equivalent codethat counts the number of words from the file (1/2 Mark for opening the file in right mode) (1/2 Mark for correct loop structure i.e. with a condition checking for end of file) (1/2 Mark for reading a character / line from the file) (1/2 Mark for checking for space and incrementing the counter) (c) void modify( ) { fstream out; out.open(“PRODUCT.DAT”,ios::binary|ios::in|ios::out); PRODUCT P1; int flag=0,stock;char PCode[10]; gets(PCode); cin>>stock; while (out.read((char*)&P1, sizeof(P1)) if (strcmp(P1.Product_code,Pcode)==0) // strcmpi()may also be considered { flag=1; P1.Stock=stock; int Position=out.tellg( )-sizeof(P1); out.seekp(Position); //OR out.seekp(-sizeof(P1),ios::cur); out.write((char*)&P1, sizeof(P1); } } if (flag==0) cout<<”Product Code does not match”; //OR if (!flag) cout<<”Product Code does not match”; out.close(); } OR Any other equivalent code (1/2 Mark for opening the file in ‘in’ as well as ‘out’ mode) (1/2 Mark for declaring object and temporary variables required for product code and stock) (1/2 Marks for correct loop, check of end of file and reading of an object from the file) (1/2 Mark for correct comparison) (1/2 Mark for identifying and moving the file pointer to the correct position) (1/2 Mark writing the modified/updated data on right position in the file)
  • 41.
    304 5. (a) DDL–DataDefinitionLanguage DML–DataManipulationLanguage (1Mark each for correct full form OR correctly explaining with the help of examples) (b) (i) SELECT FL_NO,NO_FLIGHTS FROM FLIGHTS WHERE STARTING=’KANPUR’ AND ENDING=’BANGALORE’; (1/2 Mark for using SELECT and FROM correctly) (1/2 Mark for correct WHERE clause) (ii) SELECT * FROM FLIGHTS ORDER BY FL_NO; (1/2 Mark for using SELECT and FROM correctly) (1/2 Mark for correct ORDER BY clause [ASC is optional]) (iii) SELECT FLIGHTS.FL_NO, FARE+FARE*TAX/100 FROM FLIGHTS, FARES WHERE FLIGHTS.STARTING=’DELHI’ AND FLIGHTS.ENDING=’MUMBAI’ AND FLIGHTS.FL_NO=FARES.FL_NO; *Assuming TAX% as TAX (Full 1 Mark for correctly attempting any part of 5 (b)) (iv) SELECT MIN(FARE) FROM FARES WHERE AIRLINES=’INDIAN AIRLINES’; (1/2 Mark for using SELECT and FROM with MIN function correctly) (1/2 Mark for correct WHERE clause) (v) FL_NO NO_FLIGHTS AIRLINES IC302 8 IndianAirlines AM501 1 JetAirways IC701 4 IndianAirlines (1 Mark for correct output, Ignore First header line) (vi) 7 (1 Mark for correct output)
  • 42.
    305 6. (a) (i)X+(Y+Z)=(X+Y)+Z X Y Z Y+Z X+Y X+(Y+Z) (X+Y)+Z 0 0 0 0 0 0 0 0 0 1 1 0 1 1 0 1 0 1 1 1 1 0 1 1 1 1 1 1 1 0 0 0 1 1 1 1 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 (ii) X.(Y.Z)=(X.Y).Z X Y Z Y.Z X.Y X.(Y.Z) (X.Y).Z 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 1 1 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 1 0 0 1 0 0 1 1 1 1 1 1 1 (1 Mark for stating any one of the law) (1 Mark for verification of any one of the law) (b) (A+C)’.(A+B)’.(B+C)’ (1/2 Mark each for (A+C)’, (A+B)’, (B+C)’ and final expression) OR (Full 2 marks even if students have mentioned the reduced form of the same expression) (c) (P+Q’).(P+R) OR (P+Q’+R).(P+Q’+R’).(P+Q+R) (1 Mark for any of the two POS forms of the given expression)
  • 43.
    306 (d) R+S R+S' R'+S'R'+S P+Q 0 0 P+Q' 0 0 0 P'+Q' 0 0 P'+Q 0 F(P,Q,R,S)= (P+Q+R+S).(P’+Q’+R+S).(P+Q’+R’).(P+Q’+S’).(R’+S’) (1 mark for representing correct places in K-Maps) AND (1/2 mark for grouping and writing minimum 2 Groups) OR (1 mark for grouping and writing minimum 3 Groups) OR (1 ½ mark for grouping and writing 5 Groups) OR (2 mark for grouping and writing final expression in reduced form) Important: 1/2 Mark to be deducted for redundant group(s) OR 00 01 11 10 00 1 1 01 1 11 1 1 10 1 1 1 F(P,Q,R,S)=P’QR’S’+PQ’S’+PRS’+PR’S+Q’RS’+Q’R’S RS PQ 0 4 12 8 1 5 13 9 7 15 11 3 6 14 16 2 SingleII Pair II Quad I Pair I SingleI RS PQ 0 4 12 8 1 5 13 9 7 15 11 3 6 14 16 2 SingleI Pair V Pair III Pair II Pair IV Pair I
  • 44.
    307 (1 mark forrepresenting correct places in K-Maps) AND (1/2 mark for grouping and writing minimum 2 Groups) OR (1 mark for grouping and writing minimum 4 Groups) OR (1 ½ mark for grouping and writing 6 Groups) OR (2 mark for grouping and writing final expression in reduced form) Important: 1/2 Mark to be deducted for redundant group(s) 7. (a) OpticalFiber Ethernet Cable or twisted pair cable or UTP or STP Co-axial Cable Infrared Radio Link OR Radiowave Microwave link OR Microwave Satellite Link [Any TWO of the mentioned above OR any other correct media] (1/2 Mark for each correct answer) (b) (i) XML ExtensibleMarkupLanguage (ii) GSM GlobalSystemforMobilecommunication {ignorecommunication} (iii) SMS ShortMessagingService {Message/Messagingbothacceptable} (iv)MAN MetropolitanArea Network (1/2 Mark for each correct answer) (No marks for partially correct answers) (c) Hackers:Computerenthusiastswhoenjoylearningaboutcomputersystems andgetintoothersystem/networkforgainingmoreknowledgeormayfind flawsinthesystemforrectificationpurposes. Crackers:Maliciousprogrammerswhobreakintosecuresystemsforstealing andcorrupting/spoilingdata. (1/2 Mark for definition of each Hacker and Cracker) OR (Full 1 Mark for mentioning the difference)
  • 45.
    308 (d) (i) StarTopology OR BusTopology (1Mark for mentioning any one of the two topologies) OR (1 Mark for diagramatic representation of any of the above mentioned topologies) (ii) WingS asithasthemaximumnumberofcomputers OR WingA asitisplacedintheAdminWing(forsecurityreasons) (1/2 Mark for identification of the correct Wing) (1/2 Mark for correct justification) (iii) Insideallthefourwings (1 Mark for the correct answer) (iv) Anyoneofthefollowing: Dialup,TCP/IP, DSL, Modem, Broadband, Cable, ISDN,Telephone Line,Co-axial,EthernetCable,Radiowave (1 Mark for the correct answer) Important Note: Satellite Link, Optical Fiber, Microwave and Leased line are not acceptable solution for this question
  • 46.
    261 COMPUTER SCIENCE Time allowed: 3 hours Maximum marks: 70 General Instructions: (i) All questions are compulsory. (ii) Programming Language : C++ QUESTION PAPER CODE 91 1. (a) DifferentiatebetweenaLogicalErrorandSyntaxError.Alsogivesuitable examples of each in C++. 2 (b) Name theheaderfile(s)thatshallbeneeded for successful compilation of thefollowingC++code: 1 void main( ) { char Text[40]; strcpy(Text,”AISSCE”); puts(Text); } (c) Rewrite the following program after removing the syntactical error(s), ifany.Underlineeachcorrection. 2 #include <iostream.h> const int Size 5; void main() { int Array[Size]; Array = {50,40,30,20,10}; for(Ctr=0; Ctr<Size; Ctr++) cout>>Array[Ctr]; } (d) Findtheoutputofthefollowingprogram: 2 #include<iostream.h> void main() { int Numbers[] = {2,4,8,10};
  • 47.
    262 int *ptr =Numbers; for (int C = 0; C<3; C++) { cout<< *ptr << “@”; ptr++; } cout<<endl; for(C = 0; C<4; C++) { (*ptr)*=2; --ptr; } for(C = 0; C<4; C++) cout<< Numbers [C]<< “#”; cout<<endl; } (e) Findtheoutputofthefollowingprogram: 3 #include<iostream.h> void Indirect(int Temp=20) { for (int 1=10; I<=Temp; I+=5) cout<<I<<” , “ ; cout<<endl; } void Direct (int &Num) { Num+=10; Indirect(Num); } void main() { int Number=20; Direct(Number) ; Indirect(); cout<< “ Number=” <<Number<<endl ; }
  • 48.
    263 (f) In thefollowing C++ program what is the expected value of Myscore from Options(i)to(iv)givenbelow.Justifyyouranswer. 2 #include<stdlib.h> #include<iostream.h> void main( ) { randomize(); int Score[] = {25,20,34,56, 72, 63}, Myscore; Myscore = Score[2 + random(2)]; cout<<Myscore<<endl; } (i) 25 (ii) 34 (iii) 20 (iv) None of the above 2. (a) Differentiate between Protected and Private members of a class in context ofInheritanceusing C++. 2 (b) Answerthequestions(i)and(ii)aftergoingthroughthefollowingclass: 2 class Science { char Topic[20]; int Weightage; public: Science ( ) //Function 1 { strcpy (Topic, “Optics” ); Weightage = 30; cout<<“Topic Activated”; } ~Science( ) //Function 2 { cout’<<”Topic Deactivated”; } (i) NamethespecificfeaturesofclassshownbyFunction1andFunction 2 in the above example. (ii) How would Function 1 and Function 2 get executed ?
  • 49.
    264 (c) DefineaclassTravelinC++withthedescriptiongivenbelow: 4 PrivateMembers: T_Codeoftypestring No_of_Adults oftypeinteger No_of_Children oftypeinteger Distance oftypeinteger TotalFare oftypefloat PublicMembers: • Aconstructortoassigninitialvaluesasfollows: T_Code with the word “NULL” No_of_Adults as 0 No_of_Children as 0 Distance as 0 TotalFare as 0 • AfunctionAssignFare( )whichcalculatesandassignsthevalue of the data memberTotalFare as follows : For each Adult Fare (Rs) For Distance (Km) 500 >=1000 300 <1000 & >=500 200 <500 For each Child the above Fare will be 50% of the Fare mentioned in the above table. Forexample: If Distance is 750, No_of_Adults = 3 and No_of_Children = 2 ThenTotalFare should be calculated as No_of_Adults * 300 + No_of_Children * 150 i.e. 3 * 300 + 2 * 150 = 1200 • AfunctionEnterTraveK)toinputthevaluesofthedatamembers T_Code, No_of_Adults, No_of_Children and Distance; and invoketheAssignFare()function. • Afunction ShowTraveK) which displays the content of all the data members for aTravel. (d) Answer the questions (i) to (iv) based on the following code : 4 class Teacher { char TNo[5], TName[20], DeptflO]; int Workload;
  • 50.
    265 protected: float Salary; void AssignSal(float); public: Teacher() ; void TEntry( ) ; void TDisplay( ); }; class Student { char Admno[10], SName[20], Stream[10]; protected: int Attendance, 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) Identifythememberfunctiion(s)thatcannotbecalleddirectlyfromthe objectsofclassSchoolfromthefollowing: TEntry() SDisplay() SchEntry() (iii) Writenameofallthemember(s)accessiblefrommemberfunctionsof class School. (iv) IfclassSchoolwasderivedprivatelyfromclassTeacherandprivately from class Student, then, name the member function(s) that could be accessed through Objects of class School.
  • 51.
    266 3. (a) Writea function in C++ which accepts an integer array and its size.as argumentsandreplaceselementshavingevenvalueswithitshalfandelements havingoddvalueswithtwiceitsvalue. 4 Example:ifanarrayoffiveelementsinitiallycontainstheelementsas 3, 4, 5, 16, 9 then the function should rearrange the content of the array as 6, 2, 10, 8, 18 (b) AnarrayArr[15][20]isstoredinthememoryalongtherowwitheachelement occupying 4 bytes. Find out the BaseAddress and address of the element Arr[3][2], if the elementArr[5][2] is stored at the address 1500. 4 (c) WriteafunctioninC++todeleteanodecontainingcustomer’sinformation, from a dynamically allocated Queue of Customers implemented with the helpofthefollowingstructure: 4 struct Customer { int CNo; char CName[20]; Customer *Link; }; (d) Write a functionin C++ whichaccepts a2D arrayofintegers andits size asargumentsanddisplaystheelementsofmiddlerowandtheelementsof middlecolumn. 2 [Assuming the 2DArray to be a square matrix with odd dimension i.e. 3×3, 5×5, 7×7 etc...] Example,ifthearraycontentis 3 5 4 7 6 9 2 1 8 Outputthroughthefunctionshouldbe: Middle Row : 7 6 9 Middle Column : 5 6 1 (e) Evaluatethefollowingpostfixnotationofexpression: 2 15 3 2 + / 7 + 2 * 4. (a) Observetheprogramsegmentgivenbelowcarefully,andanswerthequestion thatfollows: 1 class Labrecord { int Expno; char Experiment[20]; char Checked;
  • 52.
    267 int Marks; public : //functionto enter Experiment details void EnterExp( ); //function to display Experiment details void ShowExp ( ) ; //function to return Expno char RChecked ( ) {return Checked;} //function to assign Marks void Assignmarks(int M) { Marks = M;} }; void MpdifyMarks() { fstream File; File.open(“Marks.Dat”,ios::binary|ios::in|ios::out); Labrecord L; int Rec = 0; while (File.read((char*)&L, sizeof(L))) { if(L.RChecked( )== ‘ N ‘ ) L.Assignmarks(0) else L.Assignmarks(10) _____________________ //statement 1 ______________________ //statement 2 Rec ++ ; } File.close (); } IfthefunptionModifyMarks()issupposedtomodifyMarksfortherecords in the file MARKS.DAT based on their status of the member Checked (containing value eitherVor ‘N’).Write C++ statements for the statement 1and statement 2, where, statement 1is required to position the file write pointer to an appropriate place in the file and statement 2 is to perform the writeoperationwiththemodifiedrecord. (b) WriteafunctioninC++toprintthecountoftheword theasanindependent wordinatextfileSTORY.TXT. 2 For example, if the content of the file STORY.TXTis There was a monkey in the zoo. The monkeywasverynaughty. Then the output of the program should be 2.
  • 53.
    268 (c) Given abinary file SPORTS.DAT, containing records of the following structuretype: struct Sports { char Event[20]; char Participant[10][30]; }; WriteafunctioninC++thatwouldreadcontentsfromthefileSPORTS.DAT andcreatesafilenamedATHLETIC.DATcopyingonlythoserecordsfrom SPORTS.DATwheretheeventnameis“Athletics”. 3 5. (a) What is the importance of a Primary Key in a table ? Explain with a suitable example. 2 (b) Consider the following tables Consignor and Consignee. Write SQL commandsforthestatements(i)to(iv)andgiveoutputsforSQLqueries(v) to(viii). 6 TABLE : CONSIGNOR CnorlD CnorName CnorAddress City ND01 RSinghal 24,ABC Enclave NewDelhi ND02 AmitKumar 123,PalmAvenue NewDelhi MU15 RKohli 5/A, South Street Mumbai MU50 S Kaur 27-K, Westend Mumbai TABLE : CONSIGNEE CneelD CnorlD CneeName CneeAddress CneeCity MU05 ND01 RahulKishore 5, ParkAvenue Mumbai ND08 ND02 PDhingra 16/J, Moore Enclave NewDelhi KO19 MU15 APRoy 2A,CentralAvenue Kolkata MU32 ND02 SMittal P245,AB Colony Mumbai ND48 MU50 BPJain 13, Block D,AVihar NewDelhi (i) TodisplaythenamesofallConsignorsfromMumbai.’ (ii) To display the CneelD, CnorName, CnorAddress, CneeName, CneeAddress for every Consignee. (iii) To display consignee details in ascending order of CneeName. (iv) To displaynumberofconsignorsfromeachcity,
  • 54.
    269 (v) SELECT DISTINCTCity FROM CONSIGNEE; (vi) SELECTA.CnorName, B.CneeName FROM ConsignorA, Consignee B WHEREA.CnorID = B.CnorlDAND B.CneeCity = ‘Mumbai’; (vii) SELECT CneeName, CneeAddress FROMConsignee WHERE CneeCity NOT IN (‘Mumbai’, ‘Kolkata’); (viii) SELECT CneelD, CneeName FROMConsignee WHERE CnorID=’MU15' OR CnorID=’ND01'; 6. (a) State De Morgan’sTheorems and verify the same using truth table. 2 (b) WritetheequivalentCanonicalProductofSumExpressionforthefollowing SumofProductExpression F(X, Y, Z) = Σ (0, 2, 4, 5) 2 (c) WritetheequivalentBooleanexpressionforthefollowingLogicCircuit. 2 (d) ReducethefollowingBooleanexpressionusingK-Map: 2 F(A, B, C, D) = π(5,6,7,8,9,12,13,14,15) 7. (a) What is the significance of Cyber Law ? 1 (b) ExpandthefollowingtermswithrespecttoNetworking: 2 (i) XML (ii) WWW (iii) WLL (iv) TCP/IP
  • 55.
    270 (c) Which ofthe following units measures the speed with which data can be transmitted from one node to another node of a network ?Also, give the expansionofthesuggestedunit. 1 (i) KMph (ii) Mbps (iii) MGps (d) “HindustanConnectingWorldAssociation”isplanningtostarttheirofficesin fourmajorcitiesinIndiatoprovideregionalITinfrastructuresupportinthe fieldofEducation&Culture.Thecompanyhasplannedtosetuptheirhead officeinNewDelhiinthreelocationsandhavenamedtheirNewDelhioffices as“SalesOffice”,”HeadOffice”and“TechOffice”.Thecompany’sregional offices are located at ”Coimbatore”, “Kolkata” and “Ahmedabad”. Aroughlayoutofthesameisasfollows: Approximate distances between these offices as per network survey team is asfollows: Place From PlaceTo Distance HeadOffice SalesOffice 10 KM HeadOffice TechOffice 70 Meter HeadOffice KolkataOffice 1291 KM HeadOffice AhmedabadOffice 790 KM HeadOffice CoimbatoreOffice 1952 KM
  • 56.
    271 In continuation ofthe above, the company experts have planned to install thefollowingnumberofcomputersineachoftheiroffices: HeadOffice 100 SalesOffice 20 TechOffice 50 KolkataOffice 50 AhmedabadOffice 50 CoimbatoreOffice 50 (i) Suggestnetworktype(outofLAN,MAN,WAN)forconnectingeach ofthefollowingsetoftheiroffices: • Head Office andTech Office • Head Office and Coimbatore Office (ii) Which device will you suggest to be procured by the company for connecting all the computers within each of, their offices out of the followingdevices? • Modem • Telephone • Switch/Hub (iii) Whichofthefollowingcommunicationmedia,willyousuggesttobe procured by the company for connecting their local offices in New Delhiforveryeffectiveandfastcommunication? • EthernetCable • OpticalFiber • TelephoneCable (iv) Suggestacable/wiringlayoutforconnectingthecompany’slocaloffices located in New Delhi.Also,, suggest an effective method/technology for connecting the company’s regional offices at “Kolkata”, “Coimbatore”and“Ahmedabad”. 4 QUESTION PAPER CODE 91/1 1. (a) DifferentiatebetweenaRunTimeErrorandSyntaxError.Alsogivesuitable examples of each in C++. 2 (b) Nametheheaderfile(s)thatshallbeneededforsuccessfulcompilationofthe followingC++code 1 void main ( ) { char String [20]; gets (String); strcat (String, “CBSE”); puts (String); }
  • 57.
    272 (c) Rewritethefollowingprogramafterremovingthesyntacticalerror(s)ifany. Underlineeachcorrection. 2 #include <iostream.h> const int Max 10; void main ( ) { int Numbers [Max]; Numbers = { 20, 50,10, 30,40 } ; for (Loc= Max-1 ; Loc > = 0 ; Loc - -) cout>>Numbers [Loc]; } (d) Findtheoutputofthefollowingprogram: 2 # include < iostream.h> void main () { intArray[] = {4,6,10,12}; int *pointer = Array ; for (int I=1 ; I<=3 ; I++) { cout<<*pointer<<#”; pointer ++; } cout<<endl; for (I=1 ; I<=4 ; I++) { (*pointer)*=3 ; -- pointer; } for(I=l; I<5; I + + ) cout << Array [I-1] << “@”; cout << endl; } (e) Findtheoutputofthefollowingprogram: 3 # include < iostream.h> void Withdef (int HisNum = 30) { for (int 1=20 ; I<*= HisNum; I+=5) cout<<I<<””; cout<<endl; } void Control (int &MyNum) {
  • 58.
    273 MyNum+=10; Withdef(MyNum); } void main () { intYourNum=20; Control (YourNum); Withdef(); cout<<”Number=”<<YourNum<<endl; } (f) InthefollowingC++programwhatistheexpectedvalueofMyMarksfrom Options(i)to(iv)givenbelow.Justifyanswer. 2 #include<stdlib. h > # include<iostream. h> void main () { randomize (); int Marks [ ]= {99, 92, 94, 96, 93, 95}, MyMarks; MyMarks = Marks [1 + random (2) ]; cout<<MyMarks<<endl; } (i) 99 (ii) 94 (iii) 96 (iv) None of the above 2. (a) DifferentiatebetweenConstructorandDestructorfunctionincontextof Classes and Objects using C++ 2 (b) Answerthequestions(i)and(ii)aftergoingthroughthefollowingclass 2 class Maths { char Chapter [20]; int Marks; public: Maths ( ) //Member Function 1 { strcpy (Chapter, “Geometry”); Marks = 10; cout<<“Chapter Initialised”; { ~Math () //Member Function 2 } cout<<”Chapter Over”; } };
  • 59.
    274 (i) NamethespecificfeaturesofclassshownbyMemberFunction1and Member Function2 in the above example. (ii) HowwouldMemberFunction1andMemberFunction2getexecuted? (c) Define a classTour in C++ with the description given below : 3 PrivateMembers: TCode oftypestring NoofAdults oftypeinteger NoofKids oftypeinteger Kilometres oftypeinteger TotalFare oftypefloat PublicMembers: • Aconstructortoassigninitialvaluesasfollows: TCode with the word “NULL” NoofAdults as 0 NoofKids as 0 Kilometres as 0 TotalFare as 0 • AfunctionAssignFare ( ) which calculates and assigns the value of the data memberTotalFare as follows For each Adult Fare(Rs) For Kilometres 500 >=1000 300 <1000&>=500 200 <500 Foreach KidtheaboveFarewillbe50%oftheFarementionedinthe above table Forexample: If Kilometres is 850, NoofAdults = 2 and NoofKids = 3 ThenTotalFare should be calculated as NumofAdults * 300 + NoofKids * 150 i.e. 2*300 + 3*150=1050 • A function EnterTour( ) to input the values of the data members TCode, NoofAdults, NoofKids and Kilometres; and invoke the AssignFare()function. • A function ShowTour( ) which displays the content of all the data members for aTour.
  • 60.
    275 (d) Answer thequestions (i) to (iv) based on the following code : 4 class Trainer { char TNo [5], TName [20], Specialisation [10]; int Days; protected : float Remuneration; void AssignRem (float); public : Trainer ( ) ; void TEntry ( ); void TDisplay ( ); }; class Learner { char Regno [10], LName [20], Program [10]; Protected : int Attendance, Grade; public: Learner ( ); void LEntry ( ); void LDisplay ( ); }; class Institute : public Learner, public Trainer { char ICode[10], IName [20]; ( public: Institute ( ); void IEntry ( ); void IDisplay ( ); }; (i) Which type of Inheritance is depicted by the above example? (ii) Identifythememberfunction(s)thatcannotbecalleddirectlyfromthe objectsofclassInstitutefromthefollowing TEntry() LDisplay() IEntry()
  • 61.
    276 (iii) Writenameofallthemember(s)accessiblefrommemberfunctionsof classInstitute. (iv) IfclassInstitutewasderivedprivatelyfromclassLearnerandprivately fromclassTrainer, then, name the member function(s) that could be accessed through Objects of class Institute. 3. (a) Write a function in C++ which accepts an integer array and its size as argumentsandreplaceselementshavingoddvalueswiththriceitsvalueand elementshavingevenvalueswithtwiceitsvalue. Example:ifanarrayoffiveelementsinitiallycontainstheelementsas 3, 4, 5, 16, 9 then the function should rearrange the content of the array as 9, 8, 15, 32, 27 4 (b) AnarrayArray[20][15]isstoredinthememoryalongthecolumnwitheach element occupying 8 bytes. Find out the BaseAddress and address of the elementArray[2][3] if the elementArray [4] [5] is stored at the address 1000. 4 (c) Write a function in C++ to delete a node containing Book’s information, fromadynamicallyallocatedStackofBooksimplementedwiththehelpof thefollowingstructure. 4 struct Book } int BNo; char BName[20]; Book *Next; }; (d) Write a function in C++ which accepts a 2D array of integers and its size as argumentsanddisplaystheelementswhichlieondiagonals. 2 [Assuming the 2DArray to be a square matrix with odd dimension i.e. 3×3, 5×5, 7×7 etc.] Example,ifthearraycontentis 5 4 3 6 7 8 1 2 9 Outputthroughthefunctionshouldbe: Diagonal One : 5 7 9 Diagonal Two : 3 7 1
  • 62.
    277 (e) Evaluatethefollowingpostfixnotationofexpression: 2 258 3 - / 6 * 10 + 4. (a) Observetheprogramsegmentgivenbelowcarefully,andanswerthequestion thatfollows: 1 class PracFile { intPracno; char PracName[20]; int TimeTaken; int Marks; public: // function to enter PracFile details void EnterPrac( ); // function to display PracFile details void ShowPrac( ): // function to return TimeTaken int RTime() {return TimeTaken;} // function to assign Marks void Assignmarks (int M) { Marks = M;} }; void AllocateMarks( ) { fstreamFile; File.open(“MARKS.DAT”,ios::binary|ios::in|ios::out); PracFile P; int Record = 0; while (File.read(( char*) &P, sizeof(P))) { if(P.RTime()>50) P.Assignmarks(0) else P.Assignmarks(10) ______________ //statement 1 ______________ //statement 2 Record + + ; } File.close(); } IfthefunctionAllocateMarks()issupposedtoAllocateMarksfortherecords in the file MARKS.DAT based on their value of the member TimeTaken. Write C++ statements for the statement 1 and statement 2, where, statement 1 is required to position the file write pointer to an appropriate place in the file and statement 2 is to perform the write operation with the modifiedrecord.
  • 63.
    278 (b) Write afunctionin C++ to print the count of the word is as an independentwordinattextfileDIALOGUE.TXT. 2 For example, if the content of the file DIALOGUE. TXT is This is his book. Is this book good? Then the output of the program should be 2. (c) GivenabinaryfileGAME.DAT,containingrecordsofthefollowingstructure type 3 struct Game { char GameName [20]; char Participant [10] [30]; }; WriteafunctioninC++thatwouldreadcontentsfromthefileGAME.DAT and creates a file named BASKET.DAT copying only those records from GAME.DATwherethegamenameis“BasketBall” 5. (a) Differentiatebetweenprimarykeyandalternatekey. 2 (b) Consider the following tables. Write SQL commands for the statements (i) to (iv) and give outputs for SQL queries (v) to (viii) 6 TABLE:SENDER SenderlD SenderName SenderAddress SenderCiry ND01 RJain 2,ABCAppts NewDelhi MU02 HSinha 12, Newtown Mumbai MU15 S Jha 27/A, Park Street Mumbai ND50 T Prasad 122-K, SDA NewDelhi TABLE : RECIPIENT RecID SenderlD RecName RecAddress RecCiry KO05 ND01 R Bajpayee 5, CentralAvenue Kolkata ND08 MU02 S Mahajan 116,AVihar NewDelhi MU19 ND01 HSingh 2A,AndheriEast Mumbai MU32 MU15 P K Swamy B5, C STerminus Mumbai ND48 ND50 STripathi 13, B1 D, Mayur Vihar NewDelhi
  • 64.
    279 (i) TodisplaythenamesofallSendersfromMumbai (ii) Todisplay the RecID), SenderName, SenderAddress, RecName, RecAddressforeveryRecipient (iii) To displayRecipientdetailsinascendingorderofRecName (iv) TodisplaynumberofRecipientsfromeachcity (v) SELECT DISTINCT SenderCity FROM Sender; (vi) SELECTA. SenderName, B.RecName FROM SenderA, Recipient B WHEREA. SenderlD = B.SenderlDAND B.RecCity = ‘Mumbai’; (vii) SELECT RecName, RecAddress FROMRecipient WHERE RecCity NOT IN (‘Mumbai’, ‘Kolkata’); (viii) SELECT RecID, RecName FROMRecipient WHERE SenderID=’MU02' ORSenderID=’ND50'; 6. (a) StateDistributivelawandverifythesameusingtruthtable. 2 (b) WritetheequivalentCanonicalSumofProductexpressionforthefollowing ProductofSumExpression 2 F(X,Y,Z) = π (1,3,6,7) (c) WritetheequivalentBooleanExpressionforthefollowingLogicCircuit. 2 (d) ReducethefollowingBooleanexpressionusingK-Map 2 F(U,V,W,Z) = Σ (0, 1, 2, 3, 4, 10, 11) 7. (a) WhatisthesignificanceofCyberlaw? 1 (b) ExpandthefollowingtermswithrespecttoNetworking: 2 (i) CDMA (iii) FTP (ii) WLL (iv) HTML
  • 65.
    280 (c) Which ofthe following unit measures the speed with which data can be transmitted from one node to another node of a network?Also, give the expansionofthesuggestedunit. 1 (i) Mbps (ii) KMph (iii) MGps (d) “BhartiyaConnectivityAssociation”isplanningtospreadtheirofficesinfour majorcitiesinIndiatoprovideregionalITinfrastructuresupportinthefield ofEducation&Culture.Thecompanyhasplannedtosetuptheirheadoffice in New Delhi in three locations and have named their New Delhi offices as “Front Office”, “Back Office” and “Work Office”.The company has three more regional offices as “South Office”, “East Office” and “West Office” located in other three major cities of India.Arough layout of the same is as follows: 4 Approximatedistancesbetweentheseofficesaspernetworksurveyteamis asfollows: Place From Place To Distance BackOffice FrontOffice 10KM BackOffice WorkOffice 70 Meter BackOffice EastOffice 1291 KM BackOffice WestOffice 790 KM BackOffice SouthOffice 1952 KM
  • 66.
    281 Incontinuationoftheabove,thecompanyexpertshaveplannedtoinstallthe followingnumberofcomputersineachoftheiroffices: BackOffice 100 FrontOffice 20 WorkOffice50 EastOffice 50 WestOffice 50 SouthOffice 50 (i) Suggestnetworktype(outofLAN,MAN,WAN)forconnectingeach ofthefollowingsetoftheiroffices: • Back Office and Work Office • BackOfficeandSouthOffice (ii) Which device you will suggest to be procured by the company for connecting all the computers with in each of their offices out of the followingdevices? • Switch/Hub • Modem • Telephone (iii) Whichofthefollowingcommunicationmedium,youwillsuggesttobe procured by the company for connecting their local offices in New Delhiforveryeffectiveandfastcommunication? • TelephoneCable • OpticalFiber • EthernetCable (iv) Suggestacable/wiringlayoutforconnectingthecompany’slocaloffices located in New Delhi.Also, suggest an effective method/technology for connecting the company’s regional offices-”East Office”, “West Office”and“SouthOffice”withofficeslocatedinNewDelhi.
  • 67.
    282 Marking Scheme —Computer Science Important Note The answers given in the marking scheme are SUGGESTIVE. Examiners are requested to awardmarksforallalternativecorrectSolutions/Answersconveyingthesimilarmeaning All programming questions have to be answered with respect to C++ Language only InC++,ignorecasesensitivityforidentifiers(Variable/Functions/Structures/ClassNames) InSQLrelatedquestions–bothwaysoftext/characterentriesshouldbeacceptableforExample: “AMAR” and ‘amar’both are correct. InSQLrelatedquestions–semicolonshouldbeignoredforterminatingtheSQLstatementsIn SQLrelatedquestions,ignorecasesensitivity. QUESTION PAPER CODE 91 EXPECTEDANSWERS/VALUE POINTS 1. (a) LogicalError: Error occurred due to incorrect logic applied by the programmer. SyntaxError: Erroroccurredduetonotfollowingthepropergrammar/syntaxofthelanguage OR Erroroccurredduetoviolatingrulesoftheprogramminglanguage Example: //Program to find area and perimeter of rectangle void main() { int A,B,AR,P; A=10; B=20; AR=2*(A*B); //Logical Error – Wrong Formula P=2*(A+B); cout<<A<<P>>endl; //Syntax Error – Use of >> with cout } (½ Mark for each correct explanation of Logical Error and Syntax Error) (½ Mark for each correct example of Logical Error and Syntax Error) OR (Full 2 Marks for correct examples demonstrating the difference between Logical Error and Syntax Error) Note: Only 1 Mark to be awarded if Explanation is given without supporting example.
  • 68.
    283 (b) string.h stdio.h (½ Markfor identifying each correct header file) Note: Marks are not to be deducted if any additional header file is mentioned (c) #include<iostream.h> const int Size =5; void main( ) { int Array[Size]={50,40,30,20,10}; for(int Ctr=0;Ctr<Size;Ctr++) cout<<Array[Ctr]; } (½ Mark for each correction) OR (1 Mark for identifying at least three errors, without suggesting correction) (d) 2 @ 4 @ 8 @ 4 # 8 # 16 # 20 # (1 Mark for each correct line of output) Note: · ½ Mark to be deducted for missing symbols in each line of output · ½ Mark to be deducted if endl is not considered in the output · As Borland C++ Compiler declares for loop variable locally, the program will result in syntax errors. So, any student specifying Variable C not declared OR mentioning that the program will not RUN due to incorrect syntax should be awarded full 2 Marks (e) 10, 15, 20, 25, 30, 10, 15, 20, Number=30 (1 Mark for each correct line of output) Note: · ½ Mark to be deducted for missing Commas (,) in each line of output · ½ Mark to be deducted if endl is not considered in the output
  • 69.
    284 (f) (ii) 34 (1Mark for the correct answer) (1 Mark for the correct justification) 2. (a) Base Class AccessSpecifier DerivedClass Protected Private Private Protected Protected Public Protected Private Private NotAccessible Protected NotAccessible Public NotAccessible (1 mark each for correct explanation of Private and Protected members) Note: If the contents of the above table is explained correctly in any format (with or without example) full 2 marks are to be awarded. (b) (i) Function1:Constructor/DefaultConstructor Function2:Destructor (½ Marks for each correct answer) (ii) Function 1 is executed or invoked automatically when an object of class Science is created. Function 2 is invoked automatically when the scope of an object of class Science comes to an end. OR Example: { Science s1;//Constructor is invoked } // the destructor is invoked (½ Mark for each correct answer through explanation OR example) (c) class Travel { char TCode[5]; //OR char *Tcode; int No_of_Adults; int No_of_Children; int Distance; float TotalFare;
  • 70.
    285 public: Travel(); void AssignFare(); void EnterTravel(); voidShowTravel(); }; Travel::Travel() { strcpy(TCode,”NULL”);// OR TCode[0]=’0’ OR strcpy(TCode,”0”) // OR TCode=NULL if TCode is declared as char pointer No_of_Adults = 0; No_of_Children = 0; Distance = 0; TotalFare = 0; } void Travel::AssignFare() { if(Distance>=1000) TotalFare = 500*No_of_Adults+250*No_of_Children; else if (Distance >= 500) TotalFare = 300*No_of_Adults+150*No_of_Children; else TotalFare = 200*No_of_Adults+100*No_of_Children; } void Travel::EnterTravel() { gets(TCode); // or cin >> TCode; cin>>No_of_Adults>>No_of_Children>>Distance; AssignFare(); } void Travel::ShowTravel() { cout<<TCode<<No_of_Adults<<No_of_Children <<Distance<<TotalFare<<endl; } (½ Mark for correct syntax of class header) (½ Mark for correct declaration of data members) (1 Mark for correct definition of constructor) (1 Mark for checking all three conditions and calculating TotalFare in AssignFare( )) (½ Mark for correct EnterTravel( ) with proper invocation of AssignFare( )) (½ Mark for displaying all data Members including TotalFare inside ShowTravel( ))
  • 71.
    286 (d) (i) MultipleInheritance (1Mark for correct answer) (ii) None OR Allthefunctionscanbecalled. (1 Mark for any of the correct answer) (iii) Data Members: SCode, SchName, Attendance, TotMarks, Salary Member Functions: SchDisplay(), SchEntry(), SEntry(), SDisplay( ), TEntry( ), TDisplay( ), AssignSal( ) ( 1 Mark for all correct members) NOTE: · Mention of Constructor functions School(), Student() and Teacher() to be ignored. · No marks to be awarded for partially correct answers (iv) SchEntry( ),SchDisplay( ). ( 1 Mark for all correct member functions) NOTE: · Constructor function School() to be ignored. · No marks to be awarded for partially correct answers 3. (a) void Display(int NUM[],int N) { for(int i=0;i<N;i=i+1) { if(NUM[i]%2==0) NUM[i]=NUM[i]/2; else NUM[i]=2*NUM[i]; } } OR void Display(int NUM[],int N) { for(int i=0;i<N;i=i+1) NUM[i]=(NUM[i]%2!=0)?2*NUM[i]:NUM[i]/2; } (1 Mark for correct Function Header with proper Arguments) (1 Mark for correct loop) (1 Mark for checking Even / Odd values) (1 Mark for replacing array elements with proper values)
  • 72.
    287 (b) Assuming LBR=LBC=0 S=4bytes Number of Rows(N)=15 Number of Columns(M)=20 LOC(Arr[I][J]).= B +((I-LBR)*M+(J-LBC))*S LOC(Arr[5][2]).= B +((5-0)*20+(2-0))*4 1500.= B +(100+2)*4 B.= 1500-408 B.= 1092 LOC(Arr[3][2].= 1092+((3-0)*20+(2-0))*4 ..= 1092 + (62*4) . .= 1092+248 .= 1340 OR Assuming LBR=LBC=1 S=4 bytes Number of Rows(N)=15 Number of Columns(M)=20 LOC(Arr[I][J]).= B +((I-LBR)*M+(J-LBC))*S LOC(Arr[5][2]).= B +((5-1)*20+(2-1))*4 1500 .= B +(80+1)*4 B .= 1500-324 B .= 1176 LOC(Arr[3][2]).= 1176+((3-1)*20+(2-1))*4 . .= 1176 + (41*4) .= 1176+164 .= 1340 (1 Mark for writing correct formula/correct substituted values, for row major properly, for calculating Base Address) (1 Mark for calculating correct Base Address) (1 Mark for writing correct formula/correct substituted values, for row major properly, for calculating Address of Arr[3][2]) (1 Mark for calculating correct Address of Arr[3][2]) (c) class QUEUE { Customer *Rear,*Front; public: QUEUE( ) { Rear=NULL; Front=NULL;} void DELETE( ); ~QUEUE( ); };
  • 73.
    288 //Function definition DELETE() voidQUEUE::DELETE() { if(Front==NULL) // OR if(!Front) cout<<”n Queue Underflown”; else { Customer *Temp; Temp=Front; cout<<Front->Cno<<”:”<<Front->Cname <<”Deleted”<<endl;//To be ignored Front=Front->Link; delete Temp; if (Front==NULL) Rear=NULL; } } OR voidDELETE(Customer*&Front,Customer*&Rear) { if(!Front) cout<<”nQueueUnderflown”; else { Customer*Temp; Temp=Front; cout<<Front->Cno<<”:”<<Front->Cname <<”Deleted”<<endl;//Tobeignored Front=Front->Link; deleteTemp; if(Front==NULL) Rear=NULL; } } Note: If Front and Rear are declared as Global variables then parameters are not needed in the above function. (½ Mark for correct function header) (½ Mark for declaring Front and Rear as members OR passing them as arguments OR declaring them as global variables) (1 Mark for checking Underflow) (1 Mark for updating Front) (1 Mark for deleting node)
  • 74.
    289 (d) //Function definition voidDisplay(int A[][100],int N) { cout<<”Middle Row:”<<endl; for(int i=0;i<N;i=i+1) cout<<A[N/2][i]<<” “; cout<<endl; cout<<”Middle Column:”<<endl; for(i=0;i<N;i=i+1) for(int i=0;i<N;i=i+1) – For Borland C++ cout<<A[i][N/2]<<” “; } OR Anyothercorrectequivalentfunctiondefinition (½ Mark for correct function header) (½ Mark for correct loop) (½ Mark for checking/printing middle row elements) (½ Mark for checking/printing middle column elements) (e) Evaluationofthegivenpostfixexpressionisexplainedbelow Operator Scanned Stack Content 15 15 3 15, 3 2 15, 3, 2 + 15, 5 / 3 7 3, 7 + 10 2 10, 2 * 20 OR Anyothermethodofevaluatingthepostfixexpressionisshown. (½ Mark for each operation correctly evaluated) (Only 1 Mark is to be awarded if correct answer is given without steps)
  • 75.
    290 4. (a) Statement1: File.seekg(-1*sizeof(L),ios::cur); OR File.seekg(Rec*sizeof(L)); OR File.seekp(-1*sizeof(L),ios::cur); OR File.seekp(Rec*sizeof(L)); OR Any equivalent correct method of calculating size of the record in place of sizeofoperator. Statement 2: File.write((char *) &L,sizeof(L)); OR Any equivalent correct method of calculating size of the record in place of sizeofoperator. (½ Mark for each correct statement) (b) //Function to count the word in STORY.TXT file void thewordCount() { ifstream Fil(“STORY.TXT”); char String[20]; int C=0; while(!Fil.eof()) { Fil>>String; if(strcmpi(String,”the”)==0) C=C+1; } cout<<C<<endl; Fil.close(); } OR void thewordCount() { ifstream Fil(“STORY.TXT”); char String[20]; int C=0; while(!Fil.eof()) { Fil>>String; if(strcmp(String,”the”)==0 || strcmp(String,”The”)==0) C=C+1;
  • 76.
    291 } cout<<C<<endl; Fil.close(); } OR void thewordCount() { ifstream F(“STORY.TXT”); charStr[4]; int C=0; while(F.getline(Str,4,’ ‘)) { if(strcmp(Str,”the”)==0 || strcmp(Str,”The”)==0) C=C+1; } cout<<C<<endl; F.close(); } (½ Mark for opening file in the correct mode) (½ Mark for reading the content from the file and the loop) (½ Mark for correct comparison) (½ Mark for initialization and increment of the counter(variable)) Note: Ignore case sensitivity in the comparison with “the” or “The” (c) //Function to copy records from SPORTS.DAT to //ATHELETIC.DAT void SP2AT() { fstream IS,OA; Sports S; IS.open(“SPORTS.DAT”,ios::binary|ios::in); OA.open(“ATHLETIC.DAT”,ios::binary|ios::out); while(IS.read((char*) &S,sizeof(S))) { if(strcmp(S.Event,”Athletics”)==0) OA.write((char *)&S,sizeof(S)); } IS.close(); OA.close(); }
  • 77.
    292 OR void SP2AT() { fstream F1,F2; SportsS; F1.open(“SPORTS.DAT”,ios::binary|ios::in); F2.open(“ATHLETIC.DAT”,ios::binary|ios::out); while(F1.read((char*) &S,sizeof(S))) { if(!strcmp(S.Event,”Athletics”)) F2.write((char *)&S,sizeof(S)); } F1.close(); F2.close(); } OR void SP2AT() { fstream F1,F2; Sports S; F1.open(“SPORTS.DAT”,ios::binary|ios::in); F2.open(“ATHLETIC.DAT”,ios::binary|ios::out); while(!F1.eof()) { F1.read((char*) &S,sizeof(S)); if(!strcmp(S.Event,”Athletics”)) F2.write((char *)&S,sizeof(S)); } F1.close(); F2.close(); } (½ Mark for opening each file in the correct mode) (½ Mark for reading the content from the file) (½ Mark for the correct loop) (½ Mark for the correct comparison with “Athletics”) (½ Mark for writing the content to the second file) 5. (a) The Primary Key is an attribute/set of attributes that identifies a tuple/ row/ recorduniquely. Example: RollnumberinthetableSTUDENT OR
  • 78.
    293 AccessionNumberinthetableLIBRARY OR EmpNumberinthetableEMPLOYEE OR PanNumber in thetable INCOMETAX OR MemberNumberinthetableMEMBER OR AccNumber in the table BANK OR Anyothersuitableexample (1 Mark for correct definition/explanation of Primary Key) (1 Mark for suitable example) (b) (i) SELECT CnorN ame FROM CONSIGNOR WHERE City=’Mumbai’; (½ Mark for correct use of SELECT and FROM) (½ Mark for correct use of WHERE clause) (ii) SELECT B.CneeID, A.CnorName, A.CnorAddress, B.CneeName , B.CneeAddress FROM Consignor A, Consignee B WHERE A.CnorID=B.CnorID; OR SELECT Consigner.CneeID, CnorName, CnorAddress, CneeName, neeAddress FROM Consignor, Consignee WHERE Consignor.CnorID= Consignee.CnorID; (½ Mark for correct use of SELECT and FROM) (½ Mark for correct use of WHERE clause) (iii) SELECT * FROM CONSIGNEE ORDER BY CneeName; (½ Mark for correct use of SELECT and FROM) (½ Mark for correct use of ORDER BY clause) (iv) SELECT City,Count(CnorID) FROM CONSIGNOR Group By City; OR SELECT City,Count(*) FROM CONSIGNOR Group By City; (½ Mark for correct use of SELECT and FROM) (½ Mark for correct use of GROUP BY clause)
  • 79.
    294 (v) DISTINCT CneeCity Mumbai NewDelhi Kolkata (½ Mark for correct output) OR (½ Mark for mentioning Error as CITY not present in the table CONSIGNEE) (vi) A.CnorName B.CneeName R Singhal Rahul Kishore Amit Kumar S Mittal (½ Mark for correct output) OR (½ Mark for any 2 correct output out of (v),(vii)and (viii) even if part (vi) not attempted) (vii) CneeName CneeAddress P Dhingra 16/J,Moore Enclave B P Jain 13,Block D,A Vihar (½ Mark for correct output) (viii) CneeID CneeName MU05 Rahul Kishore KO19 A P Roy (½ Mark for correct output) Note: Column Headings for all Outputs may be ignored 6. (a) If X,Y∈B (X+Y)’=X’.Y’ (X.Y)’=X’+Y’ X Y X’ Y’ X+Y (X+Y)’ X’.Y’ 0 0 1 1 0 1 1 0 1 1 0 1 0 0 1 0 0 1 1 0 0 1 1 0 0 1 0 0
  • 80.
    295 X Y X’Y’ X.Y (X.Y)’ X’+Y’ 0 0 1 1 0 1 1 0 1 1 0 0 1 1 1 0 0 1 0 1 1 1 1 0 0 1 0 0 (½ Mark for each form of DeMorgan’s Theorem) (1 Mark for correct verification of any of the form of DeMorgan’s Theorem using Truth Table) (b) F(X, Y, Z) = π (1, 3, 6, 7) OR F=(X+Y+Z’)(X+Y’+Z’)(X’+Y’+Z)(X’+Y’+Z’) (½ Mark for each term of POS) (c) F=A.B’+C’.D (2 Marks for the correct expression) OR (½ Mark for each term of the expression) (d) A'.B' A'.B A.B A.B' C'D' 1 1 0 4 12 8 C'.D 1 1 5 13 9 C.D 1 1 3 7 15 11 C.D' 1 1 2 6 14 10 F(A,B,C,D)= A’.B’+B’.C’+A’.C’.D’ OR
  • 81.
    296 A + BA+B' A'+B' A'+B C+D 0 0 0 4 12 8 C+D' 0 0 0 1 5 13 9 C'+D' 0 0 1 3 7 15 11 C'+D 0 0 1 2 6 14 10 F(A,B,C,D)=(A’+C).(B’+D’).(B’+C’) (½ Mark for representing the terms in K-Map) (½ Mark for obtaining each reduced term i.e. 1 ½ Marks for reducing to the correct minimal form) 7. (a) Cyber law encompasses a wide variety of political and legal issues related totheInternetandothercommunicationstechnology,includingintellectual property,privacy,freedomofexpression,andjurisdiction. OR Restricting unauthorized access to user accounts. Promoting, coordinating andcontrollinge-business. (1 Mark for any correct definition/explanation) (b) (i) XML eXtensible MarkUp Language (ii) WWW WorldWideWeb (iii) WLL Wireless in Local Loop (iv) TCP/IP Transmission Control Protocol/Internet Protocol (½ Mark for each correct expansion) (c) (ii) Mbps Mega bits per second (½ Mark for correct identification) (½ Mark for correct expansion) (d) (i) · Head Office andTech Office: LAN · Head Office and Coimbatore Office: WAN (½ Mark for mention of each - LAN and WAN correctly) (ii) · Switch/Hub (1 Mark for the correct device) (iii) · Opticalfiber (1 Mark for the correct device)
  • 82.
    297 (iv) Optical Fiber/StarTopology Wireless OR OpticalFiber/BusTopology Wireless (½Mark for the correct layout) (½ Mark for the any equivalent correct technology) QUESTION PAPER CODE 91/1 EXPECTEDANSWERS/VALUE POINTS 1. (a) RunTimeError:Erroroccurringinaprogramduringitsexecution.Program executionhaltswhensuchanerrorisencountered. Example: int A,B,C; cin>>A>>B; C=A/B;//Runtime error if value of B is zero. SyntaxError:Erroroccurredduetowrongsyntaxoflanguagedetectedby thecompilerduringcompilation. Example: cout>>”A C++ Program”;
  • 83.
    298 (½ Mark foreach correct explanation of Runtime Error and Syntax Error) (½ Mark for each correct example of Runtime Error and Syntax Error) OR (Full 2 Marks for correct examples demonstrating the difference between Runtime Error and Syntax Error) OR (Only 1 Mark to be awarded if Explanation with out supporting examples) (b) stdio.h string.h (½ Marks for identifying each correct header file) Note: Ignore any other header files, if mentioned. (c) #include<iostream.h> const int Max = 10; //OR const int Max = 5; void main() { int Numbers[Max]= {20,50,10,30,40}; // OR int Numbers[]= {20,50,10,30,40}; int Loc; for(Loc=Max-1; Loc>=0; Loc—) cout<<Numbers[Loc]; } (½ Marks for each correction) OR (1 Mark for identifying at least three errors, without suggesting correction) (d) 4 # 6 # 10 # 12 @ 18 @ 30 @ 36 @ (1 Mark for each correct line of output) Note: · ½ Mark to be deducted for missing symbols in the output · ½ Mark to be deducted if endl is not considered in the output · As Borland C++ Compiler declares for loop variable locally, the program will result in syntax errors. So, any student specifying Variable I not declared OR mentioning that the program will not RUN due to incorrect syntax should be awarded full 2 Marks
  • 84.
    299 (e) 20,25,30, 20,25,30, Number=30 (1 Markfor each correct line of output) Note: · ½ Mark to be deducted for missing Commas (,) in the output · ½ Mark to be deducted if endl is not considered in the output (f) (ii) 94 (1 Mark for correct answer) (1 Mark for correct justification) 2. (a) Constructors: · Name of the constructor functions is same as the name of the class · No return type required for constructor function. · Constructorfunctionsarecalledautomaticallyatthetimeofcreationof the object · Constructors can be overloaded · Constructorfunctionsaredefinedinpublic. Destructors: · Name of the destructor is same as the name of the class preceded by ~ · No return type required for destructor function. · Destructor functions are called automatically when the scope of the object gets over · Destructor can not be overloaded · Destructorfunctionisdefinedinpublic. (1 Mark for correct explanation of Constructor) (1 Mark for correct explanation of Destructor) OR (1 Mark for any valid example of a Constructor) (1 Mark for any valid example of a Destructor) (b) (i) Function1:ConstructorORDefaultConstructor Function2:Destructor (½ Marks for each correct answer) (ii) Function 1 is executed or invoked automatically when an object of class Maths is created. Function 2 is invoked automatically when the scope of an object of class Maths comes to an end.
  • 85.
    300 OR Example: { Maths s1; //Constructoris invoked } //Destructor is invoked (½ Mark for each correct answer through explanation OR example) NOTE: If the error in declaration of the destructor is specified then marks for the destructor function should be allocated. (c) class Tour { char TCode[10]; //OR char *Tcode; int NoofAdults; int NoofKids; int Kilometres; float TotalFare; public: Tour() { strcpy(TCode,”NULL”); //OR TCode[0]=’0’OR strcpy(TCode,”0”) //OR TCode=NULL if TCode is declared as char pointer NoofAdults = 0; NoofKids = 0; Kilometres = 0; TotalFare = 0; } void AssignFare(); void EnterTour(); void ShowTour(); }; void Tour::AssignFare() { if(Kilometres>=1000) TotalFare = 500*NoofAdults+250*NoofKids; else if (Kilometres >= 500) TotalFare = 300*NoofAdults+150*NoofKids; else TotalFare = 200*NoofAdults+100*NoofKids; } void Tour::EnterTour() { gets(TCode); // or cin >> TCode; cin>>NoofAdults>>NoofKids>>Kilometres; AssignFare( );
  • 86.
    301 } void Tour::ShowTour() { cout<<TCode<<NoofAdults<<NoofKids<<Kilometres<<TotalFare<<endl; } (½ Markfor correct syntax for class header) (½ Mark for correct declaration of data members) (1 Mark for correct definition of constructor) (½ Mark for condition checking in AssigFare()) (½ Mark for calculation of correct TotalFare for each condition) (½ Mark for correct EnterTour() with proper invocation of AssignFare()) (½ Mark for displaying all data Members including TotalFare inside ShowTour()) (d) (i) MultipleInheritance (1 Mark for correct answer) (ii) None OR Alltheabovefunctionscanbecalled. (1 Mark for correct answer) (iii) Data Members: ICode, IName, Attendance, Grade, Remuneration Member Functions: IEntry( ), IDisplay( ), LEntry(), LDisplay( ), AssignRem( ), TEntry( ), TDisplay( ) (1 Mark for correct members) Note: · Constructor functions Trainer(), Learner() and Institute() to be ignored. · No marks to be awarded for partially correct answers (iv) IEntry( ), IDisplay( ) (1 Mark for correct answer) NOTE: · Constructor function Institute() to be ignored. · No marks to be awarded for partially correct answers
  • 87.
    302 3. (a) voidReplace( int Arr[], int Size) { for(int i =0; i<Size; i++) if(Arr[i]%2 != 0 ) Arr[i] *= 3; else Arr[i] *= 2; } OR void Replace( int Arr[], int Size) { for(int i =0; i<Size; i++) Arr[i]%2 ? Arr[i] *= 2 : Arr[i] *= 3; } (1 Mark for correct Function Header with proper Arguments) (1 Mark for correct loop) (1 Mark for checking Even / Odd values) (1 Mark for replacing with proper values) (b) AddressofArray[i][j]alongthecolumn= Base Address + W [( i – L1) + (j – L2) * M] where, W = size of each location in bytes = 8 L1 = Lower Bound of rows = 0 L2 = Lower Bound of columns = 0 M = Number of rows per column = 20 Address ofArray[4][5] = Base Address + 8 [ (4 – 0) +(5 – 0) * 20] 1000 = Base Address + 8 [104] BaseAddress = 1000 – 8 x 104 = 1000 – 832 = 168 Address ofArray[2][3] = 168 + 8 [ (2 – 0) + (3 – 0) x 20] = 168 + 8 x 62 = 168 + 496 = 664 OR
  • 88.
    303 AddressofArray[i][j]alongthecolumn= Base Address +W [( i – L1) + (j – L2) * M] where, W = size of each location in bytes = 8 L1 = Lower Bound of rows = 1 L2 = Lower Bound of columns = 1 M = Number of rows per column = 20 Address ofArray[4][5] = Base Address + 8 [ (4 – 1) +(5 –1) * 20] 1000 = Base Address + 8 [83] BaseAddress = 1000 – 8 x 83 = 1000 – 664 = 336 Address ofArray[2][3] = 336 + 8 [ (2 – 1) + (3 – 1) x 20] = 168 + 8 x 41 = 168 + 328 = 496 (1 Mark for writing correct formula/ correct substituted values for calculating Base Address) (1 Mark for calculating correct Base Address) (1 Mark for writing correct formula/ correct substituted values for calculating Address of Arr[3][2]) (1 Mark for calculating correct Address of Arr[3][2]) (c) class Stack { Book *Top; public: Book() //Constructor to initialize Top { Top = NULL; } void Push(); //Function to insert a node void Pop(); //Function to delete a node void Display(); //Function to display nodes of Stack ~Book(); //Destructor to delete all nodes }; void Stack::Pop( ) { if (Top != NULL) { Stack *Temp; Temp = Top;
  • 89.
    304 //Ignore the followingline while evaluation cout<<Top->Bno<<Top->Bname<<”deleted”<<endl; Top = Top ->Next; delete Temp; } else cout<<”Stack Empty”; } OR void Pop(Book *&Top) { if(Top!=NULL) { Book *Temp = Top; Top = Top ->Next; delete Temp; } else cout<<”Stack Empty”; } (½ Mark for declaring Top as member / passing Top to argument/ declaring it as a global variable) (½ Mark for correct function header) (1 Mark for checking Underflow) (1 Mark for reassigning Top) (1 Mark for deleting node) (d) void Diagonals(int Arr[][100], int Size) { int Row, Col; cout<<”Diagonal One: “; for (Row = 0; Row < Size; Row++) for (Col = 0; Col < Size; Col++) if (Row == Col) cout<<Arr[Row][Col]; cout<<”Diagonal Two: “; for (Row = 0; Row < Size; Row++) for (Col = 0; Col < Size; Col++) if (Row + Col == Size - 1) cout<<Arr[Row][Col]; }
  • 90.
    305 OR void Diagonals(int Arr[][100],int Size) { int Loc; cout<<”Diagonal One: “; for (Loc = 0; Loc < Size; Loc++) cout<<Arr[Loc][Loc]; cout<<”Diagonal Two: “; for (Loc = 0; Loc < Size; Loc++) cout<<Arr[Loc][Size-Loc-1]; } OR Anyothercorrectequivalentfunctiondefinition (½ Marks for correct function header) (½ Marks for correct loop(s)) (½ Marks for checking/printing right diagonal elements) (½ Marks for checking/printing left diagonal elements) (e) Operator Scanned Stack Content 25 25 8 25, 8 3 25, 8, 3 - 25, 5 / 5 6 5, 6 * 30 10 30, 10 + 40 OR Anyothermethodofcorrectlyevaluatingthepostfixexpressionisshown. (2 Marks is to be given for correct answer) OR (½ Mark for each operation correctly evaluated)
  • 91.
    306 4. (a) Statement1: File.seekp(Record* sizeof(P)); OR File.seekp(Record * sizeof(PracFile)); OR File.seekp(-sizeof(P), ios::cur); OR File.seekg(Record * sizeof(P)); OR File.seekg(Record * sizeof(PracFile)); OR File.seekg(-sizeof(P), ios::cur); OR Any equivalent correct method of calculating size of the record in place of sizeofoperator. Statement2: File.write((char*)&P, sizeof(P)); OR File.write((char*)&P, sizeof(PracFile)); OR Any equivalent correct method of calculating size of the record in place of sizeofoperator. (½ Mark for each correct statement) (b) void CountIs() { ifstream Fil; Fil.open(“DIALOGUE.TXT”); char Word[10]; int Count =0; while(!Fil.eof()) { Fil>>Word; if(strcmpi(Word,”is”)==0) Count++; } cout<<Count; Fil.close(); //Ignore }
  • 92.
    307 OR void CountIs() { ifstream Fil; Fil.open(“DIALOGUE.TXT”); charWord[10]; int Count = 0; while(Fil.getline(Word,10,’ ‘)) { if(strcmpi(Word,”is”)==0) Count++; } cout<<Count; Fil.close(); //ignore } OR void CountIs() { ifstream Fil; Fil.open(“DIALOGUE.TXT”); char ch, Word[10]; int Loc=0, Count = 0; while(Fil.get(ch)) { if(ch!=’ ‘) { Word[Loc] = ch; Loc++; } else { Word[Loc] = ‘0’; Loc = 0; if(strcmpi(Word,”is”)==0) Count++; } } cout<<Count; Fil.close(); //ignore } OR Anyothercorrectdefinition (½ Marks for opening DIALOGUE.TXT correctly) (½ Marks for reading each word from the file) (½ Marks for comparing with “is” / “Is” ) (½ Marks for printing the count of “is” / “Is”)
  • 93.
    308 (c) void CopyBasket() { GameG; ifstream fin; fin.open(“GAME.DAT”, ios::binary); ofstream fout; fout.open(“BASKET.DAT”, ios::binary); while(fin.read((char*)&G, sizeof(G))) { if(strcmp(G.GameName, “Basket Ball”)==0) fout.write((char*)&G,sizeof(G)); } fin.close(); //ignore fout.close(); //ignore } (½ Marks for opening GAME.DAT correctly) (½ Marks for opening BASKET.DAT correctly) (½ Marks for reading each record from GAME.DAT) (½ Marks for correct loop / checking end of file) (½ Marks for comparing GameName with “Basket Ball”) (½ Marks for writing the record to BASKET.DAT) 5. (a) Allcandidatekeys,whichare notthe primarykeyofthe table are calledthe alternatekeys. OR Primary Key:An attribute/ column used to identify each record in a table AlternateKey:Allsuchattributes/columns,whichcanactasaprimarykey but are not the primary key in a table. (2 Mark for any valid difference/relation between Primary Key and Alternate Key) OR (1 Mark for correct explanation of Primary Key) (1 Mark for correct explanation of Alternate Key) (b) (i) SELECT SenderName from Sender WHERE City = ‘Mumbai’; (ii) SELECT R.RecID, S.SenderName, S.SenderAddress, R.RecName, R.RecAddress FROM Sender S, Recipient R WHERE S.SenderID = R.SenderID; (iii) SELECT * FROM Recipient ORDER BY RecName; (iv) SELECT COUNT(*) FROM Recipient GROUP BY RecCity
  • 94.
    309 (v) SenderCity Mumbai New Delhi (vi)A.SenderName B.RecName R Jain H Singh S Jha P K Swamy (vii) RecName RecAddress S Mahajan 116, A Vihar S Tripathi 13, Bl D, Mayur Vihar (viii) RecID RecName ND08 S Mahajan ND48 STripathi (Part (i) to (iv) - 1 Mark for each correct query) (Part (v) to (viii) - ½ Marks for each correct output) Note: · Column headings for the output questions to be ignored. · Since in part (iv) the fieldname RecCity is not mentioned specifically, so full 1 mark to be given if any part of 5 (b) is answered correctly. 6. (a) If X,Y,Z are BooleanVariables then X . ( Y + Z ) = X . Y + X . Z OR X + Y . Z = (X + Y) . (X + Z) X Y Z Y+Z X.(Y+Z) X.Y X.Z X.Y+X.Z 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 1 0 1 0 0 0 0 0 1 1 1 0 0 0 0 1 0 0 0 0 0 0 0 1 0 1 1 1 0 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 VERIFIED (1 Mark for stating any one of the Distributive Law correctly) (1 Mark for verification using Truth Table)
  • 95.
    310 (b) F(X,Y,Z) =π(0,2,4,5) = X’.Y’.Z’ + X’.Y.Z’ + X.Y’.Z’ + X.Y’.Z (2 Marks for correct expression) OR (1 Mark, if a reduced non-canonical SOP expression is given) (c) F = W.X’ + Y’.Z (2 Marks for correct expression) OR ( ½ Mark each for W.X’ and Y’.Z) (d) U'V' U'V UV UV' W'Z' 1 1 0 4 12 8 W'Z 1 1 5 13 9 WZ 1 1 3 7 15 11 WZ' 1 1 2 6 14 10 F = U'.V'+W.V'+U'.W'.Z' (½ Mark for drawing correct K-Map ) (½ Mark for plotting 1’s correctly) (½ Mark for correct grouping) (½ Mark for correct Answer) 7. (a) Cyberlawencompassesawidevarietyofpoliticalandlegalissuesrelatedto the Internet and other communications technology, including intellectual property,privacy,freedomofexpression,andjurisdiction. OR CyberlawhelpspreventCyberCrime,Hacking,Datatheft,SoftwarePiracy and protects rights of Cyber Users. (1 Mark for any correct significance / explanation) W.X’ Y'.Z W.X’+Y'.Z
  • 96.
    311 (b) (i) CodeDivisionMultipleAccess (ii)WirelessLocalLoop (iii) FileTransferProtocol (iv) HyperTextMarkupLanguage (½ Marks for each correct expansion) (c) (i) Mbps (Mega Bits Per Second) (½ Marks for correct choice) (½ Marks for correct expansion) (d) (i) Back Office and Work Office – LAN Back Office and South Office –WAN (½ Mark for each correct answer) (ii) Switch/Hub (1 Mark for correct answer) (iii) OpticalFiber (1 Mark for correct answer) (iv) OR Anyothersuitablelayout/topologydrawnorexplained. Optical Fiber/StarTopology OR OpticalFiber/BusTopology OR Wireless (½ Mark for the correct layout) (½ Mark for the any equivalent correct technology)
  • 97.
    308 COMPUTER SCIENCE Time allowed: 3 hours Maximum Marks : 70 General Instructions: (i) All questions are compulsory. (ii) Programming Language: C+ + QUESTION PAPER CODE 91/1 1. (a) Whatisthedifferencebetween#defineandconst?Explainwithsuitable 2 example. (b) Name the header files that shall be needed for the following code 1 voidmain() { char String [ ] = “Peace”; cout<<setw (20) << String; } (c) Rewritethefollowingprogramafterremovingthesyntacticalerror(s)if any.Underlineeachcorrection. 2 #include<iostream.h> voidmain() { First = 10, Second = 20; Jumpto (First; Second); Jumpto (Second); } void Jumpto (int N1, int N2=20) { N1 = N1 + N2; cout<<N1>>N2; } (d) Findtheoutputofthefollowingprogram: 3 #include<iostream.h> #include<ctype.h>
  • 98.
    309 voidmain() { char Text [] = “Mind@Work!”; for (int I = 0; Text (I)! = ‘0’; 1++) { if(!isalpha(Text[I])) Text [I] = ‘*’; elseif(isupper(Text[I])) Text [I] = Text [I] + 1 ; else Text (I) = Text [I+ 1]; } cout<<Text; } (e) Findtheoutputofthefollowingprogram: 2 #include<iostream.h> voidmain() { int U = 10, V = 20; for (int I = 1; 1 < = 2; 1++) { cout<<“[1]=”<<U++<<“&”<<V–5<<endl; cout<<“[2]=”<<++V<<“&”< <U+ 2< <endl; } } (f) Inthefollowingprogram,findthecorrectpossibleoutput(s)fromtheoptions: 2 #include<stdlib.h> #include<iostream.h> voidmain() { randomize ( ) ; char City [ ] [10] = {“DEL”, “CHN”, “KOL”, “BOM”, “BNG”}; intFly; for (int I=0;I<3;I++) { Fly=random (2)+ 1; cout<<City[Fly]<<”:”;
  • 99.
    310 } } outputs: (i) DEL:CHN:KOL: (ii) CHN:KOL:CHN: (iii)KOL:BOM:BNG: (iv) KOL:CHN:KOL: 2. (a) Differentiate between public and private visibility modes in context of ObjectOrientedProgrammingusingasuitableexampleillustratingeach. 2 (b) Answer the questions (i) and (ii) after going through the following program 2 #include<iostream.h> #include<string.h> classBazar { charType[20]; char Product[20]; intQty; floatPrice; Bazar ( ) //Function 1 { strcpy(Type,“Electronic”); strcpy(Product,“Calculator”); Qty=10; Price=225; } public: void Disp ( ) / / Function 2 { cout<<Type<<“-”<<Product<<“:”<<Qty <<“@”<<Price<<endl; } }; voidmain() { BazarB; / /Statement 1
  • 100.
    311 B. Disp (); / / Statement 2 } (i) Will Statement 1 initialize all the data members for object B with the values given in the Function I? (Yes OR No). Justify your answer suggesting the correction(s) to be made in the above code. (ii) What shall be the possible output when the program gets executed? (Assuming, if required - the suggested correction(s) are made in the program) (c) DefineaclassGarmentsinC++withthefollowingdescriptions: 4 PrivateMembers: GCode oftypestring GType oftypestring GSize oftypeinteger GFabric oftypestring GPrice oftypefloat Afunction Assign ( ) which calculates and assigns the value of GPrice as follows For the value of GFabric as “COTTON”, GType GPrice(Rs) TROUSER 1300 SHIRT 1100 For GFabric other than “COTTON” the above mentioned GPrice gets reduced by 10%. PublicMembers: Aconstructor to assign initial values of GCode, GType and GFabric with the word “NOTALLOTTED” and GSize and GPrice with 0 A function Input ( ) to input the values of the data members GCode, GType, GSize and GFabric and invoke theAssign ( ) function. AfunctionDisplay()whichdisplaysthecontentofallthedatamembers for a Garment. (d) Answer the questions (i) to (iv) based on the following code: 4 classDolls { char DCode[5] ; protected: floatPrice;
  • 101.
    312 voidCalcPrice(float); public: Dolls(); void DInput () ; void DShow ( ) ; } ; classSoftDolls:publicDolls { char SDName[20] ; floatWeight; public: SoftDolls ( ) ; void SDInput ( ) ; void SDShow ( ) ; } ; classElectronicDolls:publicDolls { char EDName[20] ; charBatteryType[10]; intBatteries; public: ElectronicDolls(); void EDInput ( ) ; void EDShow ( ) ; } ; (i) WhichtypeofInheritanceisshownintheaboveexample? (ii) How many bytes will be required by an object of the class ElectronicDolls?. (iii) Writenameofallthedatamembersaccessiblefrommemberfunctions oftheclassSoftDolls (iv) Write name of all the member functions accessible by an object of the classElectronicDolls. 3. (a) Write a function in C++, which accepts an integer array and its size as parameters and rearranges the array in reverse. Example: if an array of nine elementsinitiallycontainstheelementsas 4, 2, 5, 1, 6, 7, 8, 12, 10
  • 102.
    313 thenthefunctionshouldrearrangethearrayas 10, 12, 8,7, 6, 1, 5, 2, 4 4 (b) An arrayArr[40][10] is stored in the memory along the column with each element occupying 4 bytes. Find out the address of the locationArr[3][6] if the locationArr[30][10] is stored at the address 9000 4 (c) Write a function in c++ to Insert an element into a dynamically allocated Queue where each node contains a name (of type string) as data. 4 AssumethefollowingdefinitionofTHENODEforthesame. structTHENODE { char Name[20] ; THENODE*Link; } ; (d) Write a function in C++ to print the product of each column of a two dimensionalintegerarraypassedastheargumentofthefunction. 2 Explain:ifthetwodimensionalarraycontains Then the output should appear as : Product of Column 1 = 24 Product of Column 2 = 30 Product of Column 3 = 240 (e) Evaluatethefollowingpostfixnotationofexpression(ShowstatusofStack after execution of each operation) : 2 4, 10, 5, +, *, 15, 3, /, – 4. (a) Observetheprogramsegmentgivenbelowcarefully,andanswerthequestion thatfollows: 1 classApplicant { longAId; //Applicant’sId
  • 103.
    314 char Name [20]; //Applicant’sName floatScore; //Applicant’sScore public: voidEnroll(); void Disp ( ) ; void MarksScore ( ); / /Function to change Score longR_AId(){retumAId;) } ; void ScoreUpdate (long Id) { fstreamFile; File.open(“APPLI.DAT”,ios::binary|ios::in|ios::out); ApplicantA; int Record = 0, Found = 0 ; while (!Found && File.read((char*) &C, sizeof(c))) { if(Id ==A.R_AId ( )) { cout<<”Enter new Score” ; A.MarksScore ( ); ______________ / / Statement 1 ______________ / /Statement 2 Found = 1; } Record ++; } if (Found ==1) cout<<”Record Updated”; File.close ( ) ; } WritetheStatement1toposition theFilePointeratthebeginningoftheRecordfor which the Applicant’s ld matches with the argument passed, and Statement2 to write the updated Record at that position. (b) Write a function in C++ to count the number of lowercase alphabets present in a text file “BOOK.TXT”. 2 (c) GivenabinaryfilePHONE.DAT,containingrecordsofthefollowing structuretype 3
  • 104.
    315 classPhonlist { char Name [20]; charAddress[30]; charAreaCode[5]; char PhoneNo[15] ; public: void Register () ; Void Show ( ) ; int CheckCode (charAC [ ]) { return strcmp (AreaCode,AC) ; } } ; Write a functionTRANSFER ( ) in C++, that would copy all those records which are havingAreaCode as “DEL” from PHONE.DATto PHONBACK.DAT. 5. (a) DifferentiatebetweenCandidateKeyandPrimaryKey incontextofRDBMS 2 (b) Consider the following tables Product and Client.Write SQLcommands for the statement (i) to (iv) and give outputs for SQL queries (v) to (viii) 6 TABLE: PRODUCT TABLE:CLIENT
  • 105.
    316 (i) TodisplaythedetailsofthoseClientswhoseCityisDelhi (ii) Todisplay the details of Products whose Price is in the range of 50 to 100 (Both values included) (iii) To display the ClientName, City from table Client, and ProductName andPricefromtableProduct,withtheircorrespondingmatchingP_ID (iv) To increase the Price of all Products by 10 (v) SELECTDISTINCTAddress FROM Client; (vi) SELECTManufacturer,MAX(Price),Min(Price),Count(*) FROM Product GROUP BY Manufacturer; (vii) SELECTClientName,ManufacturerName FROM Product, Client WHEREClient.Prod_ld=Product.P_ld; (viii) SELECT ProductName, Price *4 FROM Product 6. (a) State and verify De Morgan’s law in BooleanAlgebra 2 (b) DrawaLogicalCircuitDiagramforthefollowingBooleanExpression X’. (Y’ + Z) 1 (c) ConvertthefollowingBooleanexpressionintoitsequivalentCanonical Sum of Product Form(SOP) (X’+ Y + Z’) . (X’+ Y + Z) . (X’+ Y’+ Z) . (X’+ Y’+ Z’) 2 (d) Reduce the following Boolean expression using K - Map F (A,B,C,D) = ∑(0,2,3,4,6,7,8,10,12) 3 7. (a) What is a Hub? 1 (b) ExpandthefollowingtermswithrespecttoNetworking: 2 (i) MODEM (ii) WLL (iii) FTP (iv) TCP/IP (c) HowisCoaxialcabledifferentfromOpticalFibre? 1 (d) “Bias Methodologies” is planning to expand their network in India, starting withthreecitiesinIndiatobuildinfrastructureforresearchanddevelopment
  • 106.
    317 of their chemicalproducts. The company has planned to setup their main officeinPondicherry-atthreedifferentlocationsandhavenamedtheiroffices as “Back Office”, “Research Lab” and “Development Unit”. The company has one more Research office namely “Corporate Office” in “Mumbai”.A roughlayoutofthesameisasfollows: 4 Approximatedistancesbetweentheseofficesisasfollows: Incontinuationoftheabove,thecompanyexpertshaveplannedtoinstallthe followingnumberofcomputersineachoftheiroffices: (i) Suggestthekindofnetworkrequired(outofLAN,MAN,WAN) forconnectingeachofthefollowingofficeunits: Research Lab and Back Office Research Lab and Development Unit (ii) Whichoneofthefollowingdevicewillyousuggestforconnecting allthecomputerswithineachoftheirofficeunits?
  • 107.
    318 Switch/Hub Modem Telephone (iii) Whichofthefollowingcommunicationmedium,youwillsuggest to beprocured by the company for connecting their local office units in Pondicherry for very effective (High Speed) communication? Telephone Cable Optical Fiber Ethernet Cable (iv) Suggestacable/wiringlayoutforconnectingthecompany’slocal office units located in Pondicherry.Also, suggest an effective method/technology for connecting the company’s office unit locatedinMumbai. QUESTION PAPER CODE 91 1. (a) What is the purpose of using a typedef command in C++. Explain with suitableexample. 2 (b) Name the header files that shall be needed for the following code: 1 voidmain() { char Word [ ] =”Exam”; cout<<setw(20)<<Word; } (c) Rewritethefollowingprogramafterremovingthesyntaxerror(s),ifany. Underlineeachcorrection. 2 #include<iostream.h> voidmain() { One = 10, Two = 20; Callme(One;Two); Callme(Two); } voidCallme(intArg1,intArg2=20) {
  • 108.
    319 Arg1 =Arg1 +Arg2; cout<<Arg1>>Arg2; } (d)Findtheoutputofthefollowingprogram: 3 #include<iostream.h> #include<ctype.h> voidmain() { charMystring[]=“What@OUTPUT!”; for(int I = 0; Mystring [I] ! =’ 0'; I++) { if(!isalpha(Mystring[I])) Mystring [I] = ‘*’; elseif(isupper(Mystring[I])) Mystring[I]=Mystring[I]+1; else Mystring[I]=Mystring[I+1]; } cout<<Mystring; } (e) Findtheoutputofthefollowingprogram: 2 #include<iostream.h> voidmain() { intA=5, B=10; for (int I = 1; I<=2; 1++) { cout<<“Linel=”<<A++<<“&”<<B–2<<endl; cout<<“Line2=”<<++B<<“&”<<A+3<<endl; } } (f) Inthefollowingprogram,findthecorrectpossibleoutput(s)fromtheoptions: 2 #include<stdlib.h> #include<iostream.h> voidmain() {
  • 109.
    320 randomize(); charArea [] [10]= {‘‘NORTH”, ‘‘SOUTH”, “EAST”, “WEST”} ; intToGo; for (int I=0; 1<3; 1++) { ToGo = random(2) +1; cout<<Area [ToGo]<<” : “; } } outputs: (i) SOUTH:EAST:SOUTH: (ii) NORTH:SOUTH:EAST: (iii) SOUTH:EAST:WEST: (iv) SOUTH:EAST:EAST: 2. (a) Differentiatebetweenprivateand protectedvisibilitymodesincontextof ObjectOrientedProgramminggivingasuitableexampleillustratingeach. 2 (b) Answerthequestions(i)and(ii)aftergoingthroughthefollowingprogram: 2 #include<iostream.h> #include<string.h> classRetail { char Category [20]; char Item [20]; intQty; floatPrice; Retail() //Function1 { strcpy (Category, “Cereal”); strcpy(Item,“Rice”); Qty = 100; Price = 25; public: void Show ( ) //Function2 { cout<<Category<<“–”<<Item<<“:”<<Qty
  • 110.
    321 <<“@”<<Price<<endl; } }; voidmain() { RetailR; //Function1 R. Show( ) ;. //Function2 } (i) Will Statement 1 initialize all the data members for object R with the values given in the Function 1 ? (Yes OR No). Justify your answer suggesting the correction(s) to be made in the above code. (ii) What shall be the possible output when the program gets executed? (Assuming, if required - the suggested correction(s) are made in the program) (c) DefineaclassClothinginC++withthefollowingdescriptions: 4 PrivateMembers: Code oftypestring Type oftypestring Size oftypeinteger Material oftypestring Price oftypefloat AfunctionCalc_Price()whichcalculatesandassignsthevalueofPrice asfollows: For the value of Material as “COTTON” : Type Price (Rs.) TROUSER 1500 SHIRT 1200 ForMaterialotherthan“COTTON”theabovementionedPrice gets reduced by 25%. PublicMembers: Aconstructor to assign initial values of Code, Type and Material with the word “NOTASSIGNED” and Size and Price with 0. Afunction Enter( ) to input the values of the data members Code,Type, Size and Material and invoke the CalcPrice( ) function. A function Show( ) which displays the content of all the data members for a Clothing.
  • 111.
    322 (d) Answer thequestions (i) to (iv) based on the following code: 4 classToys { char TCode [5] ; protected: floatPrice; voidAssign(float); public: Toys( ) ; void TEntry ( ) ; , voidTDisplay(); } ; classSoftTOYS:publicToys { char STName [ 20] ; floatweight; public: SoftToys( ) ; void STEntry ( ) ; voidSTDisplay(); } ; classElectronicToys:publicToys { char ETName[20]; intNo_of_Batteries; public: ElectronicToys(); void ETEntry ( ) ; voidETDisplay(); } ; (i) WhichtypeofInheritanceisshownintheaboveexample? (ii) How many bytes will be required by an object of the class SoftToys ? (iii) Writenameofallthedatamembersaccessiblefrommemberfunctions of the class SoftToys. (iv) Writenameofallthememberfunctions,whichareaccessiblefroman object of the class ElectronicToys.
  • 112.
    323 3. (a) WriteafunctioninC++,whichacceptsanintegerarrayandits size as arguments andswapstheelementsofeveryevenlocationwithitsfollowingoddlocation. 4 Example:ifanarrayofnineelementsinitiallycontainstheelementsas 2, 4, 1, 6, 5, 7, 9, 23, 10 thenthefunctionshouldrearrangethearrayas 4, 2, 6, 1, 7, 5, 23, 9, 10 (b) An arrayArr[50] [100] is stored in the memory along the row with each element occupying2bytes.FindouttheaddressofthelocationArr[20][50],ifthelocation Arr[10] [25] is stored at the address 10000. 4 (c) WriteafunctioninC++toDeleteanelementfromadynamicallyallocatedQueue where each node contains a real number as data. AssumethefollowingdefinitionofMYNODEforthesame. struct MYNODE 4 { floatNUM; MYNODE*Link; } ; (d) Write a function in C++ to print the product of each row of a two dimensional integer array passed as the argument of the function. 2 Example:ifthetwodimensionalarraycontains Then the output should appear as : Product of Row 1= 8000 Product of Row 2= 6000 Product of Row 3= 3600 Product of Row 4= 2400 (e) Evaluatethefollowingpostfixnotationofexpression(ShowstatusofStack after execution of each operation) : 2 5, 20, 15, –, *, 25, 2, *, +
  • 113.
    324 4. (a) Observetheprogramsegmentgivenbelowcarefully,andanswerthequestion thatfollows: classCandidate { longCld; / /Candidate’ s Id char CName [20]; / /Candidate’s Name floatMarks; / /Candidate’s Marks public: void Enter ( ) ; void Display ( ) ; void MarksChange( ) ; / /Function to change marks lond R_Cid( ) {return Cld; ) }; void MarksUpdate (long Id) { fstreamFile; File.open(“CANDIDAT.DAT”,ios::binary|ios::in|ios::out); Candidate C; int Record=0, Found=0; while (! Found && File.read ( (char*) &C, sizeof (C) ) ) { if (Id= =C. R_Cld ( ) ) { cout<<”EnternewMarks”; C.MarksChange( ) ; _______________ / /Statement 1 _______________ / /Statement 2 Found = 1; } Record++; } if (Found = 1) cout<<”Record Updated”; File.close ( ) ; } WritetheStatement1topositiontheFilePointeratthebeginningoftheRecord forwhichtheCandidate’sIdmatcheswiththeargumentpassed,andStatement 2 to write the updated Record at that position. 1
  • 114.
    325 (b) Write afunction in C++ to count the number of uppercase alphabets present inatextfile“ARTICLE.TXT”. 2 (c) Given a binary file TELEPHON.DAT, containing records of the following classDirectory: classDirectory { char Name[20] ; charAddress [30] ; charAreaCode[5]; char Phone_No[15]; public: void Register ( ) ; void Show ( ) ; int CheckCode(charAC[ ]) { return strcmp (AreaCode,AC); } }; Write a function COPYABC( ) in C++, that would copy only those records havingAreaCode as “123” fromTELEPHON.DATtoTELEBACK.DAT. 3 5. (a) Differentiate between Candidate Key and Alternate Key in context of RDBMS. 2 (b) Consider the following tables Item and Customer.WriteSQLcommands for the statements (i) to (iv) and give outputs for SQL queries (v) to (viii). 6 TABLE : ITEM
  • 115.
    326 TABLE : CUSTOMER (i)To display the details of those Customers whose City is Delhi (ii) To display the details of Items whose Price is in the range of 35000 to 55000(Bothvaluesincluded) (iii) TodisplaytheCustomerName,CityfromtableCustomerandItemName andPricefromtableItem,withtheircorrespondingmatchingI-Id (iv) To increase the Price of all Items by 1000 in the table Item (v) SELECT DISTINCT City FROM Customer; (vi) SELECT ItemName, MAX(Price), Count(*) FROM Item GROUP BY ItemName; (vii) SELECT CustomerName, Manufacturer FROM Item, Customer WHEREItem.Item_Id=Customer.Item.I_Id (viii) SELECT ItemName, Price * 100 FROM Item WHERE Manufacturer =’ABC’; . 6. (a) StateanyverifyAbsorptionlawinBooleanAlgebra. 2 (b) DrawaLogicalCircuitDiagramforthefollowingBooleanExpression: 1 A . (B + C’) (c) ConvertthefollowingBooleanexpressionintoitsequivalentCanonical Product of Sum Form (POS) : 2 A. B’ . C + A’. B . C + A’. B . C’ (d) ReducethefollowingBooleanexpressionusingK-Map: 3 F (A, B, C, D) = ∑ (0, l, 2, 4, 5, 8, 9, 10, 11) 7. (a) What is a Modem? 1 (b) ExpandthefollowingtermswithrespecttoNetworking: 2 (i) PPP
  • 116.
    327 (ii) GSM (iii) XML (iv)HTTP (c) How is a Hacker different from a Cracker? 1 (d) “China Middleton Fashion’” is planning to expand their network in India, starting with two cities in India to provide infrastructure for distribution of their product. The company has planned to set up their main office units in Chennaiatthreedifferentlocationsandhavenamedtheirofficesas“Production Unit”,“FinanceUnit”and“MediaUnit”.Thecompanyhasitscorporateunit inDelhi. Aroughlayoutofthesameisasfollows: ApproximatedistancesbetweentheseUnitsisasfollows:
  • 117.
    328 Incontinuationoftheabove,thecompanyexpertshaveplannedtoinstallthe followingnumberofcomputersineachoftheirofficeunits: (i) Suggest thekind of network required (out of LAN, MAN,WAN) for connectingeachofthefollowingofficeunits: ProductionUnitandMediaUnit ProductionUnitandFinanceUnit (ii) Whichoneofthefollowingdeviceswillyousuggestforconnectingall thecomputerswithineachoftheirofficeunits? Switch/Hub Modem Telephone (iii) Which of the following communication media, will you suggest to be procuredbythecompanyforconnectingtheirlocalofficeunitsinChennai forveryeffective(HighSpeed)communication? TelephoneCable OpticalFiber EthernetCable (iv) Suggestacable/wiringlayoutforconnectingthecompany’slocaloffice unitslocatedinChennai.Also,suggestaneffectivemethod/technology forconnectingthecompany’sofficeunitlocatedinDelhi. 4
  • 118.
    329 Marking Scheme —Computer Science General Instructions : 1. TheanswersgiveninthemarkingschemeareSUGGESTIVE,Examinersarerequestedto awardmarksforallalternativecorrectSolutions/Answersconveyingthesimilarmeaning 2. All programming questions have to be answered with respect to. C++ Language only. 3. InC++,ignorecasesensitivityforidentifiers(Variable/Functions/Structures/ClassNames). 4. In SQL related questions - both ways of text/character entries should be acceptable for Example: “AMAR” and ‘amar’both are correct. . 5. InSQLrelatedquestions-semicolonshouldbeignoredforterminatingtheSQLstatements 6. InSQLrelatedquestions,ignorecasesensitivity. QUESTION PAPER CODE 91/1 EXPECTEDANSWERS 1. (a) Whatisthedifferencebetween#defineandconst?Explainwithsuitable example. 2 Ans: #define: It is a preprocessor directive in C++ for creating a Macro. Example: #define sqr(i) i*i const: It is an Access Modifier in C++ that assigns a constant (non modifiable) valuetoavariable.Anyattemptinmodifyingthevalueassignedtosuchavariableis reported as an error by the compiler. Example: const float Pi = 3.14; (½ Mark for each correct explanation of #define and const) (½ Mark for each correct example of #define and const) OR (Full 2 Marks for correct examples demonstrating the difference between #define and const) OR (Only 1 Mark to be awarded if Explanation without supporting examples)
  • 119.
    330 (b) Name theheader files that shall be needed for the following code 1 void main ( ) { char String [ ] = “Peace”; cout<<setw(20)<<String; } Ans: iostream.h iomanip.h (½ Mark for identifying each correct header file) Note: Ignore any other header files, if mentioned. (c) Rewritethefollowingprogramafterremovingthesyntacticalerror(s)ifany. Underlineeachcorrection. 2 #include <iostream.h> void main( ) { First = 10 , Second = 20; Jump to (First; Second) ; Jumpto (Second); } void Jumpto(int N1, int N2=20) { N1 = N1 + N2; cout<<N1>>N2; } Ans: #include <iostream.h> void Jumpto(int N1, int N2=20); // Error 1 void main( ) { int First = 10, Second = 20; // Error 2 Jumpto(First, Second); // Error 3 Jumpto(Second) ; } void Jumpto(int N1, int N2=20) { N1 = N1 + N2; cout<<N1<<N2; // Error 4 } OR #include <iostream.h> void Jumpto(int N1, int N2=20) // Error 1
  • 120.
    331 { N1 = N1+ N2; cout<<N1<< N2; // Error 2 } void main ( ) { int First = 10, Second = 20; // Error 3 Jumpto(First, Second); // Error 4 Jumpto (Second) ; } (½ Mark for each correction) OR (1 Mark for identifying at least three errors, without suggesting correction) (d) Findtheoutputofthefollowingprogram: 3 #include<iostream.h> #include<ctype.h> void main ( ) { char Text [ ] = “Mind@Work!”; for (int I = 0; Text [I] !=’0’; I++) { if (!isalpha (Text [I]) Text [I] = ‘*’; else if (isupper(Text [I])) Text [I] = Text [I]+1; else Text (I) = Text [I+l]; } cout<<Text; } Ans: Nnd@*Xrk!* (½ Mark for N in the 1st position) (½ Mark for nd in the 2nd and 3rd position) (½ Mark for @ in the 4th position) (½ Mark for * in the 5th position) (½ Mark for Xrk!) (½ Mark for * at the end)
  • 121.
    332 OR (Fu1l 3 MarksIf error is mentioned in the code for Text (I) after last else) (e) Findtheoutputofthefollowingprogram: 2 #include<iostream.h> void main() { int U=10, V=20; for (int I = 1; I<=2; I++) { cout<<“[1]=”<<U++<<“&”<<V–5<<endl; cout<<“[2]=”<<++V<<“&”<<U+2<<endl; } } Ans: [1]=10&15 [2]=21&13 [1]=11 &16 [2]=22&14 (½ Mark for each correct line of output) Note: ½ Mark to be deducted for missing “=” and “&” symbols in the output. ½ Mark to be deducted if endl is not considered in the output (f) Inthefollowingprogram,findthecorrectpossibleoutput(s)fromtheoptions: 2 #include<stdlib.h> #include<iostream.h> void main( ) { randomize( ); char City [ ] [10] = {“DEL”, “CHN”, “KOL”, “BOM”, “BNG”}; int Fly; for (int I=0;1<3;1++) { Fly = random(2)+1; cout<<City [Fly]<<”:”; } } outputs: (i) DEL:CHN:KOL: (ii) CHN:KOL:CHN: (iii) KOL:BOM:BNG: (iv) KOL:CHN:KOL:
  • 122.
    333 Ans: (ii) &(iv) (2 Marks for mentioning both correct options) OR (1 Mark for mentioning anyone correct option) 2. (a) DifferentiatebetweenpublicandprivatevisibilitymodesincontextofObject OrientedProgrammingusingasuitableexampleillustratingeach. 2 Ans: public visibility mode: Members of a class declared under this visibility are accessible inside the class(inmemberfunctionsoftheclass)aswellasbytheObjectsofthatclass (in any non member function of the program, prototyped / defined after the classdeclaration). private visibility mode: Membersofaclassdeclaredunderthisvisibilityareaccessibleonlyinsidethe class (in member functions of the class). They can not be accessed outside the class. class Example { int Priv; public: void Assign ( ) { Priv =10; //private member accessible only inside class } } ; void main ( ) { Example E; E.Assign( ); //public member accessible by Object } (2 Marks for differentiating public and private correctly using suitable example) OR (1 Mark for correct explanation of private visibility) (1 Mark for correct explanation of public visibility) OR (1 Mark for any valid example of a private member of a class) (1 Mark for any valid example of a public member of a class)
  • 123.
    334 (b) Answerthequestions(i)and(ii)aftergoingthroughthefollowingprogram 2 #include<iostream.h> #include<string.h> classBazar { char Type [20]; char Product [20]; int Qty; float Price; Bazar ( ) { //Function 1 strcpy (Type,”Electronic”); strcpy (Product,”Calculator”); Qty = 10; Price = 225; } public: void Disp ( ) { //Function 2 cout<<Type<<“-”<<Product<<“:”<<Qty <<“@”<<Price<<endl; } }; void main ( ) { Bazar B; //Statement 1 B. Disp ( ) ; //Statement 2 } (i) Will Statement 1 initialize all the data members for object B with the values given in the Function 1? (Yes OR No). Justify your answer suggesting the correction(s) to be made in the above code. Ans: No, since the constructor Bazar has been defined in private section Suggested Correction: Constructor Bazar() to be ,defined in public (½ Mark for identifying NO) (½ Mark for justification and correction) (ii) What shall be the possible output when the program gets executed? (Assuming, if required - the suggested correction(s) are made in the program)
  • 124.
    335 Ans: Iftheconstructorisdefinedasapublicmember,thefollowingoutputshallbe generated: Electronic-Calculator:10@225 (1 Markfor correct answer) OR (½ Mark each for the String and Numeric values) (c) Define,aclassGarmentsinC++withthefollowingdescriptions: 4 PrivateMembers: GCode oftypestring GType oftypestring GSize oftypeinteger GFabric oftypestring GPrice oftypefloat Afunction Assign ( ) which calculates and assigns the value of GPrice as follows For the value ofGFabric as “COTTON”, GType GPrice(Rs) TROUSER 1300 SHIRT 1100 For GFabric other than “COTTON” the above mentioned GPrice gets reduced by 10%. PublicMembers: Aconstructor to assign initial values of GCode, GType and GFabric with the word “NOTALLOTTED” and GSize and GPrice with 0 A function Input ( ) to input the values of the data members GCode, GType, GSize and GFabricl and invoke theAssign ( ) function. AfunctionDisplay()whichdisplaysthecontentofallthedatamembers for a Garment. Ans: class Garments { char GCode[10]; char GType[10]; int GSize; char GFabric[10] ; float GPrice;
  • 125.
    336 void Assign( ); public: Garments( ) { strcpy(GCode,”NOT ALLOTTED”) ; strcpy(GType,”NOT ALLOTTED”) ; strcpy (GFabric, “NOT ALLOTTED”) ; GSize=0; GPrice=0; } void Input( ) ; void Display( ) ; } ; void Garments::Assign( ) { if (strcmp(GFabric,“COTTON”)==0) //if (!strcmp(GFabric, “COTTON”)) { if (strcmp(GType,“TROUSER”) ==0) GPrice=1300; else if (strcmp(GType,“SHIRT”)==0) GPrice=1100; } else { if (strcmp(GType,”TROUSER”) = =0) GPrice=1300*0.9; // 10% reduction else if (strcmp(GType,“SHIRT”)= =0) GPrice=1100*0.9; // 10% reduction } } void Garments::Input( ) { gets(GCode) ; // or cin >> GCode; gets(GType) ; // or cin >> GType; cin>>GSize; gets(GFabric) ;// or cin >> GFabric; Assign( ) ; } void Garments::Display( ) { cout<<GCode<<GType<<GSize<<GFabric<<GPrice<<endl; }
  • 126.
    337 (½ Mark forcorrect syntax for class header) (½ Mark for correct declaration of data members) (½ Mark for correct definition of constructor) (1 Mark for correct definition of Assign( )) (1 Mark for correct definition of Input( ) with proper invocation of Assign( ) function) (½ Mark for correct definition of Display( )) NOTE: Deduct % Mark ifAssign( ) is not invoked properly inside Input( ) function (d) Answer the questions (i) to (iv) based on the following code: 4 class Dolls { char DCode[5] ; protected: float Price; void CalcPrice(float); public: Dolls ( ); void DInput ( ) ; void DShow ( ) ; } ; class SoftDolls : public Dolls { char SDName[20] ; float Weight; public: SoftDolls ( ) ; void SDInput ( ) ; void SDShow ( ) ; } ; class ElectronicDolls: public Dolls { char EDName[20] ; char BatteryType[10]; int Batteries; public: ElectronicDolls ( ) ; void EDInput ( ) ; void EDShow ( ) ; } ;
  • 127.
    338 (i) WhichtypeofInheritanceisshownintheaboveexample? Ans: HierarchicalInheritance OR SingleLevelInheritance (1mark for mentioning any of the above mentioned type of Inheritance) (ii) How many bytes will be required by an object of the class ElectronicDolls? Ans: 41 bytes (1 Mark for correct answer) (iii) Writenameofallthedatamembersaccessiblefrommemberfunctionsof theclassSoftDolls Ans: SDName,Weight, Price (1 Mark for correct answer) Note: No marks to be awarded for partially correct answer (iv) Write name of all the member functions accessible by an object of the class ElectronicDolls. Ans: EDInput( ), EDShow( ), DInput( ), DShow( ) (1 Mark for Correct answer) Note: Constructor functions ElectronicDolls( ) & Dolls( ) to be Ignored. No marks to be awarded for partially correct answers 3. (a) Write a function in C++, which accepts an integer array and its size as parameters and rearranges the array in reverse. Example: if an array of nine elementsinitiallycontainstheelementsas 4, 2, 5, 1, 6, 7, 8, 12, 10 thenthefunctionshouldrearrangethearrayas 10, 12, 8, 7, 6, 1, 5, 2, 4 4 Ans: void Rearrange( int Arr [], int Size) { for (int i = 0; i<Size/2; i++) { int T = Arr[i]; Arr[i] = Arr[Size-1-i]; Arr[Size-1-i]=T; } } OR Any other correct equivalent function definition (1 Mark for correct Function Header with proper Arguments)
  • 128.
    339 (1 Mark forcorrect loop) (2 Marks for swapping the values correctly) Note: Deduct ½ Mark if loop runs till Size instead of Size/2 for swapping Deduct ½ Mark if reversed values are stored in another array (b) An arrayArr[40][10] is stored in the memory along the column with each element occupying 4 bytes. Find out the address of the locationArr[3][6] if the locationArr[30][10] is stored at the address 9000 4 Ans: AddressofArray[i][j]alongthecolumn= Base Address + W [( i - L1) + (j - L2) * M] where, W = size of each location in bytes = 4 L1 = Lower Bound of rows = 0 L2 = Lower Bound of columns = 0 M = Number of rows per column = 40 Address of Array[30][10] = Base Address + 4 * (30 + 10 * 40) 9000 = Base Address + 4 * 430 BaseAddress = 9000 - 4 x 430 = 9000 -1720 = 7280 Address ofArray[3][6] = 7280 + 4 * (3 + 6 * 40) = 7280 + 4 * 243 = 7280 + 972 = 8252 OR AddressofArray[i][j]alongthecolumn= Base Address + W (( i - L1) + (j - L2) * M) where, W = size of each location in bytes = 4 L1 = Lower Bound of rows = 1 L2 = Lower Bound of columns = 1 M = Number of rows per column = 40 Address of Array[30][10] = Base Address + 4 * ((30 -1) +(10 -1) * 40) 9000 = Base Address + 4 * (29+9*40)
  • 129.
    340 9000 = BaseAddress + 4 * (29+360) 9000 = Base Address + 4 * (389) BaseAddress = 9000 - 4 * 389 = 9000 -1556 = 7444 Address ofArray[3][6] = 7444 + 4 * ((3 -1) + (6 -1) * 40) = 7444 + 4 * (2+5 * 40) = 7444 + 4 * (2+200), = 7444 + 4 * 202 = 7444 + 808 = 8252 OR AddressofArray[i][j]alongthecolumn= Address ofArray[x][y] + W [( i-x) + (j - y) * M] where, W = size of each location in bytes = 4 M = Number of rows per column = 40 i , j = Index value of the unknown element x , y = Index value of the known element Address ofArray[3][6] = Address of Array[30][10]+ 4 [(3 - 30) +(6 -10) * 40] = 9000 + 4 [-27 -160] = 9000 - 4 x 187 = 9000 -748 = 8252 (2 Marks for writing correct formula (for column major), substituting formula with correct values and/or calculate Base Address) (2 Marks for writing correct formula/correct substituted values, for column major properly, for calculating Address of Arr[20][50]) (c) Write a function in c++ to Insert an element into a dynamically allocated Queue where each node contains a name (of type string) as data. 4 AssumethefollowingdefinitionofTHENODEforthesame. structTHENODE { char Name[20]; THENODE *Link; };
  • 130.
    341 Ans: void Qinsert (THENODE*&Front, THENODE *&Rear) { THENODE *Temp = new THENODE; gets(Temp->Name); //or cin>>Temp->Name; Temp->Link = NULL; if (Rear = = NULL) { Front = Temp; Rear = Temp; } else { Rear – > Link = Temp; Rear = Temp; } } OR class Queue { THENODE *Front, *Rear; public: QUEUE( ) //Constructor to initialize Top { Front = NULL; Rear = NULL; } void Qinsert( );//Function to insert a node void QDelete( );//Function to delete a node void QDisplay( );//Function to display nodes of Stack ~Queue( ); //Destructor to delete all nodes } ; void Queue: : Qinsert ( ) { THENODE *Temp; Temp = new THENODE; gets (Temp–>Name) ;//Or cin>>Temp–>Name; Temp–>Link = NULL; if (Rear = = NULL) { Front = Temp;
  • 131.
    342 Rear = Temp; } else { Rear–>Link= Temp; Rear = Temp; } } (½ Mark for declaration of a temporary pointer to THENODE) (½Markfornewallocationfortemporarypointer) (½ Mark for assigning OR entering the value of NAME on temporary pointer) (½ Mark for assigning NULLto Temp->Link) (½ Mark for checking Empty QUEUE) (½ Mark for assigning Front and Rear in case of Empty QUEUE) (½ Mark for assigning Rear ->Link with Temporary pointer when QUEUEisnotEmpty) (½MarkforreassigningRearwithTempwhentheQUEUEisnotEmpty) (d) Write a function in C++ to print the product of each column of a two dimensionalintegerarraypassedastheargumentofthefunction. 2 Explain:ifthetwodimensionalarraycontains Then the output should appear as : Product of Column 1 = 24 Product of Column 2 = 30 Product of Column 3 = 240 Ans: void ProdCol(int Arr[][100], int Row, int Col) { int i, j, Prod; for (j = 0; j < Col; j++) { Prod=1; for (i = 0; i < Row; i++)
  • 132.
    343 Prod * =Arr[i][j]; cout<<“Product of Column”<<j<< “=” <<Prod<<endl; } } OR Any other correct equivalent function definition (½ Mark for correct function header) (½ Mark for correct loop(s)) (½ Mark for finding product of elements for each column correctly) (½ Mark for printing the product in correct format) (e) Evaluatethefollowingpostfixnotationofexpression(ShowstatusofStack after execution of each operation) : 2 4, 10, 5, +, *, 15, 3, /, – Ans: Operator Scanned Stack Content 4 4 10 4, 10 5 4, 10, 5 + 4, 15 * 60 15 60, 15 3 60, 15, 3 / 60, 5 - 55 OR Anyothermethodofevaluatingcorrectlythepostfixexpressionisshowing the Stack Status. (½ Mark for each operation correctly evaluated showing the Stack Status) OR (½ Mark only to be given for writing correct answer without showing the Stack Status) 4. (a) Observetheprogramsegmentgivenbelowcarefully,andanswerthequestion thatfollows: 1 class Applicant
  • 133.
    344 { long AId; //Applicant’sId char Name [20] ; //Applicant’s Name float Score; //Applicant’s Score public: void Enroll ( ); void Disp ( ); void MarksScore( ); //Function to change Score long R_AId () {retumAId;) } ; void ScoreUpdate (long Id) { fstream File; File.open (“APPLI.DAT”,ios::binary|ios::in|ios::out); Applicant A; int Record = 0, Found = 0 ; while (!Found && File.read((char*) &C, sizeof(c))) { if(Id ==A.R_AId ( )) { cout<<”Enter new Score” ; A.MarksScore ( ); ______________ // Statement 1 ______________ //Statement 2 Found = 1 . } Record ++; } if (Found ==1) cout<<”Record Updated”; File.close ( ) ; } WritetheStatement1topositiontheFilePointeratthebeginningoftheRecord forwhichtheApplicant’sldmatcheswiththeargumentpassed,andStatement2 to write the updated Record at that position. Ans: Statement 1 : File.seekp (Record * sizeof (A)); OR File.seekp (Record * sizeof (Applicant)); OR
  • 134.
    345 File.seekp (File. tellg()- sizeof(A)); OR File. seekp(File. tellg() - sizeof{Applicant)); OR File. seekp(-sizeof (A) , ios::cur); OR File.seekg(Record * sizeof(A)); OR File.seekg(Record * sizeof(Applicant)); OR File. seekg(-sizeof (A) , ios::cur); OR Anyequivalentcorrectmethod Statement 2: File.write((char*) &A, sizeof (A)); OR File.write((char*)&A, sizeof(Applicant)); OR Any equivalent correct method usingAor C as object (½ Mark for each correct Statement) Note: (Full1Marktobegivenformentioningerrorincodeforundeclaredsymbols C and c in the File.read(...)) (b) Write a function in C++ to count the number of lowercase alphabets present in a text file “BOOK.TXT”. 2 Ans: int CountLower() { ifstream Fil; OR ifstream Fil (“BOOK.TXT”); Fil.open(“BOOK. TXT”) char Ch; int Count =0; while (Fil.get(Ch)) { if (Ch>=‘a’ && Ch<=‘z’) Count++;   
  • 135.
    346 } Fil.close() ; //Ignore returnCount; } OR int CountLower() { OR ifstream Fil (“BOOK.TXT”);ifstream Fil; Fil.open(“BOOK. TXT”); char Ch; int Count =0; while (Fil.get(Ch)) { if (islower(Ch)) Count++; } Fil.close(); //Ignore return Count; } OR int CountLower() { ifstream Fil; OR ifstream Fil (“BOOK.TXT”); Fil.open(“BOOK.TXT”); char Ch; int Count = 0; while (!Fil.eof()) { ch=Fil.get() ; if (islower(Ch)) Count++; } Fil.close() ; //Ignore return Count; } OR Any other correct function definition (½ Mark for opening BOOK. TXT correctly) (½ Mark for reading each character from the file) (½ Mark for checking lowercase alphabet) (½ Mark for calculating the lowercase alphabets)      
  • 136.
    347 NOTE: No Mark shouldbe deducted if Count is not returned (c) GivenabinaryfilePHONE.DAT,containingrecordsofthefollowing structuretype 3 class Phonlist { char Name [20] ; char Address[30]; char AreaCode[5]; char PhoneNo[15] ; public: void Register () ; Void Show ( ) ; int CheckCode (char AC[]) { return strcmp (AreaCode, AC) ; } } ; Write a function TRANSFER ( ) in C++, that would copy all those records which are having AreaCode as “DEL” from PHONE.DAT to PHONBACK.DAT. Ans: void TRANSFER() OR { ifstream fin (“PHONE.DAT”, ios: :binary); Phonlist P; ofstream fin (“PHONBACK.DAT”, ios: :binary); fstream fin,fout; fin.open(“PHONE.DAT”,ios::binary|ios::in); fout.open(“PHONBACK.DAT”, ios:: binary | ios::out); while (fin.read((char*)&P, sizeof(P))) { if (P. CheckCode(“DEL”) ==0) fout.write((char*)& P,sizeof(P)); } fin.close(); //ignore fout.close(); //ignore } OR OR void TRANSFER() ifstream fin (“PHONE.DAT”, ios: :binary); { ofstream fin (“PHONBACK.DAT”, ios: :binary); Phonlist P; fstream fin, fout; fin. open (“PHONE. DAT”, ios: : binary | ios: : in);
  • 137.
    348 fout.open(“PHONBACK.DAT”, ios: :binary|ios::in); if (fin) { fin.read((char*)&P, sizeof(P)); while (!fn.eof()) { if (P.CheckCode(“DEL”) ==0) fout.write((char*)&P, sizeof(P)); fin.read((char*)&P, sizeof(P)); } } fin.close(); //ignore fout.close(); //ignore } (½ Mark for opening PHONE.DAT correctly) (½ Mark for opening PHONBACK.DAT correctly) (½ Mark for reading each record from PHONE.DAT) (½ Mark for correct loop / checking end of file) (½ Mark for comparing value returned by CheckCode(“DEL”) with 0) (½ Mark for writing the record to PHONBACK.DAT) 5. (a) Differentiate between Candidate Key and Primary Key in context of RDBMS Ans: CandidateKey:Allsuchattributes/columns,whichcanuniquelyidentifyeach row/record in a table PrimaryKey:Anattribute/columnamongtheCandidateKeyswhichisused touniquelyidentifyeachrow/recordinatable (2Marksforanyvaliddifference/relationbetweenCandidateKeyandPrimary Key) OR (1 Mark for correct explanation of Candidate Key) (1 Mark for correct explanation of Primary Key) (b) Consider the following tables Product and Client.Write SQLcommands for the statement (i) to (iv) and give outputs for SQL queries (v) to (viii) 6 TABLE: PRODUCT
  • 138.
    349 TABLE:CLIENT (i) Todisplaythedetails ofthoseClientswhoseCityisDelhi Ans:SELECT * FROM Client WHERE City = ‘Delhi’; (½ Mark for correct SELECT) (½ Mark for correct WHERE clause) (ii) To display the details of Products whose Price is in the range of 50 to 100(Bothvaluesincluded) Ans: SELECT * FROM Product WHERE Price >=50 AND Price <=100; OR SELECT * FROM Product WHERE Price BETWEEN 50AND 100; (½ Mark for correct SELECT) (½ Mark for correct WHERE clause) (iii) TodisplaytheClientName,CityfromTableClient,andProductName andPricefromtableProduct,withtheircorrespondingMatchingP_ID Ans: SELECT ClientName, City, ProductName, Price, Client.P_ID FROM Client, Product WHERE Client.P_ID = Product. P_ID; (½ Mark for correct SELECT) (½ Mark for correct WHERE clause) (iv) To increase the Price of all Products by 10 Ans: UPDATE Product SET Price = Price +10; (½ Mark for correct SELECT) (½ Mark for correct WHERE clause) (v) SELECT DISTINCTAddress FROM Client Ans: DISTINCT City Bangalore Delhi
  • 139.
    350 Mumbai (½ Mark forcorrect output) OR (½ Mark for mentioning Address is not a Column in the Table Client OR mentioningERROR) (vi) SELECTManufacturer,MAX(Price),Min(Price),Count(*) FROM Product GROUP BY Manufacturer; Ans: Manufacturer MAX(Price) MIN(Price) Count(*) ABC 55 45 2 LAK 40 40 1 XYZ 120 95 2 (½ Mark for correct output) (vii) SELECT ClientName, ManufacturerName FROM Product, Client WHERE Client.Prod_Id = Product.P_Id; Ans: ClientName Manufacturer Cosmetic Shop ABC TotalHealth ABC Livelife XYZ PrettyWoman XYZ Dreams LAK (½ Mark for correct output) OR (½MarkformentioningManufactureNameandProd_ldarenotvalidColumn intherespectiveTables) (viii) SELECT ProductName, Price * 4 Ans: Product Name Price * 4 TalcomPowder 160 Face Wash 180 Bath Soap 220 Shampoo 480 Face Wash 380 (½ Mark for correct output) NOTE: For Parts (v) to (viii), Ignore the Column Header and order of output rows
  • 140.
    351 6. (a) Stateand verify De Morgan’s law in BooleanAlgebra 2 Ans: (X + Y )’= X’. Y’ OR (X . Y)’= X’+ Y’ Verification: OR (X+Y)’ = X’. Y’ If (X+Y)’ . (X+Y) = (X’ . V’) . (X+Y) If 0 - = X’. Y’ . X + X’. Y’ . Y If 0 = 0 + 0 Hence Proved andVerified (1 Mark for stating anyone of the De Morgan’s Law) (1 Mark for verifying anyone of the De Morgan’s Law) (b) DrawaLogicalCircuitDiagramforthefollowingBooleanExpression 1 X’ . (y’ + Z) Ans: (1 Marks for Drawing Logic Circuit Diagram for all ) (c) ConvertthefollowingBooleanexpressionintoitsequivalentCanonicalSum of Product Form«SOP) 2 (X’ +Y +Z’). (X’ +Y +Z). (X’ +Y’ +Z). (X’ +Y’ +Z’)” Ans: F( X , Y , Z) = Π (4 , 5 , 6 , 7) = ∑ (0 , 1 , 2 , 3)
  • 141.
    352 = X’. Y’.Z’+ X’. Y’. Z + X’. Y. Z’+ X’. Y. Z (2 Marks for writing correct Canonical SOP Expression) OR (1 Mark for only deriving Product Terms) (d) Question Ans: F= C’.D’ + A’.C + B’.D’ (½ Mark for drawing correct K-Map) (½ Mark for plotting 1‘s correctly) (1 Mark for correct grouping) (1 Mark for correct Answer) 7. (a) What is a Hub? 1 Ans: A Hub is used for a central connection between two or more computers on a network. OR A Hub is a network device used to connect two or more computers. OR A Hub is an unintelligent network device to connect computers. (1 Mark for any correct definition / explanation) (b) ExpandthefollowingtermswithrespecttoNetworking: 2 (i) Modem (ii) WLL (iii) FTP (iv) TCP/IP Ans: (i) Modulator - Demodulator (ii) Wireless Local Loop OR Wireless in Local Loop (iii) File Transfer Protocol (iv) TransferControl Protocol/Internet Protocol (½ Mark for each correct expansion)
  • 142.
    353 (c) HowisCoaxialcabledifferentfromOpticalFibre? 1 Ans:CoaxialCable:ComparativelySlow,Economic,convenienttolaydown,used inBustopologyofnetworks Optical Fibre:Veryfast,expensive,reliable,nointerference (1 Mark for mentioning anyone valid difference) OR (½ Mark for anyone characteristic each of Coaxial Cable or Optical Fibre) (d) “Bias Methodologies” is planning to expand their network in India, starting withthreecitiesinIndiatobuildinfrastructureforresearchanddevelopment of their chemical products. The company has planned to setup their main officeinPondicherry-atthreedifferentlocationsandhavenamedtheiroffices as “Back Office”, “Research Lab” and “Development Unit”. The company has one more Research office namely “Corporate Office” in “Mumbai”.A roughlayoutofthesameisasfollows: 4 Approximatedistancesbetweentheseofficesisasfollows: Incontinuationoftheabove,thecompanyexpertsp.ayeplannedtoinstallthe followingnumberofcomputersineachoftheiroffices:
  • 143.
    354 (i) Suggest thekind of network required (out of LAN, MAN, WAN) for connectingeachofthefollowingofficeunits: Research Lab and Back Office ResearchLabandDevelopmentUnit Ans: Research Lab and Back Office - LAN Research Lab and Development Unit - MAN (½ Mark for each answer) (ii) Whichoneofthefollowingdevicewillyousuggestforconnectingall thecomputerswithineachoftheirofficeunits? Switch/Hub Modem Telephone Ans: SwitchIHub (1 Mark for mentioning correct option) (iii) Whichofthefollowingcommunicationmedium,youwillsuggesttobe procured by the company for connecting their local office units in Pondicherryforveryeffective(HighSpeed)communication? TelephoneCable OpticalFiber EthernetCable Ans: OpticalFibre (1 Mark for mentioning correct option) (iv) Suggestacable/wiringlayoutforconnectingthecompany'slocaloffice units located in Pondicherry. Also, suggest an effective method/ technologyforconnectingthecompany'sofficeunitlocatedinMumbai. Ans: Local office units at Pondicherry to be connected using LAN / MAN / star Topology / Tree Topology Mumbai Office to be connected using Satellite/WAN (½ Mark for mentioning valid connectivity or topology or diagram for local office in Pondicherry) (½ Mark. for mentioning valid connectivity or topology or diagram for Mumbai office)
  • 144.
    355 MARKING SCHEME QUESTION PAPERCODE 91 EXPECTEDANSWERS 1. (a) What is the purpose of using a typedef command in C++. Explain with suitableexample. 2 Ans: Typedef: Thiskeywordallowscreatingsynonymsoraliasesforpreviouslydefineddata types Thegeneralformoftypedefis typedefold_namenew_name; OR typedef is used for renaming a data type. Example: typedef char STR [80]; OR typedef signed char SMALLNUM; OR typedef float REAL; OR typedef long int BIGNUM; OR typedef int MAT[2][3] ; (1 Mark for definition of typedef) (1 Mark for example of typedef) OR (Full 2 Marks for an example with an appropriate explanation) (b) Name the header files that shall be needed for the following code: 1 void main ( ) { char Word [ ] =”Exam”; cout<<setw(20)<<Word; } Ans: iostream.h iomanip.h (½ Mark for identifying each correct header file) Note: Marks are not to be deducted if any additional header file is mentioned
  • 145.
    356 (c) Rewritethefollowingprogramafterremovingthesyntaxerror(s),ifany. Underlineeachcorrection. 2 #include<iostream.h> void main ( ) { One = 10, Two = 20; Callme (One;Two) ; Callme (Two) ; } void Callme (int Arg1, int Arg2=20) { Arg1 = Arg1 + Arg2; cout<<Arg1>> Arg2; } Ans: #include <iostream.h> void Callme (int,int Arg2=20); //Error 1 void main () { int One=10,Two=20; //Error 2 Callme(One,Two); //Error 3 Callme (Two); } void Callme (int Argl, int Arg2=20) { Argl=Argl +Arg2 ; cout<<Argl<<Arg2; //Error 4 } (½ Mark for each correction) OR (1 Mark for only identifying at least three errors, without suggesting correction) (d) Findtheoutputofthefollowingprogram: #include<iostream.h> #include<ctype.h> void main ( ) { char Mystring[ ] =“What@OUTPUT!” ; for(int I = 0; Mystring [I] ! =’ 0'; I++) {
  • 146.
    357 if (!isalpha (Mystring[I])) Mystring[I] = ‘*’; else if (isupper (Mystring[I])) Mystring [I] = Mystring[I] +1; else Mystring [I] = Mystring [I+1]; } cout<<Mystring; } Ans: Xat@*PVUQVU* (½ Mark for X in the first position) (½ Mark for at in the 2nd & 3rd positions) (½ Mark for @ in the 4th position) (½ Mark for * in the 5th position) (½ Mark for PVUQvu) (½ Mark for * at the end) (e) Findtheoutputofthefollowingprogram: #include<iostream.h> void main ( ) { int A=5, B=10; for (int I = 1; I<=2; 1++) { cout<< “Linel=”<<A++<<“&”<<B–2<<endl; cout<<“Line2=”<<++B<<“&”<<A+3<<endl; } } Ans: Line1=5&8 Line2=11&9 Line1=6&9 Line2=12&10 (½ Mark for each correct line of output) Note: . ½ Mark to be deducted for missingAmpersand (&) in each line of output ½ Mark to be deducted if endl is not considered in the output (f) Inthefollowingprogram,findthecorrectpossibleoutput(s)fromtheoptions: #include<stdlib.h>
  • 147.
    358 #include<iostream.h> void main () { randomize() ; char Area [] [10] = {‘‘NORTH”, ‘‘SOUTH”, “EAST”, “WEST”} ; int ToGo; for (int I=0; 1<3; 1++) { ToGo = random(2) +1; cout<<Area [ToGo]<<” : “; } } (i) SOUTH:EAST:SOUTH: (ii) NORTH:SOUTH:EAST: (iii)SOUTH:EAST:WEST: (iv) SOUTH:EAST:EAST: Ans: (i)and(iv) (2 Mark for the correct answer) OR (1 Mark for anyone of the option) 2. (a) Differentiatebetweenprivateand protectedvisibilitymodesincontextof ObjectOrientedProgramminggivingasuitableexampleillustratingeach. Ans: Private Visibility Mode Protected Visibility Mode Themembersinprivatevisibility Themembersinprotectedvisibility modes are not accessible to modes are not accessible to objects objectsaswellasderivedclasses but are accessible in derived classes class A { int x; protected: int y; public: void display(void) ; } ; class B:public A { int a; public: int b; void readit(void) ; };
  • 148.
    359 (1 mark foranyone correct difference given above) (1 mark for correct example). (b) Answerthequestions(i)and(ii)aftergoingthroughthefollowingprogram: #include<iostream.h> #include<string.h> class Retail { char Category [20]; char Item [20]; int Qty; float Price; Retail ( ) // Function 1 { strcpy (Category, “Cereal”); strcpy (Item, “Rice”); Qty = 100; Price = 25; } public: void Show ( ) // Function 2 { cout<<Category<<“–”<<Item<<“ : ”<<Qty <<“@”<<Price<<endl; } }; void main ( ) { Retail R; // Function 1 R. Show ( );. // Function 2 } Ans: i) No, since the constructor Retail has been defined in private section. Suggested Correction: Constructor RetailO to be defined in public section of class. (½ mark for identifying No) (½ mark for justification) Ans: ii) Cereal-Rice:100@25 (1 full mark for the correct answer) (c) DefineaclassClothinginC++withthefollowingdescriptions: PrivateMembers:
  • 149.
    360 Code of typestring Type of type string Size of type integer Material of type string Price of type float AfunctionCalc_Price()whichcalculatesandassignsthevalueofPrice asfollows: For the value of Material as “COTTON” : Type Price (Rs.) TROUSER 1500 SHIRT 1200 ForMaterialotherthan“COTTON”theabovementionedPrice gets reduced by 25%. PublicMembers: Aconstructor to assign initial values of Code, Type and Material with the word “NOTASSIGNED” and Size and Price with 0. Afunction Enter( ) to input the values of the data members Code,Type, Size and Material and invoke the CalcPrice( ) function. A function Show( ) which displays the content of all the data members for a Clothing. Ans: class Clothing { char Code[25]; char Type[25]; int Size; char Material[30]; float Price; Public: Clothing() ; void Calc_Price() ; void Enter() ; void Show() ; }; Clothing::Clothing() { strcpy(Code,”NOT ASSIGNED”); strcpy(Type,”NOT ASSIGNED”); Size=0;
  • 150.
    361 strcpy (Material, “NOTASSIGNED”); Price=0; } void Clothing:: Calc_Price() { if (strcmp(Type, “TROUSER”) ==0 && strcmp (Material,“COTTON”)==0) Price=1500; else if (strcmp(Type, “SHIRT”) ==0 && strcmp(Material,”COTTON”)==O) Price=1200; else if (strcmp(Type, “TROUSER”) ==0 && strcmp(Material,”COTTON”)!=O) Price=1500*0.75; else if (strcmp(Type,”SHIRT”)==0) && strcmp(Material,”COTTON”)!= 0) Price=1200*0.75; } void Clothing::Enter() { gets(Code) ; // or cin >> Code; gets(Type) ; // or cin >> Type; cin>>Size; gets(Material) ;// or cin >> Material; Calc_Price() ; } void Clothing::Show() { cout<<Code<<Type<<Size<<Material<<Price<<endl; } (½ Mark for correct syntax for class header) (½ Mark for correct declaration of data members) (½MarkforcorrectdefinitionoffunctionCalc_price()) (½ Mark for constructor) (1 Mark for calculation of correct Price for each condition) (½ Mark for correct Enter() with proper invocation of Calc_Price()) (½MarkfordisplayingalldataMembersinfunctionShow()) (d) Answer the questions (i) to (iv) based on the following code: class Toys { char TCode [5] ; protected: float Price; void Assign (float); public: Toys( ) ; void TEntry ( ) ; ,
  • 151.
    362 void TDisplay (); } ; class SoftTOYS: public Toys { char STName [ 20] ; float weight; public: SoftToys( ) ; void STEntry ( ) ; void STDisplay ( ); } ; class ElectronicToys: public Toys { char ETName[20]; int No_of_Batteries; public: ElectronicToys( ) ; void ETEntry ( ) ; void ETDisplay ( ) ; } ; (i) Whichtypeofinheritanceisshownintheaboveexample? Ans: HierarchicalInheritance OR SingleLevelInheritance (1 Mark to be given for mentioning any of the above mentioned type of inheritance) (ii) How many bytes will be required by an object of the class softToys? Ans: 33 (1 Mark for correct answer) (iii) Writenameofallthedatamember(s)accessiblefrommemberfunctions of class SoftToys. Ans: Data Members: Price, STName, Weight (1 Mark for all correct members) NOTE: No marks to be awarded for partially correct answers (iv) Writenameofallthememberfunctions,whichareaccessiblefroman object of the class ElectronicToys. Ans: Member Functions: TEntry ( ) , TDisplay ( ) , ETEntry ( ) , ETDisplay ( ) (1 Mark for correct answer)
  • 152.
    363 NOTE: ConstructorsToys() & ElectronicToys(),it mentioned to be ignored. No marks to be awarded for partially correct answers 3. (a) WriteafunctioninC++,whichacceptsanintegerarrayand its size as arguments andswapstheelementsofeveryevenlocationwithitsfollowingoddlocation. 4 Example:ifanarrayofnineelementsinitiallycontainstheelementsas 2, 4, 1, 6, 5, 7, 9, 23, 10 thenthefunctionshouldrearrangethearrayas 4, 2, 6, 1, 7, 5, 23, 9, 10 Ans: void Display (int NUM[ ], int N) { int T; for (int I=0; I<N–l; I+=2) { T=N[I] ; N[I]=N[I+1] ; N[I+1] = T ; } } (1 Mark tor correct Function Header with proper Arguments) (1 Mark for correct loop) (2 Marks for swapping values correctly with/without a temporary variable) (b) An arrayArr[50] [100] is stored in the memory along the row with each element occupying2bytes.FindouttheaddressofthelocationArr[20][50],ifthelocation Arr[10] [25] is stored at the address 10000. Ans: Assuming LBR=LBC=0 S=2 bytes Number of Rows (N)=50 Number of Columns (M)=100 LOC (Arr [I] [J]) =B + (I*M+J)*S LOC (Arr [10] [25])=B +(10*100+25)*2 10000 = B +(1000+25)*2 B = 10000-2050 B = 7950 LOC (Arr [20] [50]) = 7950+(20*100+50)*2 = 7950 + (2050*2)
  • 153.
    364 = 7950+4100 = 12050 OR AssumingLBR=LBC=1 S=2 bytes Number of Rows (N)=50 Number of Columns (M) =100 LOC (Arr [I] [J]) =B +((I-LBR)*M+(J-LBC))*S LOC (Arr [10] [25]) =B +((10–1)*100+(25–1))*2 10000 = B +(900+24)*2 B = 10000-1848 B = 8152 LOC (Arr [20] [50]) = 8152+ ((20-1)*100+ (50-1))*2 = 8152 + (1949*2) = 8152+3898 = 12050 (2 Mark for writing correct formula(for row major), substituting formula with correct values and calculate Base Address) (1 Mark for writing correct formula/correct substituted values, for row major properly, for calculating Address of Arr[20][50]) (1 Mark for calculating correct Address of Arr[20][50]) (c) WriteafunctioninC++toDeleteanelementfromadynamicallyallocatedQueue where each node contains a real number as data. AssumethefollowingdefinitionofMYNODEforthesame. struct MYNODE { float NUM; MYNODE *Link; } ; Ans: class QUEUE { MYNODE *Rear,*Front; public: QUEUE() { Rear=NULL; Front=NULL;} void DELETE(); ~QUEUE() ; }; //Function definition DELETE()
  • 154.
    365 void QUEUE:: DELETE() { if(Front==NULL) // OR if{!Front) cout<<”n Queue Underflown”i else { MYNODE *Temp; Temp=Front; cout<<Front->NUM<<“:”<<“Deleted”<<endl; // To be ignored Front=Front–>Link; delete Temp; if (Front==NULL) Rear=NULL; } } OR void DELETE(MYNODE *& Front, MYNODE *& Rear) { if (! Front) cout<<“n Queue Underflown”; else { MYNODE *Temp; Temp=Front; cout<<Front–>NUM<<“:”«“Deleted”<<endl; //To be ignored Front=Front–>Link; delete Temp; if (Front==NULL) Rear=NULL; } } Note. If Front and Rear are declared as Global vanabfes then Parameters are not needed in the above function. (½ Mark for correct function header) (½ Mark for declaring Front and Rear as members OR passing them as arguments OR declaring them as global variables) (1 Mark for checking Underflow) (1 Mark for updating Front) (1 Mark for deleting node)
  • 155.
    366 (d) Write afunction in C++ to print the product of each row of a two dimensional integer array passed as the argument of the function. Example:ifthetwodimensionalarraycontains Then the output should appear as : Product of Row 1= 8000 Product of Row 2= 6000 Product of Row 3= 3600 Product of Row 4= 2400 Ans: // Function definition void Display(int A[ ][3], int M, int N) { int I, J; long int T; // OR int T; cout<<“Performing Calculation:”<<endl; for (I=0; I<M; I=I+1) { T=1; for (J=0; J<N; J=J+1) T=T*A[M][N] ; cout<<”Product of Row “<<I+1<<”= “<<T<<endl; } } OR Any other correct equivalent function definition (1/2 mark for correct function header) (1/2 mark for correct loops) (1/2 mark for calculating product) (1/2 mark for correct initialization of T after every inner loop) (e) Evaluatethefollowingpostfixnotationofexpression(ShowstatusofStack after execution of each operation) : 5, 20, 15, –, *, 25, 2, *, +
  • 156.
    367 Ans: Evaluationofthegivenpostfixexpressionisexplainedbelow Operator ScannedStack Content 5 5 20 5, 20 15 5, 20,15 - 5, 5 * 25 25 25, 25, 2 2 25, 25, 2 * 25, 50, + 75 OR Any other method of evaluating the postfix expression is shown. (2 Marks to be given for correct answer) (½ Mark for each operation correctly evaluated) (Only 1 Mark is to be awarded if correct answer is given without steps) 4. (a) Observetheprogramsegmentgivenbelowcarefully,andanswerthequestion thatfollows: class Candidate { long Cld; / /Candidate’ s Id char CName [20];/ /Candidate’s Name float Marks; / /Candidate’s Marks public: void Enter ( ) ; void Display ( ) ; void MarksChange( ) ; / /Function to change marks lond R_Cid( ) {return Cld; ) }; void MarksUpdate (long Id) { fstream File; File.open (“CANDIDAT.DAT”,ios: :binary | ios: :in | ios: :out); Candidate C; int Record=0, Found=0; while (! Found && File.read ( (char*) &C, sizeof (C) ) ) {
  • 157.
    368 if (Id==C. R_Cld( ) ) { cout<<”Enter new Marks”; C.MarksChange( ) ; _______________/ /Statement 1 _______________/ /Statement 2 Found -= 1; } Record++; } if (Found= =1) cout<<”Record Updated”; File.close ( ) ; } WritetheStatement1topositiontheFilePointeratthebeginningoftheRecord forwhichtheCandidate’sIdmatcheswiththeargumentpassed,andStatement 2 to write the updated Record at that position. Ans: Statement 1: File.seekp(Record*sizeof(C)); OR File.seekp(-l*sizeof(C),ios::cur); OR File.seekg (Record*sizeof(C)); OR File.seekg(-l*sizeof(C),ios::cur); OR Any equivalent correct method qf calculating size of the record in place of sizeof operator. Statement 2: File.write((char*)&C, sizeof(C)); OR File.write((char*)&C,sizeof(Candidate)); (½ Mark for each correct statement) (b) Write a function in C++ to count the number of uppercase alphabets present inatextfile“ARTICLE.TXT”. Ans: void theUpperAlphaCount() { ifstream Fi1(“ARTICLE. TXT”) ;
  • 158.
    369 //R fstream Fi1; //Fil.open(“ARTICLE.TXT”, ios : : in) ; Char ch; int c=0; while(Fil) // OR while (!Fi1.eof()) Fil.get(ch) ; //OR ch = Fil.get(); if (isupper(ch)) //OR if (ch>=65 && ch<=90) OR if (ch>=‘A’&&ch<=‘Z’) c++; } cout<<”Number of alphabets in uppercase”<<c<<endl.; Fil.close() ; } OR void theUpperAlphaCount() { ifstream Fil(“ARTICLE.TXT”); //R fstream Fil; //Fil.open(“ARTICLE. TXT”, ios:: in) ; char ch; int c=0; while (Fil.get(ch)) { if (isupper(ch)) //OR if (ch>=65 && ch<=90) OR if (ch>=‘A’ && ch<=‘Z’) c++; } cout<<“Number of alphabets in uppercase”<<c<<endl; Fil.close(); } (½ Mark for opening file in the correct mode) (½ Mark for reading the content from the file and the loop) (½ Mark for correct comparison) (½Markforinitializationandincrementofthecounter(variable)) (c) Given a binary file TELEPHON.DAT, containing records of the following classDirectory: class Directory { char Name[20] ; char Address[30] ; char AreaCode[5];
  • 159.
    370 char Phone_No[15]; public: void Register( ) ; void Show ( ) ; int CheckCode(char AC[ ]) { return strcmp (AreaCode, AC); } }; Write a function COPYABC( ) in C++, that would copy only those records havingAreaCode as “123” fromTELEPHON.DATtoTELEBACK.DAT. Ans: //Function to copy records from TELEPHON.DAT to //TELEBAC.DAT void COPYABC() { fstream IS, OA; IS.open(“TELEPHON.DAT”, ios::binary|ios: :in); OA.open(“TELEBACK. DAT”, ios::binary | ios:: out); Directory D; while (IS.read((char*)& D,sizeof(D))) { if (D. CheckCode(“123”)==0) OA.write((char *)& D,sizeof(D)); } IS.close() ; OA.close() ; } OR Anyotherequivalentcode (½ Mark for opening each file in the correct mode) (½ Mark for reading the content from the file) (½ Mark for the correct loop) (½ Mark for the correct comparison with “123”) (½ Mark for writing the content to the second file) 5. (a) Differentiate between Candidate Key and Alternate Key in context of RDBMS. Ans: Candidate Key: It is the one that is capable of becoming primary key i.e., a columnorsetofcolumnsthatidentifiesarowuniquelyintherelation. Alternate Key:Acandidate key that is not selected as a primary key is called anAlternateKey.
  • 160.
    371 (1 Mark eachfor correct definition/explanation of Candidate Key and Alternate Key) OR (Full2MarksforillustratingtheconceptofCandidateandAlternatekeywith appropriateexample) (b) Consider the following -tables Item and Customer.Write SQLcommands for the statements (i) to (iv) and give outputs for SQL queries (v) to (viii). TABLE : ITEM TABLE : CUSTOMER (i) To display the details of those Customers whose City is Delhi. Ans: SELECT * FROM CUSTOMER WHERE City=’Delhi’ ; (½ Mark for correct use of SELECT and FROM) (½ Mark for correct use of WHERE clause) (ii) To display the details of Items whose Price is in the range of 35000 to 55000(Bothvaluesincluded) Ans: SELECT * FROM ITEM WHERE PRICE BETWEEN 35000 AND 55000; OR SELECT * FROM ITEM WHERE PRICE>=35000 AND PRICE<=55000; (½ Mark for correct use of SELECT and FROM) (½ Mark for correct use of WHERE clause)
  • 161.
    372 (iii) TodisplaytheCustomerName,CityfromtableCustomerandItemName andPricefromtableitemwiththeircorrespondingmatchingI_Id. Ans: SELECT CustomerName,City, ItemName , Price FROM CUSTOMER C, ITEM I WHERE I. I_Id=C.I_ID; OR SELECT CustomerName, City, ItemName, Price FROM CUSTOMER, ITEM WHERE CUSTOMER.I_Id=ITEM.I_ID; OR SELECT C. CustomerName, C.City, I.ItemName, I.Price FROM CUSTOMER C, ITEM I WHERE C.I_Id=I.I_ID; OR SELECT CUSTOMER.CustomerName, CUSTOMER.City, ITEM. ItemName, ITEM. Price FROM CUSTOMER, ITEM WHERE CUSTOMER.I_Id=ITEM.I_ID; (½ Mark for correct use of SELECT and FROM) (½ Mark for correct use of WHERE clause) (iv) To increase the Price of all Items by 1000 in the table Item. Ans: UPDATE ITEM SET PRICE=PRICE+1000; (½ Mark for cbrrect use of UPDATE) (½ Mark for correct use of SET) (v) SELECT DISTINCT City FROM Customer; Ans: DISTINCT City Delhi Mumbai Bangalore (½ Mark for correct output - ignore the order of City in the output & Column Header) (vi) SELECT ItemName, Max (Price), Count(*) From Item Group by ItemName; Ans: ItemName Max (Price) Count ( * ) PersonalComputer 37000 3 Laptop 57000 2 (½Markforcorrectoutput-ignoretheorderofrowsintheoutput&Column Headers)
  • 162.
    373 (vii) SELECT CustomerName,Manufacturer FROM Item, Customer WHEREItem.Item_Id=Customer.Item.I_Id; Ans: CustomerName Manufacturer N Roy PQR HSingh XYZ R Pandey COMP C Sharma PQR KAgarwal ABC (½Markforcorrectoutput-ignoretheorderofrowsintheoutput&Column Headers) OR (½ Mark for mentioning syntax error or error as the column Item_ld is not present) (viii) SELECTItemName,Price*100FROMItemWHEREManufacturer= 'ABC'; Ans: ItemName Price*100 PersonalComputer 3500000 Laptop 5500000 (½ Mark for correct output - ignore the order of rows in the output & Column Headers) 6. (a) StateanyverifyAbsorptionlawinBoolean-Algebra. Ans: X+X.Y=X X Y X.Y X+X.Y X 0 0 0 0 0 0 1 0 0 0 1 0 0 1 1 1 1 1 1 1 OR X. (X+Y) = X X Y X+Y X.(X+Y) X 0 0 0 0 0 0 1 1 0 0 1 0 1 1 1 1 1 1 1 1
  • 163.
    374 OR X+X’.Y=X+Y X Y X’X’.Y X+X’.Y X+Y 0 0 1 0 0 0 0 1 1 1 0 0 1 0 0 0 1 1 1 1 0 0 1 1 OR X. (X’+Y) =X.Y X Y X’ X’+Y X. (X’+Y) X.Y 0 0 1 1 0 0 0 1 1 1 0 0 1 0 0 0 0 0 1 1 0 1 1 1 OR X+X.Y=X L.H.S=X+X.Y =X.1+X. Y =X. (l+Y) =X.1 =X =R.H.S Verified OR X(X+Y)=X L.H.S=X. (X+Y) L.H.S=X.X+X.Y =X+X.Y =X.1+X.Y =X. (l+Y) =X.1 =X =R.H.S Verified OR
  • 164.
    375 X+X’.Y=X+Y L.H.S=(X+X’).(X+Y) =1.(X+Y) =X+Y =R.H.S Verified OR X.(X’+Y)=X.Y L.H.S=X.(X’ +Y) =X.X’+X.Y =0+X.Y =X.Y =R.H.S Verified (2 Marksfor verification of anyone form of the Absorption Law) OR (1 Mark for stating anyone form of theAbsorption Law) (b) DrawaLogicalCircuitDiagramforthefollowingBooleanExpression: A . (B + C’) Ans: (1 mark for the correct circuit diagram) (c) ConvertthefollowingBooleanexpressionintoitsequivalentCanonical Product of Sum Form (POS) : A. B’ . C + A’. B . C + A’. B . C’ Ans: = Π (0, 1, 4, 6, 7) OR = (A+B+C) . (A+B+C’) . (A’+B+C) . (A’ +B’ +C) . (A’+B’ +C’ ) (2 Marks for the correct expression) OR (1 Mark if only truth table is given for the expression without deriving POS expression) Note: No marks to be awarded for partial answers F
  • 165.
    376 (d) ReducethefollowingBooleanexpressionusingK-Map: F (A,B, C, D) = ∑ (0, l, 2, 4, 5, 8, 9, 10, 11) Ans: F(A,B,C,D)=A’.C’+A.B’+ B’.D’ (1 Mark for drawing correct K-Map ) (½ Mark for plotting 1‘s correctly) (½ Mark for each correct grouping) Note: No marks should be deducted even if the solution is arrived with the help of POS form. 7. (a) What is a Modem? Ans: ModemisaModulationDemodulationdevicethatconvertsanalogsignalto digitalsignalandviceversa. (1Markforanycorrectdefinition/explanation) (b) ExpandthefollowingtermswithrespecttoNetworking: (i) PPP (ii) GSM (iii) XML (iv) HTTP Ans: (i) PointTo Point Protocol (ii) GlobalSystemforMobileCommunication (iii) eXtensibleMarkUpLanguage (iv) HyperTextTransfer Protocol (½ Mark for each correct expansion) (c) How is a Hacker different from a Cracker? Ans: Hackers are the ones who get into someone’s code or computer without any maliciousintentions,whereasCrackersaretheone’swhogetintosomeone’s codeorcomputerwithmaliciousintentions. OR Any equivalent difference (½ Mark for each correct definition) (d) “China Middleton Fashion’” is planning to expand their network in India, starting with two cities in India to provide infrastructure for distribution of
  • 166.
    377 their product. Thecompany has planned to set up their main office units in Chennaiatthreedifferentlocationsandhavenamedtheirofficesas“Production Unit”,“FinanceUnit”and“MediaUnit”.Thecompanyhasitscorporateunit inDelhi. Aroughlayoutofthesameisasfollows: ApproximatedistancesbetweentheseUnitsisasfollows: Incontinuationoftheabove,thecompanyexpertshaveplannedtoinstallthe followingnumberofcomputersineachoftheirofficeunits:
  • 167.
    378 (i) Suggest thekind of network required (out of LAN, MAN,WAN) for connectingeachofthefollowingofficeunits: ProductionUnitandMediaUnit ProductionUnitandFinanceUnit Ans: Production Unit and Media Unit : MAN ProductionUnitandFinanceUnit: LAN (½ Mark for mention of each - MAN and LAN correctly) (ii) Whichoneofthefollowingdevicewillyousuggestforconnectingall thecomputerswithineachoftheirofficeunits? Switch/Hub Modem Telephone Ans: Switch/Hub (1 Mark for the correct device) (iii) Which of the following communication media, will you suggest to be procuredbythecompanyforconnectingtheirlocalofficesinChennai forveryeffective(HighSpeed)communication? Ethernetcable OpticalFiber Telephonecable Ans: OpticalFiber (1 Mark for the correct media) (iv) Suggestacable/wiringlayoutforconnectingthecompany'slocaloffice unitslocatedinChennai.Also,suggestaneffectivemethod/technology forconnectingthecompany'sofficeunitlocatedinDelhi. Ans: Optical Fiber/StarTopology Wireless/SatelliteLink/leasedLine (½ Mark for the correct layout) (½ Mark for the equivalent correct method/technology)
  • 168.
    310 COMPUTER SCIENCE Time allowed: 3 hours Maximum Marks : 70 Instructions: (i) All questions are compulsory. (ii) Programming Language: C+ + QUESTION PAPER CODE 91/1 1. (a) What is the difference between call by value and call by reference? Give an exampleinC++toillustrateboth. 2 (b) Writethenamesoftheheaderfilestowhichthefollowingbelong: 1 (i) puts( ) (ii) sin() (c) Rewritethefollowingprogramafterremovingthesyntacticalerrors(ifany). Underlineeachcorrection. 2 #include [iostream.h] #include [stdio.h] class Employee { int EmpId = 901; char EName [20] ; public Employee ( ) { } void Joining () {cin>>EmpId; gets (EName);} void List ( ) {cout<<EmpId<<“ : ”<<EName<<endl;} } ; void main ( ) { Employee E ;
  • 169.
    311 Joining.E ( ); E. List ( ) } (d) Findtheoutputofthefollowingprogram: 3 #include<iostream.h> void main ( ) { int X[ ] = {10, 25, 30, 55, 100}; int *p = X ; while ( *p < 110) { if (*p%3 ! = 0) *p = *p + 1 ; else *p = *p + 2 ; p++; } for(int I = 4 ; 1>= 1 ; I - -) { cout << X[I] << “*” ; if ( I%3 = = 0) cout<<endl ; } cout<<X[0]*3<<endl ; } (e) Findtheoutputofthefollowingprogram: 2 #include<iostream.h> #include<ctype.h> void Encode (char Info [ ], int N) ; void main ( ) {
  • 170.
    312 char Memo [] = “Justnow” ; Encode(Memo, 2) ; cout<<Memo<<endl ; } void Encode(char Info[ ], int N) { for (int I = 0 ; Info[I] != ‘0’ ; 1++) if (1%2= =0) Info[I] = Info[I] –N ; else if (islower(Info[I])) Info[I] = toupper(Info[I]) ; else Info[I] = Info[I] +N ; } (f) Studythefollowingprogramandselectthepossibleoutputfromit: 2 #include <iostream.h> #include <stdlib.h> const int LIMIT = 4 ; void main ( ) { randomize ( ) ; int Points; Points = 100 + random(LIMIT) ; for (int P=Points ; P>=100 ; P– –) cout<<P<<“#” ; cout<<endl; } (i) 103#102#101#100# (ii) 100#101#102#103#
  • 171.
    313 (iii) 100#101#102#103#104# (iv) 104#103#102#101#100# 2.(a) What is copy constructor? Give an example in C++ to illustrate copy con- structor. 2 (b) Answer the questions (i) and (ii) after going through the following class: class WORK 2 { int WorkId;char WorkType ; public: -WORK ( ) //Function 1 { cout<<”Un-Allocated”<<endl ;} void status ( ) //Function 2 { cout<<WorkId<<”: “<<WorkType<<endl ;} WORK ( ) //Function 3 { WorkId = 10; WorkType=’T’ ; } WORK(WORK &W) //Function 4 { WorkId=W. WorkId+12;WorkType=W. WorkType+l } } ; (i) WhichmemberfunctionoutofFunction1,Function2,Function3andFunction 4shownintheabovedefinitionofclassWORKiscalledautomatically,when the scope of an object gets over? Is it known as Constructor OR Destructor OR Overloaded Function OR Copy Constructor? (ii) WORK W ; //Statement1 WORK Y (W) ; //Statement2 WhichmemberfunctionoutofFunction1,Function2,Function3andFunction 4shownintheabovedefinitionofclassWORKwillbecalledonexecutionof statementwrittenasstatement2?Whatisthisfunctionspecificallyknownas out of Destructor or Copy Constructor or Default Constructor? (c) DefineaclassRESORTinC++withfollowingdescription: 4
  • 172.
    314 PrivateMembers Rno //Data memberto store Room No Name //Data member to store customer name Charges //Data member to store per day charges Days //Data member to store number of days of stay COMPUTE( ) //A function to calculate’ and return Amount as Days*Charges and if the value of Days*Charges is more than 11000 then as 1.02*Days*Charges PublicMembers Getinfo() //A function to enter the content Rno, Name, //Charges and Days Dispinfo() //A function to display Rno, Name, Charges, //Days andAmount (Amount to be displayed by //calling function COMPUTE ( ) ) (d) Answerthequestions(i)to(iv)basedonthefollowing: 4 class FaceToFace { char CenterCode [10] ; public: void Input ( ) ; void Output ( ) ; } ; class Online { char website [50] ; public: void SiteIn ( ) ; void SiteOut ( ) ; } ; class Training: public FaceToFace, private Online
  • 173.
    315 { long Tcode ; floatcharge; int period; public: void Register ( ) ; void Show ( ) ; } ; (i) WhichtypeofInheritanceisshownintheaboveexample? (ii) WritenamesofallthememberfunctionsaccessiblefromShow()functionof classTraining. (iii) WritenameofallthemembersaccessiblethroughanobjectofclassTraining. (iv) Is the function Output( ) accessible inside the function SiteOut( ) ? Justify youranswer. 3. (a) Write a function SORTPOINTS( ) in C++ to sort an array of structure Game in descending order of Points using Bubble Sort. 3 Note:AssumethefollowingdefinitionofstructureGame struct Game { long PNo; //Player Number char PName [20] ; long Points; } ; Sample content of the array (before sorting) PNo PName Points 103 RitikaKapur 3001 104 JohnPhilip 2819 101 RaziaAbbas 3451 105 TarunKumar 2971
  • 174.
    316 Sample content ofthe array (after sorting) PNo PName Points 101 RaziaAbbas 3451 103 Ri tika Kapur 3001 105 TarunKumar 2971 104 JohnPhilip 2819 (b) An array S[40][30]isstoredinthememoryalongthecolumnwith each of the element occupying 4 bytes, find out the base address and address of element S[20][15], if an element S[15][10] is stored at the memory location 7200. 4 (c) Write a function QUEINS( ) in C++ to insert an element in a dynamically allocatedQueuecontainingnodesofthefollowinggivenstructure: 4 struct Node { int PId ; //Product Id char Pname [20] ; NODE *Next ; } ; (d) DefineafunctionSWAPCOL()inC++toswap(interchange)thefirstcolumn elements with the last column elements, for a two dimensional integer array passed as the argument of the function. 3 Example:Ifthetwodimensionalarraycontains 2 1 4 9 1 3 7 7 5 8 6 3 7 2 1 2 After swapping of the content of 1st column and last column, it should be : 9 1 4 2 7 3 7 1 3 8 6 5 2 2 1 7
  • 175.
    317 (e) Convert thefollowing infix expression to its equivalent postfix expression showingstackcontentsfortheconversion: 2 X–Y /(Z + U) * V 4. (a) Observe the program segment given below carefully and fill in the blanks markedasLine1andLine2usingfstreamfunctionsforperformingthere- quired task. 1 #include <fstream.h> class Stock { long Ino ; //Item Number char Item [20] ;//Item Name int Qty ; //Quantity public: void Get(int) ;//Function to enter the content void show ( ) ;//Function to display the content void Purchase (int Tqty) { Qty + = Tqty ; } //Function to increment in Qty long KnowIno ( ) {return Ino ;} } ; void Purchaseitem (long PINo, int PQty) //PINo -> Ino of the item purchased //PQty -> Number of item purchased { fstream File; File.open(“ITEMS.DAT”, ios :: binarylios :: inlios :: out); int Pos = –1 ; Stock S ;
  • 176.
    318 while (Pos == –1 && File.read((char*) &S, sizeof (S))) if (S. KnowIno( ) = =PINo) { S. Purchase (PQty); //To update the number of Items Pos = File.tellg ( ) -sizeof (S) ; //Line 1: To place the file pointer to the required position ; //Line 2: To write the object S on to the binary file ; } if (Pos = = –1) cout<<“No updation done as required Ino not found..” ; File.close ( ) ; } (b) Write a function COUNT_DO( ) in C++ to count the presence of a word ‘do’inatextfile“MEMO.TXT” 2 Example: Ifthecontentofthefile“MEMO.TXT”isasfollows: I will do it, if you request me to do it. It would have been done much earlier. ThefunctionCOUNT_DO()willdisDla Count of -do- in file : 2 Note: In the above example, ‘do’ occurring as a part of word done is not considered. (c) Write a function in C++ to read and display the detail of all the users whose statusis‘A’(i.e.Active)fromabinaryfile“USER.DAT”.Assumingthebinary file “USER.DAT” is containing objects of class USER, which is definedas follows: 3
  • 177.
    319 class USER { int Uid; //User Id char Uname [20];//User Name char Status; //User Type: A Active I Inactive Public: void Register ( ) ;//Function to enter the content void show ( ) ; //Function to display all data members char Getstatus ( ) {return Status;}. } ; 5. (a) What are candidate keys in a table? Give a suitable example of candidate keys in a table. 2 (b) Consider the following tables GARMENT and FABRIC. Write SQL commands for the statements (i) to (iv) and give outputs for SQL queries (v)to(viii) 6 Table:GARMENT Table : FABRIC FCODE TYPE F04 POLYSTER F02 COTTON F03 SILK F01 TERELENE
  • 178.
    320 (i) To displayGCODE and DESCRIPTION of each GARMENT in descending order of GCODE (ii) TodisplaythedetailsofalltheGARMENTs,whichhaveREADYDA TE in between 08-DEC-07 and 16-JUN-08(inclusive of both the dates). (iii) TodisplaytheaveragePRICEofalltheGARMENTs,whicharemade up of FABRIC with FCODE as F03. (iv) To display FABRIC wise highest and lowest price of GARMENTs fromGARMENTtable.(DisplayFCODEofeachGARMENTalong withhighestandlowestprice) (v) SELECT SUM (PRICE) FROM GARMENT WHERE FCODE = ‘F01’ ; (vi) SELECT DESCRIPTION, TYPE FROM GARMENT, FABRIC WHERE GARMENT.FCODE = FABRIC.FCODE AND GARMENT. PRICE > = 1260 ; (vii) SELECT MAX (FCODE) FROM FABRIC; (viii) SELECT COUNT (DISTINCT PRICE) FROM GARMENT ; 6. (a) Verify X’Y+ X.Y’+ X’Y’= (X’+Y’) using truth table. 2 (b) WritetheequivalentBooleanExpressionforthefollowingLogicCircuit: 2 (c) Write the POS form of a Boolean function H, which is represented in a truth tableasfollows: 1
  • 179.
    321 (d) ReducethefollowingBooleanExpressionusingK-Map: 3 F(P,Q, R, S) = Σ(1, 2, 3, 5,6, 7, 9, 11, 12, 13, 15) 7. (a) What is difference between StarTopology and BusTopology of network? 1 (b) Expandthefollowingabbreviations: 1 (i) GSM (ii) CDMA (c) What is protocol? Which protocol is used to search information from internet usinganinternetbrowser? 1 (d) Name two switching techniques used to transfer data between two terminals (computers ). 1 (e) Freshminds University of India is starting its first campus inAna Nagar of South India with its center admission office in Kolkata. The university has 3 major blocks comprising of Office Block, Science Block and Commerce Block in the 5 KM area Campus. As a network expert, you need to suggest the network plan as per (El) to (E4)totheauthoritieskeepinginmindthedistanceandothergivenparameters. ExpectedWiredistancesbetweenvariouslocations: Office Block to Science Block 90 m Office Block to Commerce Block 80 m Science Block to Commerce Block 15 m KolkataAdmission office toAna Nagar Campus 2450 km Expected number of Computers to be installed’ at various locations in the Universityareasfollows: Office Block 10 Science Block 140 Commerce Block 30 KolkataAdmission office 8
  • 180.
    322 (E1) Suggest theauthorities, the cable layout amongst various blocks inside universitycampusforconnectingtheblocks. 1 (E2) Suggest the most suitable place (i.e. block) to house the server of this universitywithasuitablereason. 1 (E3) Suggestanefficientdevicefromthefollowingtobeinstalledineachofthe blocks to connect all the computers: 1 (i) MODEM (ii) SWITCH (iii) GATEWAY (E4) Suggest the most suitable. (very high speed) service to provide data con- nectivity betweenAdmission Office located in Kolkata and the campus locatedinAnaNagarfromthefollowingoptions: 1 Telephoneline Fixed-LineDial-upconnection Co-axial Cable Network GSM Leasedline SatelliteConnection QUESTION PAPER CODE 91 1. (a) What is the difference betweenActual Parameter and Formal Parameter? Give an example in C++ to illustrate both types of parameters. 2 (b) Writethenamesoftheheaderfilestowhichthefollowingbelong: 1 (i) setw( ) (ii) sqrt( ) (c) Rewritethefollowingprogramafterremovingthesyntacticalerrors(ifany). Underlineeachcorrection. 2 include <iostream.h> include <stdio.h> class MyStudent {
  • 181.
    323 int StudentId =1001; char Name [20] ; public MyStudent( ){ } void Register ( ) {cin>>StudentId; gets (Name) ;} void Display ( ) {cout<<StudentId<< “:” <<Name<<end1;} } ; void main ( ) { MyStudent MS ; Register.MS( ) ; MS.Display( ) ; } (d) Findtheoutputofthefollowingprogram: 3 #include<iostream.h> void main ( ) { int A[ ] = {10, 15, 20, 25, 30} int *p = A; while (*p < 30) { if (*p%3 ! = 0) *p = *p + 2 ; else *p = *p + 1; p++; } for (int J = 0; J<=4; J++) { cout << A[J] << “*” ; if ( J%3 = = 0) cout<<end1;
  • 182.
    324 } Cout<<A[4] * 3<<end1; } (e)Findtheoutputofthefollowingprogram: 2 #include <iostream.h> #include <ctype.h> void Secret (char Mig [ ], int N); void main ( ) { char SMS[ ] = “rEPorTmE” ; Secret{SMS,2); cout<<SMS<<end1; } void Secret(char Msg[ ], int N) { for (int C=0; Msg[C] ! =’ 0' ;C++) if (C%2==0) Msg[C] = Msg[C]+N; else if (isupper(Msg[C])) Msg[C] = tolower(Msg[C]); else Msg[C] = Msg[C]-N; } (f) Studythefollowingprogramandselectthepossibleoutputfromit: 2 #include <iostream.h> #include <stdlib.h> const int MAX=3 ; void main ( ) { randomize( ) ; int Number ;
  • 183.
    325 Number = 50+ random{MAX) ; for (int P=Number; P>=50; P– –) cout<<p<< “ # ” ; cout<<endl; } (i) 53#52#51#50# (ii) 50#51#52# (iii) 50#51# (iv) 51#50# 2. (a) Whatisfunctionoverloading?GiveanexampleinC++toillustratefunction overloading. 2 (b) Answerthequestions(i)and(ii)aftergoingthroughthefollowingclass: 2 class Job { int JobId;char JobType; public: ~Job ( ) //Function 1 { cout<< “Resigned” <<end1; } Job ( ) //Function 2 { JobId=10 ; JobType =‘T” ;} void TellMe( )//Function 3 { cout<<JobId<< “: ” <<JobType<<end1; } Job (Job &J) //Function 4 { JobId=J.JobId+10; JobType=J.JobType+l; } };
  • 184.
    326 (i) WhichmemberfunctionoutofFunction1,Function2,Function3andFunction 4shownintheabovedefinitionofclassJobiscalledautomatically,whenthe scope ofan object gets over? Is it known as Constructor OR Destructor OR Overloaded Function OR Copy Constructor? (ii) Job P ; //Line 1 Job Q(P) ; //Line 2 WhichmemberfunctionoutofFunction1,Function2,Function3andFunction 4 shown in the above definition of class Job will be called on execution of statementwrittenasLine2?Whatisthisfunctionspecificallyknownasoutof Destructor or Copy Constructor or Default Constructor? (c) DefineaclassHOTELinC++withthefollowingdescription: 4 PrivateMembers: Rno //Data member to store Room No Name //Data member to store customer name Tariff //Data member to store per day charges NOD //Data member to store number of days of stay CALC( ) //Afunction to calculate and returnAmount as NOD*Tariff and if the value of NOD*Tariff is more than 10000 then as 1.05*NOD*Tariff PublicMembers Checkin ( ) / /Afunction to enter the content Rno, Name, / / Tariff and NOD Checkout( ) / /Afunction to display Rno, Name, Tariff, / /NOD andAmount (Amount to be displayed by //callingfunctionCALC()) (d) Answerthequestions(i)to(iv)basedonthefollowing: 4 class Regular { char SchoolCode[10];
  • 185.
    327 public: void InRegular( ); voidOutRegular( ); } ; class Distance { char StudyCentreCode [‘5] ; public: void InDistance( ); void OutDistance ( ); } ; class Course: public Regular, private Distance { char Code [ 5] ; float Fees; int Duration; public: void InCourse( ); void OutCourse( ); } ; (i) WhichtypeofInheritanceisshownintheaboveexample? (ii) Write names of all the member functions accessible from OutCourse functionofclassCourse. (iii) Write name of all the members accessible througb an object of class Course. (iv) IsthefunctionInRegular()accessibleinsidethefunctionInDistance()? Justifyyouranswer. 3. (a) WriteafunctionSORTSCORE()inC++tosortanarrayofstructureExaminee in descending order of Score using Bubble Sort. 3 Note:AssumethefollowingdefinitionofstructureExaminee
  • 186.
    328 struct Examinee { long RollNo; charName [20] ; float Score; } ; Sample Content of the array (before sorting) Sample Content of the array (after sorting) (b) An array T[50][20] is stored in the memory along the column with each of the elements occupying 4 bytes. Find out the base address and address of element T[30][15], if an element T[25][10] is stored at the memory location 9800. 4 (c) Write a function QUEDEL( ) in C++ to display and delete an element from a dynamically allocated Queue containing nodes of the following given structure: 4 struct NODE {
  • 187.
    329 int Itemno; char Itemname[20]; NODE*Link; } ; (d) Define a function SWAPARR( ) in C++ to swap (interchange) the first row elements with the last row elements, for a two dimensional integer array passed as the argument of the function. 3 Example:Ifthetwodimensionalarraycontains 5 6 3 2 1 2 4 9 2 5 8 1 9 7 5 8 After swapping of the content of first row and last row, it should be as follows: 9 7 5 8 1 2 4 9 2 5 8 1 5 6 3 2 (e) Convert the following infix expression to its equivalent postfix expression showingstackcontentsfortheconversion: 2 A + B * (C – D) / E 4. (a) Observetheprogramsegmentgivenbelowcarefullyandfilltheblanksmarked. asLine1andLine2usingfstreamfunctionsforperformingtherequiredtask. 1 #include <fstream.h> class Library { long Ano; //Ano - Accession Number of the Book char Title[20]; //Title - Title of the Book int Qty; //Qty - Number of Books in Library public:
  • 188.
    330 void Enter(int); //Functionto enter the content void Display(); //Function to display the content void Buy(int Tqty) { Qty+=Tqty; } //Function to increment in Qty long GetAno() {return Ano;} } ; void BuyBook(long BANo,int BQty) //BANo → Ano of the book purchased //BQty → Number of books purchased { fstream File; File.open(“STOCK.DAT” ,ios::binary|ios::in|ios::out); int position=-l; Library L; while (Position==-l && File.read((char*)&L,sizeof(L).)) if (L. GetAno() ==BANo) { L.Buy(BQty); //To update the number of Books Position = File.tellg()-sizeof(L) ; //Line 1: To place the file pointer to the required positiol ______________________________; //Line 2:To write the object L on to the binary file ______________________________; } if (Position==-l) cout<< “No updation do:r{e as required Ano not found..”; File.close(); } (b) Write a function COUNT_TO( ) in C++ to count the presence of a word ‘to’ inatextfile“NOTES.TXT”. 2
  • 189.
    331 Example: Ifthecontentofthefile“NOTES.TXT”isasfollows: It is veryimportant to know that smokingisinjurioustohealth. Let us take initiative to stop it. ThefunctionCOUNT_TO()willdisplaythefollowingmessage: Count of -to- in file: 3 Note: In the above example, ‘to’ occurring as a part of word stop is not considered. (c) Write a function in C++ to read and display the detail of all the members whose membership type is ‘L’or ‘M’from a binary file “CLUB.DAT”. Assume the binary file “CLUB.DAT” contains objects of class CLUB, whichisdefinedasfollows: 3 class CLUB { int Mno; //Member Number char Mname [20]; //Member Name char Type;//Member Type:L Life Member M Monthly Member G Guest public: void Register();//Function to enter the content void Display(); //Function to display all data members char WhatType() {return Type;}. } ; 5. (a) What is the purpose of a key in a table? Give an example of a key in a table. 2 (b) Consider the following tables DRESS and MATERIAL. Write SQL commands for the statements (i) to (iv) and give outputs for SQL queries (v) to(viii). 6
  • 190.
    332 Table: DRESS Table: MATERIAL MCODETYPE MOOl TERELENE MOO2 COTTON MOO4 POLYESTER MOO3 SILK (i) To display DCODE and DESCRIPTION of each dress in ascending order of DCODE. (ii) TodisplaythedetailsofallthedresseswhichhaveLAUNCHDATEin between 05-DEC-07 and 20-JUN-08 (inclusive of both the dates). (iii) To display the average PRICE of all the dresses which are made up of material with MCODE as M003. (iv) TodisplaymaterialwisehighestandlowestpriceofdressesfromDRESS table. (Display MCODE of each dress along with highest and lowest price)
  • 191.
    333 (v) SELECTSUM(PRICE)FROMDRESSWHEREMCODE=‘M001’; (vi) SELECTDESCRIPTION, TYPE FROM DRESS, MATERIAL WHERE DRESS.DCODE = MATERIAL.MCODE AND DRESS.PRICE>=l250; (vii) SELECT MAX(MCODE) FROM MATERIAL; (viii) SELECT COUNT(DISTINCT PRICE) FROM DRESS; 6. (a) Stateandverifyabsorptionlawusingtruthtable. 2 (b) WritetheequivalentBooleanExpressionforthefollowingLogicCircuit: 2 (c) Write the POS form of a Boolean function G, which is represented in a truth tableasfollows: 1 (d) ReducethefollowingBooleanExpressionusingK-Map: 3 H(U,V,W,Z) = Σ(0, 1, 4, 5, 6, 7, 11, 12, 13, 14, 15)
  • 192.
    334 7. (a) Whatis the difference between LAN andWAN? 1 (b) Expandthefollowingabbreviations: 1 (i) HTTP (ii) ARPANET (c) What is protocol? Which protocol is used to copy a file from/to a remotely located server? 1 (d) Name two switching techniques used to transfer data between two terminals (computers). 1 (e) Eduminds University of India .is starting its first campus in a small town ParampurofCentralIndiawithitscenteradmissionofficeinDelhi.Theuniversity has3majorbuildingscomprisingofAdminBuilding,AcademicBuildingand Research Building in the 5 KM area Campus. As a network expert, you need to suggest the network plan as per (E1) to (E4) to the authorities keeping in mind the distances and other given parameters. ExpectedWiredistancesbetweenvariouslocations: ResearchBuildingtoAdminBuilding 90m ResearchBuildingtoAcademicBuilding 80m AcademicBuildingtoAdminBuilding 15m DelhiAdmissionOfficetoParampurCampus 1450 km Expected number of computers to be installed at various locations in the universityareasfollows:
  • 193.
    335 ResearchBuilding 20 AcademicBuilding 150 AdminBuilding35 DelhiAdmissionOffice 5 (E1) Suggest to the authorities, the cable layout amongst variousbuildings insidetheuniversitycampusforconnectingthebuildings. 1 (E2) Suggestthemostsuitableplace(i.e.building) to house the server of this organisation,withasuitablereason. 1 (E3) Suggestanefficientdevicefromthefollowingtobeinstalledineachof thebuildingstoconnectallthecomputers: 1 (i) GATEWAY (ii) MODEM (iii) SWITCH (E4) Suggest the most suitable (very high speed) service to provide data connectivity betweenAdmission Building located in Delhi and the campuslocatedinParampurfromthefollowingoptions: 1 Telephoneline Fixed-LineDial-upconnection Co-axial Cable Network GSM Leasedline SatelliteConnection
  • 194.
    336 Marking Scheme —Computer Science General Instructions : 1. TheanswersgiveninthemarkingschemeareSUGGESTIVE,Examinersarerequestedto awardmarksforallalternativecorrectSolutions/Answersconveyingthesimilarmeaning 2. All programming questions have to be answered with respect to. C++ Language only. 3. InC++,ignorecasesensitivityforidentifiers (Variable/Functions/Structures/ClassNames) 4. In SQL related questions - both ways of text/character entries should be acceptable for Example: “AMAR” and ‘amar’both are correct. 5. In SQL related questions - all date entries should be acceptable for Example: 'DD-Mon- YY', "DD/MM/YY", 'DD/MM/YY", 'DD/MM/YY', "MM/DD/YY", 'MM/DD/YY', and {MM/DD/YY} are correct. 6. InSQLrelatedquestions-semicolonshouldbeignoredforterminatingtheSQLstatements 7. InSQLrelatedquestions,ignorecasesensitivity. QUESTION PAPER CODE 91/1 EXPECTEDANSWERS 1. (a) What is the difference between call by value and call by reference? Give an exampleinC++toillustrateboth. 2 Ans Call by value is used to create a temporary copy of the data coming from the actualparameterintotheformalparameter.Thechangesdoneinthefunction informalparameterarenotreflectedbackinthecallingenvironment.Itdoes notuse‘&’sign. Call by reference is used to share the same memory location for actual and formal parameters and so changes done in the function are reflected back in thecallingenvironment.Ituses‘&’sign. void Compute(int A, int &B) { A++; B++;
  • 195.
    337 cout<<”In the function”<<endl; cout<<”A=”<<A<<“&”<<“B=”<<B<<endl; } voidmain () { int I=50,J=25; cout<<”Before function call “<<endl; cout<<”I=”<<I<<”&”<<”J=”<<J <<endl; Compute (I,J) ; cout<<”After function call “<<endl; cout<<I=”<<I<<”&”<<”J=”<<J <<endl; } OUTPUT Before function call I=50&J=25 In the function A=51&B=26 After function call I=50&J=26 (½MarkforeachcorrectexplanationofCallbyValueandCallbyReference) (½ Mark for each correct example of Call by Value and Call by Reference) OR (Full 2 Marks for correct examples demonstrating the difference between Call byValue and Call by Reference) OR (Only 1 Mark to be awarded if Explanation without supporting examples) Note:Outputisoptional (b) Writethenamesoftheheaderfilestowhichthefollowingbelong: 1 (i) puts ( ) (ii) sin ( )
  • 196.
    338 Ans (i) stdio.h(ii) math. h (½ Mark for writing each correct header file) (c) Rewritethefollowingprogramafterremovingthesyntacticalerrors(ifany). Underlineeachcorrection. 2 #include [iostream.h] #include [stdio.h] class Employee { int EmpId=901; char EName [20] ; public Employee(){} void Joining() {cin>>EmpId; gets (EName);} void List () {cout<<EmpId<<” : “<<EName<<endl;} }; void main () { Employee E; Joining.E(); E.List() } Ans #include <iostream.h> #include <stdio.h> class Employee { int EmpId; char EName[20]; public : Employee() {EmpId=901;} void Joining() {cin>>EmpId; gets (EName);} void List () {cout<<EmpId<<”: “<<EName<<endl;}
  • 197.
    339 }; void main () {Employee E; E.Joining (); E.List (); } (½ Mark for writing both header files inside < >) (½ Mark for removing = 901 from int Empld = 901;) (½Markforwriting:afterpublicand;afterE.List()) (½MarkforwritingE.Joining();correctly) Note: ½markforidentifyinganytwoerrorswithoutvalidcorrectionand1 markforidentifyingallfiveerrorswithoutvalidcorrection (d) Findtheoutputofthefollowingprogram: 3 #include<iostream.h> void main () { int X[] = {10,25,30,55,110}; int *p = X; while ( *p < 110) { if ( *P%3 != 0 ) *p=*p+1; else *p = *p + 2; p++; } for(int I = 4; I>=l ; I--) { cout << X[I] << “*" ; if ( I%3 == 0) cout<<endl;
  • 198.
    340 } cout<<X[0] * 3<<endl; } Ans1110*56* 32*26*33 (½ Mark for each correct value) (½ Mark for all correct endl and *) (e) Findtheoutputofthefollowingprogram: 2 #include <iostream.h> #include <ctype.h> void Encode (char Info [ ], int N) ; void main ( ) { char Memo [ ] = “Justnow” ; Encode (Memo, 2) ; cout<<Memo<<endl ; } void Encode (char Info [ ], int N) { for (int I = 0 ; Info[I] !=‘0’ ; 1++) if (1%2= =0) Info[I] = Info[I] –N ; else if (islower(Info[I])) Info[I] = toupper(Info[I]) ; else Info[I] = Info[I] +N ; } Ans HuqTlOu (½ Mark for writing H, U as the first two characters) (½ Mark for writing q, T as the next two characters)
  • 199.
    341 (½ Mark forwriting 1, O as the next two characters) (½ Mark for writing u as the last character) (f) Studythefollowingprogramandselectthepossibleoutputfromit: 2 #include <iostream.h> #include <stdlib.h> const int LIMIT = 4 ; void main ( ) { randomize( ) ; int Points; Points = 100 + random(LIMIT) ; for (int P=Points ; P>=100 ; P– –) cout<<P<<“#” ; cout<<endl; } (i) 103#102#101#100# (ii) 100#101#102#103# (iii) 100#101#102#103#104# (iv) 104#103#102#101#100# Ans (i) 103#102#101#100# (2 Marks for mentioning correct option) Note: No Marks to be awarded for any other answer 2. (a) What is copy constructor? Give an example in C++ to illustrate copy con- structor. 2 Ans A copy constructor is an overloaded constructor function in which (an) object(s) of the same class is/are passed as a reference parameter(s). It is used when an object’s data value is related to or is initialised using another object’sdatavalueofthesameclass.Intheexamplebelowthevaluesofdata
  • 200.
    342 members of objectQ are dependent on the values of data members of object P and Data members of object R dependent on Q. //Example of Copy Constructor class Play { int Count, Number; public: Play(); //constructor Play(Play &);//copy constructor void Disp(); void Change(int,int); }; Play::Play () //constructor { Count=0; Number=0; } Play:: Play (Play &P) //copy constructor { Count=P.Count+l0; Number=P.Number+20; } void Play::Disp() { cout<<Count; cout<<Number<<endl; } void Play::Change(int C,int N) { Count=C;
  • 201.
    343 Number=N; } void main () { PlayP; //Call for constructor P.Disp (); P.Change(90,80) ; Play Q(P); //Copy constructor call Q.Disp(); Play R=Q; //Copy constructor ca11 [same as P1ay R(Q);] R. Disp(); } (1 Mark for correct explanation of Copy Constructor) (1 Mark for a valid example of Copy Constructor) Note: Member function other than the constructors are optional (b) Answer the questions (i) and (ii) after going through the following class: class WORK 2 { int WorkId;char WorkType ; public: -WORK ( ) //Function 1 { cout<<”Un-Allocated”<<endl ;} void status ( ) //Function 2 { cout<<WorkId<<”: “<<WorkType<<endl ;} WORK ( ) //Function 3 { WorkId = 10; WorkType=’T’ ; } WORK(WORK &W) //Function 4 { WorkId=W. WorkId+12;WorkType=W. WorkType+l } } ;
  • 202.
    344 (i) WhichmemberfunctionoutofFunction1,Function2,Function3andFunction 4shownintheabovedefinitionofclassWORKiscalledautomatically,when the scopeof an object gets over? Is it known as Constructor OR Destructor OR Overloaded Function OR Copy Constructor? Ans Function1 Destructor. (½ Mark for naming Function 1 correctly) (½ Mark for naming it as Destructor, (ii) WORK W; // Statement 1 WORK Y(W); // Statement 2 WhichmemberfunctionoutofFunction1,Function2,Function3andFunction 4shownintheabovedefinitionofclassWORKwillbecalledonexecutionof statementwrittenasstatement2?Whatisthisfunctionspecificallyknownas out of Destructor or Copy Constructor or Default Constructor? Ans Function4 Copy Constructor. (½ Mark for naming Function 4 correctly) (½ Mark for naming it as Copy Constructor) (c) DefineaclassRESORTinC++withfollowingdescription: 4 PrivateMembers Rno //Data member to store Room No Name //Data member to store customer name Charges //Data member to store per day charges Days //Data member to store number of days of stay COMPUTE( ) //A function to calculate’ and return Amount as Days*Charges and if the value of Days*Charges is more than 11000 then as 1.02*Days*Charges PublicMembers Getinfo() //A function to enter the content Rno, Name, //Charges and Days
  • 203.
    345 Dispinfo() //A functionto display Rno, Name, Charges, //Days andAmount (Amount to be displayed by //calling function COMPUTE ( ) ) Ans class RESORT { int Rno; char Name [20]; float Charges; int Days; float COMPUTE(); public: void Getinfo() ; void Dispinfo(); }; void RESORT::Getinfo() { cin>>Rno; gets (Name); cin>>Charges; cin>>Days; } void RESORT::Dispinfo() { cout<<Rno<<” “<<Name<<“ “<<Charges<<” “<<Days<< COMPUTE()<<endl; } float RESORT::COMPUTE(} { float Amount = Charges*Days; if (Amount>11000)
  • 204.
    346 Amount = 1.02*Days*Charges; returnAmount; } (½ Mark for correct syntax for class header) (½ Mark for correct declaration of data members) (1 Mark for correct definition of COMPUTE ( )) . (1 Mark for correct definition of Dispinfo( ) with proper invocation of COMPUTEOfunction) (1 Mark for correct definition of Getinfo( )) NOTE: Deduct ½ Mark if COMPUTE( ) is not invoked properly inside Dispinfo()function (d) Answerthequestions(i)to(iv)basedonthefollowing: 4 class FaceToFace { char CenterCode [10] ; public: void Input ( ) ; void Output ( ) ; } ; class Online { char website [50] ; public: void SiteIn ( ) ; void SiteOut ( ) ; } ; class Training: public FaceToFace, private Online { long Tcode ; float charge;
  • 205.
    347 int period; public: void Register( ) ; void Show ( ) ; } ; (i) WhichtypeofInheritanceisshownintheaboveexample? Ans MultipleInheritance (1Markformentioningcorrectinheritancetype) ii) WritenamesofallthememberfunctionsaccessiblefromShow()functionof classTraining. Ans Register() Siteln( ). SiteOut( ). Input( ), Output( ) (1 Mark for correct answer) Note: No marks to be awarded for any other alternative answer iii) WritenameofallthemembersaccessiblethroughanobjectofclassTraining. Ans Register( ), Show( ), Input( ), Output( ) (1 Mark for correct answer) Note: No marks to be awarded for any other alternative answer iv) IsthefunctionOutput()accessibleinsidethefunctionSiteOut()?Justifyyour answer. Ans No,functionOutput()isnotaccessibleinsidethefunctionSiteOut(),because Output( ) is a member of class FaceToFace and SiteOut( ) is a member of class Online. and the classes FaceToFace and Online are two independent classes. ( ½ Mark for mentioning NOTACCESSIBLE correctly) ( ½ Mark for correct justification) OR (1MarkifYESissupportedwithvalidjustificationthatthefunctionInRegular()
  • 206.
    348 is accessible insidethe function InDistance( ) ONLYfor an object of the derived class OR in contextofInheritance) NOTE: No mark to be awarded if onlyYES is written without any justification. 3. (a) Write a function SORTPOINTS( ) in C++ to sort an array of structure Game in descending order of Points using Bubble Sort. 3 Note:AssumethefollowingdefinitionofstructureGame struct Game { long PNo; //Player Number char PName [20] ; long Points; } ; Sample content of the array (before sorting) PNo PName Points 103 RitikaKapur 3001 104 JohnPhilip 2819 101 RaziaAbbas 3451 105 TarunKumar 2971 Sample content of the array (after sorting) PNo PName Points 101 RaziaAbbas 3451 103 Ri tika Kapur 3001 105 TarunKumar 2971 104 JohnPhilip 2819 Ans void SORTPOINTS(Game G[], int N) { Game Temp;
  • 207.
    349 for (int I= 0; I<N-l; I++) for (int J = 0; J<N-I-l; J++) if(G[J].Points < G[J+l].Points) { Temp = G[J]; G[J] = G[J+l]; G[J+l] = Temp; } { OR Anyothercorrectequivalentfunctiondefinition ( ½ Mark for correct Function Header) ( ½ Mark for each correct loop) ( 1 Mark for correct comparison of adjacent elements) ( ½ Mark for swapping the values correctly) Note: Deduct ½ Mark if sorted in ascending order instead of descending order Deduct ½ Mark if only Points is swapped instead of the whole Structure Deduct ½ Mark ifTemp is not declared with correct data type (b) An array S[40][30]isstoredinthememoryalongthecolumnwith each of the element occupying 4 bytes, find out the base address and address of element S[20][15], if an element S[15][10] is stored at the memory location 7200. 4 Ans Loc(S[I][J]) = Base(S)+W(I+J*N) Loc(S[15][10]) = Base(S)+4(15+10*40) Base(S) = 7200-4*415 Base(S) = 7200-1660 Base(S) = 5540 Loc(S[20][15]) = Base(S)+4(20+15*40) Loc(S[20][15]) = 5540 + 4(20+15*40) = 5540 + 4(20+600)
  • 208.
    350 = 5540 +4*620 = 5540 + 2480 = 8020 OR Address of S[i][j]=BaseAddress + W[(i-L1) + ( j - L2) *M] Address of S[15] [10] = BaseAddress+ 4[(15–0)+(10 - 0)*40] 7200= Base Address + 4 [415] Base Address = 7200 - 4 * 415 = 7200 - 1660 = 5540 Address of S[20][15]= 5540 + 4 [(20 - 0) + (15 - 0) x 40] = 5540 + 4 x 620 = 5540 + 2480 = 8020 OR Address of Sri] [j] along the column = Base Address + W [( i - L1) + (j - L2) * M] Address of S[15)[10] = BaseAddress + 4[(15 - 1)+(10-1) x 40] 7200= Base Address + 4 [374] Base Address = 7200 - 4 x 374 = 7200 - 1496 = 5704 Address of 5[20)[15] = 5704 + 4 [(20 - 1) + (15 - 1) x 40] = 5704 + 4 x 579 = 5704 + 2316 = 8020 (1Markforwritingcorrectformula(forcolumnmajor)ORsubstitutingformula with correct values for calculating correct BaseAddress) (1 Mark for calculating correct BasgAddress)
  • 209.
    351 (1 Mark forwriting correct formula/correct substituted values, for column major properly, for calculatingAddress of 5[20][15]) (1 Mark for calculating correct address of 5[20][15]) (c) Write a function QUEINS( ) in C++ to insert an element in a dynamically allocatedQueuecontainingnodesofthefollowinggivenstructure: 4 struct Node { int PId ; //Product Id char Pname [20] ; NODE *Next ; } ; Ans class Queue { Node *Front, *Rear; public: QUEUE() //Constructor to initia1ize Front and Rear { Front = NULL; Rear = NULL; } void QUEINS(); //Function to insert a node void QUEDEL(); //Function to de1.ete a node void QUEDISP(); //Function to disp1ay nodes ~Queue(); //Destructor to de1ete a11 nodes } ; void Queue::QUEINS( ) { Node *Temp; Temp = new Node; cin>>Temp->PId;
  • 210.
    352 gets(Temp->Pname); //Or cin>>Temp->Pname; //cin.get1ine(Temp->Pname); Temp->Next= NULL; if (Rear = = NULL) { Front = Temp; Rear = Temp; } e1se } Rear->Next = Temp; Rear = Temp; } } OR void QUEINS (Node *&Front, Node *&Rear) { Node *Temp = new Node; cin>>Temp->PId; gets (Temp->Pname); //or cin>>Temp->Pname; //cin.get1ine(Temp->Pname); Temp->Next = NULL; if(Rear == NULL) Front = Temp; e1se Rear -> Next = Temp; Rear = Temp; } (1 Mark for creating Node dynamcally) (½ Mark for input / assigning Pld, Pname)
  • 211.
    353 (½ Mark forassigning NULLtoTemp->Next) (½ Mark for checking Empty Queue) (½ Mark for assigning Front withTemp in case of empty queue) (½ Mark for assigning Rear ->Next withTemp when queue is not empty) (½ Mark for assigning RearwithTemp) (d) DefineafunctionSWAPCOL()inC++toswap(interchange)thefirstcolumn elements with the last column elements, for a two dimensional integer array passed as the argument of the function. 3 Example:Ifthetwodimensionalarraycontains 2 1 4 9 1 3 7 7 5 8 6 3 7 2 1 2 After swapping of the content of 1st column and last column, it should be : 9 1 4 2 7 3 7 1 3 8 6 5 2 2 1 7 Ans void SWAPCOL(int A[][100], int M, int N) { int Temp, I; for(I=O; I<M; I++) { Temp = A [I][0] ; A[I][0] = A[I][N-l]; A[I][N-l] = Temp; } }
  • 212.
    354 OR void SWAPCOL(int A[4][4]) { intTemp, I; for(I=O; I<4; I++) { Temp = A[I][0]; A[I][0] = A[I][3]; A[I][3] = Temp; } } OR Anyothercorrectequivalentfunctiondefinition. (1 Mark for correct function header) (1 Mark for correct loop) (1Markforswappingthefirstcolumnwithlastcolumncorrectly) (e) Convert the following infix expression to its equivalent postfix expression showingstackcontentsfortheconversion: 2 X–Y /(Z + U) * V Ans X - Y / (Z + U) * v = (X - ((Y / (Z + U)) * v)) Element Scanned Stack Postfix ( X X - - ( ( Y XY / -/ (
  • 213.
    355 Z XYZ + -/+ UXYZU ) -/ XYZU+ ) - XYZU+/ * -* V XYZU+/V ) - XYZU+/V* ) XYZU+/V*- OR Element Scanned Stack Postfix ( ( X ( X - (- X Y (- XY / (-/ XY ( (-/( XY Z (-/( XYZ + (-/(+ XYZ U (-/(+ XYZU ) (-/ XYZU+ * (-* XYZU+/ V (-* XYZU+/V ) XYZU+/V*- OR Any other method for converting the given infix expression to its equivalent postfixexpressionshowingtheStackStatus. (½ Mark for correctly converting expression up to each operator (1 Mark only to be given for writing correct answer without showing the Stack Status) 4. (a) Observe the program segment given below carefully and fill in the blanks markedasLine1andLine2usingfstreamfunctionsforperformingthere- quired task. 1
  • 214.
    356 #include <fstream.h> class Stock { longIno ; //Item Number char Item [20] ;//Item Name int Qty ; //Quantity public: void Get(int) ;//Function to enter the content void show ( ) ;//Function to display the content void Purchase (int Tqty) { Qty + = Tqty ; } //Function to increment in Qty long KnowIno ( ) {return Ino ;} } ; void Purchaseitem (long PINo, int PQty) //PINo -> Ino of the item purchased //PQty -> Number of item purchased { fstream File; File.open(“ITEMS.DAT”, ios :: binarylios :: inlios :: out); int Pos = –1 ; Stock S ; while (Pos = = –1 && File.read((char*) &S, sizeof (S))) if (S. KnowIno( ) ==PINo) { S. Purchase (PQty); //To update the number of Items Pos = File.tellg ( ) -sizeof (S) ;
  • 215.
    357 //Line 1: Toplace the file pointer to the required position _____________________________________; //Line 2: To write the object S on to the binary file _____________________________________; } if (Pos = = –1) cout<<“No updation done as required Ino not found..” ; File.close ( ) ; } Ans Statement1: File.seekp(Pos); OR File.seekp(-sizeof(A), ios:: cur); OR File.seekg(Pos); //Not advisable OR File.seekg(-sizeof (A), ios:: cur);//Not advisable OR Anyequivalentcorrectmethod Statement2: File.write((char*)&S, sizeof(S)); OR File.write((char*)&S, sizeof(Stock)); OR Anyequivalentcorrectmethod (½ Mark for each correct Statement) (b) Write a function COUNT_DO( ) in C++ to count the presence of a word ‘do’inatextfile“MEMO.TXT” 2
  • 216.
    358 Example: Ifthecontentofthefile“MEMO.TXT”isasfollows: I will doit, if you request me to do it. It would have been done much earlier. ThefunctionCOUNT_DO()willdisplaythefollowingmessage: Count of -do- in file : 2 Note: In the above example, ‘do’ occurring as a part of word done is not considered. Ans void COUNT_DO () { ifstream Fi1; Fil.open(“MEMO.TXT”); char Word[80]; int Count =0; while(!Fil.eof()) { Fil>>Word; if (strcmp (Word, “do”) ==0) Count++; } cout<<”Count of -do- in file:”<<Count; Fil.close(); //Ignore } OR void COUNT_TO () { ifstream Fi1(“MEMO.TXT”); //OR fstream Fi1; OR ifstream Fil(“MEMO.TXT”);   
  • 217.
    359 //Fi1.open (“NOTES. TXT”,ios::in); char. STR[10]; int c=0; whi1e(Fi1.qet1ine(STR,10, ‘ ‘)) { if (strcmpi (STR, “to”) =0) c++; } Fi1.c1ose();//Ignore cout<<”Count of -to- in file : “<<c<<end1; } OR void COUNT_DO () { ifstream Fi1; Fil.open(“MEMO.TXT”); char Word[80],Ch; int Count =0, I=0; while(Fi1.get(Ch)) { if (Ch! = ‘ ‘) Word[I++] = Ch; else { Word[I] = ‘0’; if (strcmp (Word, “do”) ==0) Count++; I=O; } } OR ifstream Fil(“MEMO.TXT”);   
  • 218.
    360 cout<<”Count of -do-in file:”<<Count; Fil.close(); //Ignore } OR Anyothercorrectfunctiondefinition (½ Mark for opening MEMO. TXT correctly) (½ Mark for reading each word (Whichever method adopted) from the file) (½ Mark for comparing the word with ‘do’ and incrementing counter) (½ Mark for displaying the number of ‘do’with/without theText Message) (c) Write a function in C++ to read and display the detail of all the users whose statusis‘A’(i.e.Active)fromabinaryfile“USER.DAT”.Assumingthebinary file “USER.DAT” is containing objects of class USER, which is definedas follows: 3 class USER { int Uid ; //User Id char Uname [20];//User Name char Status; //User Type: A Active I Inactive Public: void Register ( ) ;//Function to enter the content void show ( ) ; //Function to display all data members char Getstatus ( ) {return Status;}. } ; Ans void DisplayActive () { USER U; ifstream fin; fin.open (“USER.DAT”, ios::binary); OR ifstream fin (“USER.DAT”, ios::binary);
  • 219.
    361 while(fin.read((char*)&U, sizeof(U))) { if(U.Getstatus()==’A’) U.show(); } fin.close(); //Ignore } OR voidDisplayActive() { USER U; ifstream fin; fin.open (“USER.DAT”, ios::binary); OR ifstream fin (“USER.DAT”, ios::binary); if (fin) { fin.read((char*)&U, sizeof(U)); while(!fin.eof()) { if (U.Getstatus()==’A’) U.show() ; fin.read((char*)&U, sizeof(U)) } fin.close(); //Ignore } (½ Mark for opening USER.DATcorrectly) (½ Mark for reading each record from USER.DAT) (½ Mark for correct loop / checking end of file) (1 Mark for comparing value returned by Getstatus( ) with ‘A’) (½Markfordisplayingthematchingrecord)
  • 220.
    362 5. (a) Whatare candidate keys in a table? Give a suitable example of candidate keys in a table. 2 Ans Atablemayhavemorethanonesuchattribute/groupofattributethatidentifies a tuple uniquely, all such attribute(s) are known as Candidate Keys. Table:Item Ino Item Qty I01 Pen 560 I02 Pencil 780 I04 CD 450 I09 Floppy 700 I05 Eraser 300 I03 Duster 200 (1 Mark for writing correct definition of Candidate Key) (1Markforgivingsuitableexample) OR (2MarksforillustratingCandidateKeywith/withoutshowingitasapartof aTable) (b) Consider the following tables GARMENT and FABRIC. Write SQL commands for the statements (i) to (iv) and give outputs for SQL queries (v)to(viii) 6 Table: GARMENT
  • 221.
    363 Table : FABRIC FCODETYPE F04 POLYSTER F02 COTTON F03 SILK F01 TERELENE (i) TodisplayGCODEandDESCRIPTIONofeachGARMENTindescending order of GCODE Ans SELECT GeODE, DESCRIPTION FROM GARMENT ORDER BY GCODE DESC; (1 Mark for correct query) (½ Mark for partially correct answer) (ii) TodisplaythedetailsofalltheGARMENTs,whichhaveREADYDATEin between 08-DEC-07 and 16-JUN-08(inclusive of both the dates). Ans SELECT * FROM GARMENT WHERE READYDATE BETWEEN’ 08- DEC-07’ AND , 16-JUN-08’ ; OR SELECT * FROM DRESS WHERE LAUNCHDATE >= ‘08-DEC-07’ AND LAUNCHDATE<=’16-JUN-08’; (1 Mark for correct query) (½ Mark for partially correct answer) (iii) To displaytheaveragePRICEofalltheGARMENTs,whicharemadeupof FABRIC with FCODE as F03. Ans SELECT AVG (PRICE) FROM GARMENT WHERE FCODE = ‘F03’; (1 Mark for correct query) (½ Mark for partially correct answer) (iv) To display FABRIC wise highest and lowest price of GARMENTs from GARMENTtable.(DisplayFCODEofeachGARMENTalongwithhighest and lowest price) Ans SELECT FCODE, MAX (PRICE), MIN(PRICE) FROM GARMENT GROUP BY FCODE;
  • 222.
    364 (1 Mark forcorrect query) (½ Mark for partially correct answer) (v) SELECT SUM (PRICE) FROM GARMENT WHERE FCODE = ‘F01’ ; Ans SUM (PRICE) 26:10 (½ Mark for correct output) (vi) SELECTDESCRIPTION, TYPE FROM GARMENT, FABRICWHERE GARMENT.FCODE = FABRIC.FCODEAND GARMENT. PRICE > = 1260 ; Ans DESCRIPTION TYPE INFORMAL SHIRT COTTON INFORMAL PANT COTTON FORMAL PANT TERELENE (½ Mark for correct output) (vii) SELECT MAX (FCODE) FROM FABRIC; Ans MAX (FCODE) F04 (½ Mark for correct output) (viii) SELECT COUNT (DISTINCT PRICE) FROM GARMENT ; Ans COUNT(DISTINCT PRICE) 7 (½ Mark for correct output) 6. (a) Verify X’Y+ X.Y’+ X’Y’= (X’+Y’) using truth table. 2 Ans VERIFIED (1 Mark for drawing the truth table with correct inputs) (1 Mark for deriving LHS values = RHS values)
  • 223.
    365 (b) WritetheequivalentBooleanExpressionforthefollowingLogicCircuit: 2 Ans(x+Y’) . (X’ +Z) (2 Marks for the final expression (x+Y’). (X’ +Z)) OR (1 Mark for any of the correct terms out of (X+Y’) or (X’ +Z) ) (c) Write the POS form of a Boolean function H, which is represented in a truth tableasfollows: 1 Ans (A+B+C).(A’+B+C’).(A’+B’+C) OR H(A,B,C) = n (0, 5, 6) (1 Mark for the correct POS form) Note: Deduct ½ mark if wrong variable names are used (d) ReducethefollowingBooleanExpressionusingK-Map: 3 F(P, Q, R, S) = Σ(1, 2, 3, 5,6, 7, 9, 11, 12, 13, 15) Ans
  • 224.
    366 F (P,Q,R,S =PQR’+R+ P’R ( ½ Mark for placing aU1 s at correct positions in K-Map) ( ½ Mark for each grouping) (1Markforwritingfinalexpressioninreduced/minimalform) Note: Deduct ½ mark if wrong variable names are used 7. (a) What is difference between StarTopology and BusTopology of network? 1 Ans BusTopology:Itischaracterisedbycommontransmissionmediumsharedby all the connected hosts, managed by dedicated nodes. It offers simultaneous flow of data and control. StarTopology:Itischaracterisedbycentralswitchingnode(communication controller)anduniquepath(pointtopointlink)foreachhost.Itiseasytoadd andremoveadditionalhostsbyupgradingthecentralisednode (1Markforcorrectdifference,eitherTextualorDiagrammatical) OR (½MarkforcorrectTextual/DiagrammaticalexplanationofeitherBusor StarTopology (b) Expandthefollowingabbreviations: 1 (i) GSM (ii) CDMA Ans (i) GlobalSystemforMobileCommunication (ii) CodeDivisionMultipleAccess ( ½ Mark tor correct expansion of GSM) ( ½ Mark for correct expansion of CDMA)
  • 225.
    367 (c) What isprotocol? Which protocol is used to search information from internet usinganinternetbrowser? 1 Ans A protocol is the set of rules for governing communication between two communication devices. It also infers documentation, negotiations and establishmentofrules. Protocolusedtosearchinformationfrominternetusinganinternetbrowseris: TCP/IP OR HTTP (½Markforexplainingprotocolcorrectly) (½ Mark for TCP/IP or HTTP) (d) Name two switching techniques used to transfer data between two terminals (computers ). 1 Ans MessageSwitchingandPacketSwitching OR CircuitSwitchingandMessageSwitching OR CircuitSwitchingandPacketSwitching (½Markforfirstswitchingtechnique) (½Markforsecondswitchingtechnique) (e) Freshminds University of India is starting its first campus inAna Nagar of South India with its center admission office in Kolkata. The university has 3 major blocks comprising of Office Block, Science Block and Commerce Block in the 5 KM area Campus. As a network expert, you need to suggest the network plan as per (El) to (E4)totheauthoritieskeepinginmindthedistanceandothergivenparameters.
  • 226.
    368 ExpectedWiredistancesbetweenvariouslocations: Office Block toScience Block 90 m Office Block to Commerce Block 80 m Science Block to Commerce Block 15 m KolkataAdmission office toAna Nagar Campus 2450 km Expected number of Computers to be installed’ at various locations in the Universityareasfollows: Office Block 10 Science Block 140 Commerce Block 30 KolkataAdmission office 8 (E1) Suggest the authorities, the cable layout amongst various blocks inside universitycampusforconnectingtheblocks. 1 Ans (1 Mark for mentioning any valid connectivity or topology or diagram connectingvariousblocksinsideuniversitycampus) (E2) Suggest the most suitable place (i.e. block) to house the server of this universitywithasuitablereason. 1 Ans ScienceBlockasitcontainsmaximumnumberofcomputere. (½Markformentioningtheblock) (½ Mark for correct reason) Note: 1 mark if Commerce Block is written with valid justification eg. Minimumwiringneeded (E3) Suggestanefficientdevicefromthefollowingtobeinstalledineachofthe blocks to connect all the computers: 1 (i) MODEM
  • 227.
    369 (ii) SWITCH (iii) GATEWAY AnsSWITCH ( 1 Mark for correct device) (E4) Suggest the most suitable. (very high speed) service to provide data con- nectivity betweenAdmission Office located in Kolkata and the campus locatedinAnaNagarfromthefollowingoptions: 1 Telephoneline Fixed-LineDial-upconnection Co-axial Cable Network GSM Leasedline SatelliteConnection Ans SatelliteConnection OR Leasedline (1 Mark for correct service name) QUESTION PAPER CODE 91 EXPECTEDANSWERS 1. (a) What is the difference betweenActual Parameter and Formal Parameter? Give an example in C++ to illustrate both types of parameters. 2 Ans AparameterusedinthefunctioncallisknownasActualParameter.Itisused to send the data to function. AparameterusedinthefunctiondefinitionisknownasFormalParameter,It is used to accept the data from actual parameter. void Seventimes(int A)//A is formal parameter { cout<<7*A; }
  • 228.
    370 void main () { intP=6; Seventimes(P);//p is actual parameter } (½ Mark for each correct explanation of Actual Parameter and Formal Parameter) (½ Mark for each correct example of Actual Parameter and Formal Parameter) OR (Full 2 Marks for correct examples demonstrating the difference between Actual Parameter and Formal Parameter) OR (Only 1 Mark to be awarded for Explanation given without supporting examples) (b) Writethenamesoftheheaderfilestowhichthefollowingbelong: 1 (i) setw( ) (ii) sqrt( ) Ans (i) iomanip.h (ii) math.h (½ Mark for writing each correct header file) (c) Rewritethefollowingprogramafterremovingthesyntacticalerrors(ifany). Underlineeachcorrection. 2 include <iostream.h> include <stdio.h> class MyStudent { int StudentId = 1001; char Name [20] ; public MyStudent( ){ }
  • 229.
    371 void Register () {cin>>StudentId; gets (Name) ;} void Display ( ) {cout<<StudentId<< “:” <<Name<<end1;} } ; void main ( ) { MyStudent MS ; Register.MS( ) ; MS.Display( ) ; } Ans # include <iostream.h> # include <stdio.h> class MyStudent { int StudentId; char Name[20]; public : MyStudent() {StudentId = 1001;} void Register(){ cin>>StudentId; gets (Name);} void Display () {cout«StudentId<<”:“<<Name<<endl;} }; void main () { MyStudent MS; MS. Register (); MS. Display () ; } (½Markforwritingbothincludeas#include) (½ Mark for removing = 1001 from int StudentId = 1001;) (½Markforwriting:afterpublic) (½ Mark for writing MS. Register ( ) ; correctly) Note: ½ mark for identifying any two errors without valid correction and 1markforidentifyingallfiveerrorswithoutvalidcorrection
  • 230.
    372 (d) Findtheoutputofthefollowingprogram: 3 #include<iostream.h> voidmain ( ) { int A[ ] = {10, 15, 20, 25, 30} int *p = A; while (*p < 30) { if (*p%3 ! = 0) *p = *p + 2 ; else *p = *p + 1; p++; } for (int J = 0; J<=4; J++) { cout << A[J] << “*” ; if ( J%3 = = 0) cout<<end1; } Cout<<A[4] * 3<<end1; } Ans 12* 16*22*27* 30*90 (1 Mark for each line with correct values) Note: Deduct½Markifany/all‘*’missing Deduct ½ Mark if endl is not considered at the right positions (e) Findtheoutputofthefollowingprogram: 2 #include <iostream.h> #include <ctype.h>
  • 231.
    373 void Secret (charMig[ ], int N); void main ( ) { char SMS[ ] = “rEPorTmE” ; Secret{SMS,2); cout<<SMS<<end1; } void Secret(char Msg[ ], int N) { for (int C=0; Msg[C] !=’ 0' ;C++) if (C%2==0) Msg[C] = Msg[C]+N; else if (isupper(Msg[C])) Msg[C] = tolower(Msg[C]); else Msg[C] = Msg[C]-N; } Ans teRmttoe (½ Mark for writing t,e as the first two characters) (½ Mark for writing R,m as the next two characters) (½ Mark for writing t,t as the next two characters) (½ Mark for writing o,e as the next two characters) (f) Studythefollowingprogramandselectthepossibleoutputfromit: 2 #include <iostream.h> #include <stdlib.h> const int MAX=3 ; void main ( ) { randomize( ) ; int Number ;
  • 232.
    374 Number = 50+ random{MAX) ; for (int P=Number; P>=50; P– –) cout<<p<< “ # ” ; cout<<endl; } (i) 53#52#51#50# (ii) 50#51#52# (iii) 50#51# (iv) 51#50# Ans (iv) 51#50# (2 Marks for mentioning correct option) Note: No Marks to be awarded for any other answer 2. (a) Whatisfunctionoverloading?GiveanexampleinC++toillustratefunction overloading. 2 Ans Function overloading is an example of polymorphism, where the functions havingsamenamewithdifferentsetofparametersperformdifferentoperations. OR Whenafunctionishavingmorethanonedefinitionanddifferentiablebythe number/typeofparametersisknownasfunctionoverloading Example: void Disp() //Function 1 { cout<<”Hello”<<endl; } void Disp(int N) // Function 2 { for (int I=1;I<=N;I++) cout<<I<<end1; }
  • 233.
    375 void main () { intx=5; Disp(x);//call for Function 2 - Prints numbers from 1 to 5 Disp(); //call for Function 1 - Prints Hello } (1MarkforcorrectdefinitionorexplanationofFunctionOverloading) (1 Mark for a valid example of Function Overloading) (b) Answerthequestions(i)and(ii)aftergoingthroughthefollowingclass: 2 class Job { int JobId;char JobType; public: ~Job ( ) //Function 1 { cout<< “Resigned” <<end1; } Job ( ) //Function 2 { JobId=10 ; JobType =‘T” ;} void TellMe( )//Function 3 { cout<<JobId<< “: ” <<JobType<<end1; } Job (Job &J) //Function 4 { JobId=J.JobId+10; JobType=J.JobType+l; } }; (i) WhichmemberfunctionoutofFunction1,Function2,Function3andFunction 4shownintheabovedefinitionofclassJobiscalledautomatically,whenthe scope of an object gets over? Is it known as Constructor OR Destructor OR Overloaded Function OR Copy Constructor?
  • 234.
    376 Ans Function1. Destructor. (½Markformentioningthecorrectfunction) ( ½Mark for identifying it as Destructor) (ii) Job P ; //Line 1 Job Q(P) ; //Line 2 WhichmemberfunctionoutofFunction1,Function2,Function3andFunction 4 shown in the above definition of class Job will be called on execution of statementwrittenasLine2?Whatisthisfunctionspecificallyknownasoutof Destructor or Copy Constructor or Default Constructor? Ans Function4. Copy Constructor. (½Markformentioningthecorrectfunction) ( ½ Mark for identifying it as Copy constructor) (c) DefineaclassHOTELinC++withthefollowingdescription: 4 PrivateMembers: Rno //Data member to store Room No Name //Data member to store customer name Tariff //Data member to store per day charges NOD //Data member to store number of days of stay CALC( ) //Afunction to calculate and returnAmount as NOD*Tariff and if the value of NOD*Tariff is more than 10000 then as 1.05*NOD*Tariff PublicMembers Checkin ( ) / /Afunction to enter the content Rno, Name, / / Tariff and NOD Checkout( ) / /Afunction to display Rno, Name, Tariff, / /NOD andAmount (Amount to be displayed by //callingfunctionCALC())
  • 235.
    377 Ans class HOTEL { intRno; char Name[20]; float Tariff; int NOD; float CALC() ; public: void Checkin() ; void Checkout() ; } ; float HOTEL::CALC() { float Amount = Tariff*NOD; if (Amount>10000) Amount = 1.05*NOD*Tariff; return Amount; } void HOTEL::Checkin() { cin>>Rno; gets (Name); cin>>Tariff; cin>>NOD; } void HOTEL::Checkout() { cout<<Rno<<” “<<Name<<“ “<<Tariff<<” “<<NOD<< CALC ()<<endl; }
  • 236.
    378 (½ Mark forcorrect syntax for class header) (½ Mark for correct declaration of data members) (1 Mark for correct definition of CALC( )) (1 Mark for correct definition of Checkout( ) with proper invocation of CALC()function) (1 Mark for correct definition of Checkin()) NOTE:Deduct½MarkifCALC()isnotinvokedproperlyinsideCheckout() function (d) Answerthequestions(i)to(iv)basedonthefollowing: 4 class Regular { char SchoolCode[10]; public: void InRegular( ); void OutRegular( ); } ; class Distance { char StudyCentreCode [5] ; public: void InDistance( ); void OutDistance( ); } ; class Course: public Regular, private Distance { char Code [ 5] ; float Fees; int Duration; public: void InCourse( ); void OutCourse( ); } ;
  • 237.
    379 (i) WhichtypeofInheritanceisshownintheaboveexample? Ans MultipleInheritance (1Markformentioningcorrecttypeofinheritance) (ii)WritenamesofallthememberfunctionsaccessiblefromOutCoursefunction of class Course. Ans InCourse( ), InDistance( ), OutDistance( ), InRegular(),OutRegular() (1 Mark for correct answer) Note: No marks to be awarded for any other alternative answer (iii) Writenameofallthe.:membersaccessiblethrougbanobjectofclassCourse. Ans InCourse( ), OutCourse( ), InRegular(),OutRegular() (1 Mark for correct answer) Note: No marks to be awarded for any other alternative answer (iv) IsthefunctionInRegular()accessibleinsidethefunctionInDistance()?Justify youranswer. Ans No, function InRegular( ) is not accessible inside the function InDistance( ), because InRegular( ) is a member of class Regular and InDistance( ) is a member of class Distance, and the classes Regular and Distance are two independentclasses. (½ Mark for mentioning NOTACCESSIBLE correctly) (½ Mark for correct justification) OR (1 Mark if YES is supported with valid justification that the function InRegular()isaccessibleinsidethefunctionInDistance(}ONLYforanobject of the derived class OR in context of Inheritance} NOTE:NomarktobeawardedifonlyYESiswrittenwithoutanyjustification. 3. (a) WriteafunctionSORTSCORE()inC++tosortanarrayofstructureExaminee in descending order of Score using Bubble Sort. 3
  • 238.
    380 Note:AssumethefollowingdefinitionofstructureExaminee struct Examinee { long RollNo; charName[20] ; float Score; } ; Sample Content of the array (before sorting) Sample Content of the array (after sorting) I Ans void SORTSOORE (Examinee E[ ], int N) { Examinee Temp; for (int I = 0; I<N-l; I++) for (int J = 0; J<N-I-l; J++) if(E[J].Score < E[J+l].Score) {
  • 239.
    381 Temp = E[J]; E[J]= E[J+l]; E[J+l] = Temp; } } OR Anyothercorrectequivalentfunctiondefinition ( ½ Mark for correct Function Header) ( ½ Mark for each correct loop) ( 1 Mark for correct comparison of adjacent elements) ( ½ Mark for swapping the values correctly) Note: Deduct ½ Mark if sorted in ascending order instead of descending order Deduct ½ Mark if only Score is swapped instead of the whole Structure Deduct ½ Mark ifTemp is not declared with correct data type (b) An array T[50][20] is stored in the memory along the column with each of the elements occupying 4 bytes. Find out the base address and address of element T[30][15], if an element T[25][10] is stored at the memory location 9800. 4 Ans Loc(T[I][J]) = Base(T)+W(I+J*N) Loc(T[25][10]) = Base(T)+4(25+10*50) Base(T) = 9800-4*525 Base(T) = 9800-2100 Base(T) = 7700 Loc(T[30][15]) = Base(T)+4(30+15*50) Loc(T[30][15]) = 7700 + 4(30+15*50) = 7700 + 4(30+750) = 7700 + 4*780 = 7700 + 3120 = 10820
  • 240.
    382 OR Address of T[i][j]=BaseAddress+ W [(i - L1) + (j - L2) * M] Address of T[25] [10] = BaseAddress + 4[(25 - 0)+(10 - 0)*50] 9800 = Base Address + 4 [525] Base Address = 9800 - 4 * 525 = 9800 - 21.00 = 7700 Address of T[30][15]= 7700 + 4 [(30 - 0) + (15 - 0) x 50] = 7700 + 4 x 780 = 7700 + 3120 = 10820 OR Address of T[i][j] along the column = Base Address + W [( i - L1) + (j - L2) * M] Address of T[25][10]=BaseAddress + 4[(25 - 1) +(10 -1) x 50] 9800= Base Address + 4 [474] Base Address = 9800 - 4 x 474 = 9800 - 1896 = 7904 Address of T[30][15] = 7904 + 4 [(30 - 1) + (15 - 1) x 50] = 7904 + 4 x 729 = 7904 + 2916 = 10820 (1Markforwritingcorrectformula(forcolumnmajor)ORsubstitutingformula with correct values for calculating correct BaseAddress) (1 Mark for calculating correct BaseAddress) (1Markforwritingcorrectformula(forcolumnmajor)ORsubstitutingformula with correct values for calculatingAddress ofT[30][15]) (1 Mark for calculating correct address of T[30][15])
  • 241.
    383 (c) Write afunction QUEDEL( ) in C++ to display and delete an element from a dynamically allocated Queue containing nodes of the following given structure: 4 struct NODE { int Itemno; char Itemname[20]; NODE *Link; } ; Ans class Queue { Node *Front, *Rear; public: QUEUE() //Constructor to initialize Front and Rear { Front = NULL; Rear = NULL; } void QUEINS(); //Function to insert a node void QUEDEL(); //Function to delete a node void QUEDISP(); //Function to display nodes ~Queue(); //Destructor to delete all nodes }; void Queue::QUEDEL( ) { if (Front!=NULL) { NODE *Temp=Front; cout<<Front->Itemno<<” “; cout<<Front->Itemname<<”Deleted“; Front=Front->Link;
  • 242.
    384 delete Temp; if (FrontNULL) Rear=NULL; } else cout<<”Queue Empty..”; } OR void QUEDEL(Node *&Front, Node *&Rear) { if (Front ! =NULL) { NODE *Temp=Front; cout<<Front->Itemno<<” “; cout<<Front->Itemname<<”Deleted ”; Front=Front->Link; delete Temp; if (Front == NULL) Rear=NULL; } else cout<<”Queue Empty..”; } (1 Mark for checking Empty Queue) (½ Mark for assigning Front toTemp) (½ Mark for displaying the deleted Node detail(s)) (1MarkforreassigningFrontwithFront->Link) ( ½ Mark for deletingTemp) ( ½ Mark for assigning Rear with NULL if Queue becomes Empty) (d) Define a function SWAPARR( ) in C++ to swap (interchange) the first row elements with the last row elements, for a two dimensional integer array passed as the argument of the function. 3
  • 243.
    385 Example:Ifthetwodimensionalarraycontains 5 6 32 1 2 4 9 2 5 8 1 9 7 5 8 After swapping of the content of first row and last row, it should be as follows: 9 7 5 8 1 2 4 9 2 5 8 1 5 6 3 2 Ans void SWAPARR(int A[][100], int M, int N) { int Temp, Ji for (J=0; J<N; J++) { Temp = A[0)[J] ; A[0][J] = A[M-1][J]; A[M-l][J] = Temp; } } OR void SWAPARR(int A[4][4]) { int Temp, J; for (J=0; J<4; J++) { Temp = A[0][J]; A[0][J] = A[3][J];
  • 244.
    386 A[3][J] = Temp; } } OR Anyotilercorrectequivalentfunctiondefinition (1Mark for correct function header) (1 Mark for correct loop) (1 Mark for swapping the first row with last row correctly) (e) Convert the following infix expression to its equivalent postfix expression showingstackcontentsfortheconversion: 2 A + B * (C – D) / E Ans A + B * (C - D) / E = (A+ ( (B* (C-D) ) / E) ) Element Scanned Stack Postfix ( A A + + ( ( B AB * +* ( C ABC - +*- D ABCD ) +* ABCD- ) + ABCD-* / +/ E ABCD-*E ) + ABCD-*E/ ) ABCD-*E/+
  • 245.
    387 OR Element Scanned StackPostfix ( ( A ( A + (+ A B (+ AB * (+* AB ( (+*( AB C (+*( ABC - (+*(- ABC D (+*(- ABCD ) (+* ABCD- / (+/ ABCD-* E (+/ ABCD-*E ) ABCD-*E/+ OR Any other method for converting the given infix expression to its equivalent postfixexpressionshowingtheStackStatus. (½ Mark for correctly converting expression up to each operator) (1 Mark only to be given for writing correct answer without showing the Stack Status) 4. (a) Observetheprogramsegmentgivenbelowcarefullyandfilltheblanksmarked. asLine1andLine2usingfstreamfunctionsforperformingtherequiredtask. 1 #include <fstream.h> class Library { long Ano; //Ano - Accession Number of the Book char Title[20]; //Title - Title of the Book int Qty; //Qty - Number of Books in Library public: void Enter (int); //Function to enter the content
  • 246.
    388 void Display(); //Functionto display the content void Buy(int Tqty) { Qty+=Tqty; } //Function to increment in Qty long GetAno() {return Ano;} } ; void BuyBook(long BANo,int BQty) //BANo → Ano of the book purchased //BQty → Number of books purchased { fstream File; File.open(“STOCK.DAT” ,ios::binary|ios::in|ios::out); int position=-l; Library L; while (Position==-l && File.read((char*)&L,sizeof(L))) if (L. GetAno() ==BANo) { L.Buy(BQty); //To update the number of Books Position = File.tellg()-sizeof(L) ; //Line 1: To place the file pointer to the required positiol _________________________________; //Line 2:To write the object L on to the binary file _________________________________; } if (Position==-l) cout<< “No updation do:r{e as required Ano not found..”; File.close(); } Ans Statement1: File.seekp(Position);
  • 247.
    389 OR File. seekp (-sizeof(L), ios::cur); OR File.seekg(Position); //Not advisable OR File.seekg(-sizeof(L), ios::cur); //Not advisable OR Anyequivalentcorrectmethod Statement2: File.write((char*)&L, sizeof(L)); OR File.write((char*)&L, sizeof(Library)); OR Anyequivalentcorrectmethod (½ Mark for each correct Statement) (b) Write a function COUNT_TO( ) in C++ to count the presence of a word ‘to’ inatextfile“NOTES.TXT”. 2 Example: Ifthecontentofthefile“NOTES.TXT”isasfollows: It is very important to know that smokingisinjurioustohealth. Let us take initiative to stop it. ThefunctionCOUNT_TO()willdisplaythefollowingmessage: Count of -to- in file: 3 Note: In the above example, ‘to’ occurring as a part of word stop is not considered. Ans void COUNT_TO () { fstream Fil;
  • 248.
    390 Fil.open (“NOTES.TXT”, ios::in); charWord[80]; OR ifstream Fil(“NOTES.TXT”); int Count =0; while(!Fil.eof()) { Fil>>Word; if (strcmp(Word, “to”)==0) Count++; } Fil.close(); //Ignore cout<<”Count of -to- in file:”<<Count; } OR void COUNT_TO () { ifstream Fil(“NOTES.TXT”); OR fstream Fil; char STR[10]; Fil.open(“NOTES.TXT”,ios::in); int c=0; while (Fil.getline(STR, 10, ‘ ’)) { if (strcmpi (STR, “to”) ==0) c++; } Fil.close();//Ignore cout<<“Count of -to- in file:”<<c<<end1; } OR void COUNT_TO ()
  • 249.
    391 { ifstream Fil; ORifstream Fi1(“NOTES.TXT”); Fil.open(“NOTES.TXT”) char Word[80],Ch; int Count =0, I=0; while(Fil.get(Ch)) { if (Ch!= ‘ ‘) Word [I++] = Ch; else { Word[I] = ‘0’; if (strcmp (Word, “to”) ==0) Count++; I=O; } } Fil.close(); //Ignore cout<<”Count of -to- in file: “<<Count; } OR Anyothercorrectfunctiondefinitionperformingthedesiredoperation (½ Mark for opening NOTES. TXT correctly) (½ Mark for reading each word (Whichever method adopted) from the file) (½Markforcomparingthewordwith‘to’andincrementingcounter) (½Markfordisplayingthenumberof‘to’with/withouttheTextMessage) (c) Write a function in C++ to read and display the detail of all the members whose membership type is ‘L’or ‘M’from a binary file “CLUB.DAT”. Assume the binary file “CLUB.DAT” contains objects of class CLUB, whichisdefinedasfollows: 3
  • 250.
    392 class CLUB { int Mno;//Member Number char Mname [20]; //Member Name char Type; //Member Type: L Life Member M Monthly Member G Guest public: void Register();//Function to enter the content void Display(); //Function to display all data members char WhatType() {return Type;}. } ; Ans void DisplayL_M() { CLUB C; fstream fin; fin. open (“CLUB.DAT”, ios::binary|ios::in); OR ifstream fin (“CLUB.DAT”, ios::binary); while(fin.read((char*)&C, sizeof(C)) { if(C.WhatType()==’L’||C.WhatType()==’M’) C .Display (); } fin.close(); //Ignore } OR void Disp1ayL_M () { CLUB C; fstream fin; fin.open (“CLUB.DAT”, ios::binary | ios::in);
  • 251.
    393 OR ifstream fin (“CLUB.DAT”,ios::binary); if (fin) { fin.read((char*)&C, sizeof(C)); while(!fin.eof()) { if(C.WhatType()==’L’ || C.WhatType()==’M’) C. Display(); fin.read((char*)&C, sizeof(C)); } fin.close(); //Ignore (½ Mark for opening CLUB.DATcorrectly) (½ Mark for reading each record from CLUB.DAT) (½ Mark for correct loop / checking end of file) (1 Mark for comparing value returned byWhatType( ) with ‘L’, ‘M’) (½Markfordisplayingthematchingrecord) 5. (a) What is the purpose of a key in a table? Give an example of a key in a table. 2 Ans Anattribute/groupofattributesinatablethatidentifieseachtupleuniquelyis known as a Key. OR Any correct definition of Key / Primary Key / Candidate Key /Alternate Key Table:Item Ino Item Qty I01 Pen 560 I02 Pencil 780 I04 CD 450 I09 Floppy 700 I05 Eraser 300 I03 Duster 200
  • 252.
    394 (1Markforwritingcorrectdefinition/purposeofanyvalidKey) (1Markforgivingsuitableexample) OR (2 Marks forillustrating the purpose of Key with/without showing it as a part of a Table) (b) Consider the following tables DRESS and MATERIAL. Write SQL commands for the statements (i) to (iv) and give outputs for SQL queries (v) to(viii). 6 Table: DRESS Table: MATERIAL MCODE TYPE MOOl TERELENE MOO2 COTTON MOO4 POLYESTER MOO3 SILK
  • 253.
    395 (i) To displayDCODE and DESCRIPTION of each dress in ascending order of DCODE. Ans SELECT DCODE. DESCRIPTION FROM DRESS ORDER BY DCODE ; (1 Mark for correct query) (½ Mark for partially correct answer) : (ii) TodisplaythedetailsofallthedresseswhichhaveLAUNCHDATEinbetween 05-DEC’-07 and 20-JUN-08 (inclusive of both the dates). Ans SELECT * FROM DRESS WHERE LAUNCHDATE BETWEEN ‘05-DEC-07’ AND ’20-JUN-08’ OR SELECT * FROM DRESS WHERE LAUNCHDATE >= ‘05-DEC-07’ AND LAUNCHDATE<= ’20-JUN-08’ (1 Mark for correct query) (½ Mark for partially correct answer) (iii) TodisplaytheaveragePRICEofallthedresseswhicharemadeupofmaterial with MCODE as M003. Ans SELECT AVG(PRICE) FROM GARMENT WHERE MCODE = ‘M003’ (1 Mark for correct query) (½ Mark for partially correct answer) (iv) To display materialwise highest and lowest price of dresses from DRESS table. (Display MCODE of each dress along with highest and lowest price) Ans SELECT MCODE, MAX(PRICE), MIN (PRICE) FROM DRESS GROUP BY MCODE (1 Mark for correct query) (½ Mark for partially correct answer) (v) SELECT SUM(PRICE) FROM DRESS WHERE MCODE=‘M001’; Ans SUM(PRICE) 2700 (½ Mark for correct output) (vi) SELECT DESCRIPTION, TYPE FROM DRESS, MATERIALWHERE DRESS.DCODE = MATERIAL.MCODEAND DRESS.PRICE>=l250;
  • 254.
    396 Ans DESCRIPTION TYPE (NOOUTPUT) (½ Mark for the above) OR (½ Mark for attempting the question) (vii) SELECTMAX(MCODE) FROM MATERIAL; Ans MAX (MCODE) MOO4 (½ Mark for correct output) (viii) SELECT COUNT(DISTINCT PRICE) FROM DRESS; Ans COUNT(DISTINCT PRICE) 6 (½ Mark for correct output) 6. (a) Stateandverifyabsorptionlawusingtruthtable. 2 Ans AbsorptionLaw : For every X , Y ∈ B i) X + X . Y = X X . (X + Y) = X (by Duality) ii) X + X’ . Y = X + Y (i) (ii) (1 Mark for stating anyone of theAbsorption Laws) (1MarkforverifyingthelawusingTruthTable)
  • 255.
    397 (b) WritetheequivalentBooleanExpressionforthefollowingLogicCircuit: 2 AnsP.Q’ + P’.R (2 Marks for the final expression P.Q’+P’R) OR (1 Mark for anyone of the correct terms out of P.Q’or P’.R) (c) Write the POS form of a Boolean function G, which is represented in a truth tableasfollows: 1 Ans (U+V’+W).(U+V’+W’) . (U’+V’+W) OR G(U,V,W) = Π (2, 3, 6) (1 Mark for the correct POS form) Note: Deduct ½ mark if wrong variable names are used
  • 256.
    398 (d) ReducethefollowingBooleanExpressionusingK-Map: 3 H(U,V,W,Z)= Σ(0, 1, 4, 5, 6, 7, 11, 12, 13, 14, 15) Ans H(U,V,W,Z) = V + U’W’+ UWZ (½ Mark for placing all 1s at correct positions in K-Map) (½ Mark for each grouping) (1Markforwritingtinalexpressioninreduced/minimalform) Note: Deduct ½ mark if wrong variable names are used 7. (a) What is the difference between LAN andWAN? 1 Ans LAN (LocalArea Network): Interconnects a high number of access or node points or stations within a confined physical area.An example is the territory covered in a single office building that houses various departments/offices. All these areas are interconnectedusingaLAN. WAN (WideArea Network) Itisusedtoconnectsystemswithnolimitationofgeographicalarea.Itisused to serve many locations distributed over a large geographical area. Asystemofovernighttellermachinesusedbyabankingorganisationcovering theNorthofIndiaisanexampleofaWAN.Internetisalsoanexampleofthe same.
  • 257.
    399 (1Markforcorrectdifference,eitherTextualorDiagrammatical) OR ( ½ Markeach for correctTextual/Diagrammatical explanation of LAN orWAN) (b) Expandthefollowingabbreviations: 1 (i) HTTP (ii) ARPANET Ans (i) HyperTextTransfer Protocol (ii) Advanced Research ProjectsAgency Network (½ Mark for correct expansion of HTTP) (½ Mark for correct expansion ofARPANET) (c) What is protocol? Which protocol is used to copy a file from/to a remotely located server? 1 Ans A protocol is the set of rules for governing communication between two communication devices. It also infers documentation, negotiations and establishmentofrules. Protocol used to copy a file fromlto a remotely located server is FTP (File TransferProtocol) (½Markforexplainingprotocolcorrectly) (½ Mark for FTP) (d) Name two switching techniques used to transfer data between two terminals (computers). 1 Ans MessageSwitchingandPacketSwitching OR CircuitSwitchingandMessageSwitching OR CircuitSwitchingandPacketSwitching (½Markfornamingfirstswitchingtechnique) (½Markfornamingsecondswitchingtechnique) (e) EdumindsUniversityofIndiaisstartingitsfirstcampusinasmalltownParampur ofCentralIndiawithitscenteradmissionofficeinDelhi.Theuniversityhas3
  • 258.
    400 majorbuildingscomprisingofAdminBuilding,AcademicBuildingandResearch Building in the5 KM area Campus. As a network expert, you need to suggest the network plan as per (E1) to (E4) to the authorities keeping in mind the distances and other given parameters. ExpectedWiredistancesbetweenvariouslocations: ResearchBuildingtoAdminBuilding 90m ResearchBuildingtoAcademicBuilding 80m AcademicBuildingtoAdminBuilding 15m DelhiAdmissionOfficetoParampurCampus 1450 km Expected number of computers to be installed at various locations in the universityareasfollows: ResearchBuilding 20 AcademicBuilding 150 AdminBuilding 35 DelhiAdmissionOffice 5 (E1) Suggest to the authorities, the cable layout amongst variousbuildings insidetheuniversitycampusforconnectingthebuildings. 1 Ans
  • 259.
    401 (1 Mark formentioning any valid connectivity or topology or diagram connectingvariousbuildingsinsideuniversitycampus) (E2) Suggestthemostsuitableplace(i.e.building) to house the server of this organisation,withasuitablereason. 1 Ans AcademicBuildingasitcontainsmaximumnumberofcomputers. (½Markformentioningthebuilding) ( ½ Mark for correct reason) Note:1markifanysuitableplace/buildingissuggestedwithvalidjustification (E3) Suggestanefficientdevicefromthefollowingtobeinstalledineachof thebuildingstoconnectallthecomputers: 1 (i) GATEWAY (ii) MODEM (iii) SWITCH Ans SWITCH ( 1 Mark for correct device) (E4) Suggest the most suitable (very high speed) service to provide data connectivity betweenAdmission Building located in Delhi and the campuslocatedinParampurfromthefollowingoptions: 1 Telephoneline Fixed-LineDial-upconnection Co-axial Cable Network GSM Leasedline SatelliteConnection Ans SatelliteConnection OR Leasedline (1 Mark for correct service name)
  • 260.
    302 COMPUTER SCIENCE Time allowed: 3 hours Maximum Marks : 70 Instructions: (i) All questions are compulsory. (ii) Programming Language: C+ + QUESTION PAPER CODE 91/1 1. (a) What is the difference between automatic type conversion and type casting? Also, give a suitable C++ code to illustrate both. 2 (b) WhichC++headerfile(s)willbeessentiallyrequiredtobeincludedtorun/ execute the following C++ code? 1 void main( ) { int Eno=123, char Ename[ ]=”Rehan Swamp”; cout<<setw(5)<<Eno<<setw(25)<<EName<<endl; } (c) Rewritethefollowingc++programcodeafterremovingthesyntaxerror(s) (ifany).Underlineeachcorrection. 2 include <iostream.h> class TRAIN { long TrainNo; char Description[25]; public void Entry ( ) {
  • 261.
    303 cin >>TrainNo; gets(Description); } VoidDisplay ( ) { cout<<TrainNo<<“:”<<Description<<endl; } }; void main( ) { TRAIN T; Entry. T( ); Display. T( ); } (d) Findtheoutputofthefollowingprogram: 3 #inc1ude <iostream.h> struct POINT {int X, Y, Z;}; void StepIn(POINT & P, int Step=1) { P.X+=Step; P.Y -=Step; P.Z+=Step; } void StepOut(POINT & P, int Step=1) { P.X-=Step; P.Y+=Step; P.Z–=Step;
  • 262.
    304 } void main () { POINT P1={15, 25, 5}, P2={10, 30, 20}; StepIn(P1); StepOut(P2,4); cout<<P1.X<<“,”<<P1.Y<<“,”<<P1.Z<<endl; cout<<P2.X<<“,”<<P2.Y<<“,”<<P2.Z<<endl; StepIn(P2,12); cout<<P2.X<<“,”<<P2.Y<<“,”<<P2.Z<<endl; } (e) Findtheoutputofthefollowingprogram: 2 #include <iostream.h> #include <ctype.h> void ChangeIt(char Text[ ], char C) { for (int K=0;Text[K]!='0';K++) { if (Text[K]>=’F’ && Text[K]<=’L’) Text[K]=tolower(Text[K]); else if (Text[K]=’E’ || Text[K]==’e’) Text[K]= =C; else if (K%2==O) Text[K]=toupper(Text[K]); else
  • 263.
    305 Text[K]=Text[K-l]; } } void main () { char OldText[ ]=”pOwERALone”; ChangeIt(OldText,’%’); cout<<“New TEXT:”<<OldText<<endl; } (f) Thefollowingcodeisfromagame,whichgeneratesasetof4randomnumbers. Yallavisplayingthisgame,helphimtoidentifythecorrectoption(s)outofthe fourchoicesgivenbelowasthepossiblesetofsuchnumbersgeneratedfrom the program code so that he wins the game. Justify your answer. 2 #include <iostream.h> #include <stdlib.h> const int LOW=15; void main ( ) { randomize( ) ; int POINT=5, Number; for (int 1=1;I<=4;I++) { Number=LOW+random(POINT) ; cout<<Number<<“:” ; POINT--; } }
  • 264.
    306 (i) 19:16:15:18: (ii) 14:18:15:16: (iii)19:16:14:18: (iv) 19:16:15:16: 2. (a) What do you understand by Polymorphism.?Also, give an example in C++ toillustratethesame. . 2 (b) Answerthequestions(i)and(ii)aftergoingthroughthefollowingclass: 2 class TEST { int Regno, Max, Min, Score; public: TEST() //Function 1 { Regno= 101;Max=100;Min=40;Score=75; } TEST(int Pregno,int Pscore) //Function 2 { Regno=Pregno;Max=100;Min=40;Score=Pscore; } ~TEST() //Function 3 { cout<<“TEST Over”<<endl; } void Display() //Function 4 { cout<<Regno<<“:”<<Max<<“:”<<Min<<endl; cout<<“[Score]”<<Score<<endl; } };
  • 265.
    307 (i) As perObject Oriented Programming, which. concept is illustrated by Function 1 and Function 2 together? (ii) WhatisFunction3specificallyreferredas?Whendoyouthink,Function3 willbeinvoked/called? (c) DefineaclassITEMinC++withfollowingdescription: 4 PrivateMembers Code of type integer (Item Code) Inameoftypestring(ItemName) Price of type float (Price of each item) Qtyoftypeinteger(Quantityof iteminstock) Offer of type float (Offer percentage on the item) AmemberfunctionGetOffer()tocalculateOfferpercentageasperthe followingrule: If Qty<=50 Offer is 0 If 50<Qty<=100 Offer is 5 If Qty>100 Offer is 10 PublicMembers A function GetStock() to allow user to enter values for Code, Iname, Price,QtyandcallfunctionGetOffer()tocalculatetheoffer AfunctionShowItem()toallowusertoviewthecontentofallthedata members (d) Answerthequestions(i)to(iv)basedonthefollowing: 4 classChairperson { long CID; //Chairperson Identification Number char CName[20]; protected: char Description [40]; void Allocate();
  • 266.
    308 public: Chairperson(); void Assign(); void Show(); }; classDirector { int DID; //Director ID char Dname[20]; protected: char Profile[30]; public: Director(); void Input(); void output(); }; class Company: private Chairperson, public Director { int CID; //Company ID char City[20], Country[20]; public: Company(); void Enter(); void Display(); }; (i) Whichtypeofinheritanceoutofthefollowingisspecificallyisillustratedin the above C++ code?
  • 267.
    309 (a) SingleLevelInheritance (b) MultiLevelInheritance (c)MultipleInheritance (ii) Write the names of data members, which are accessible by objects of class typeCompany. (iii) Write the names of all member functions, which are accessible by objects of class type Company. (iv) Writethenamesofallmembers,whichareaccessiblefrommemberfunctions of class Director. 3. (a) Write a function CHANGEO in C++, which accepts an array of integer and its size as parameters and divide all those array elements by 7 which are divisibleby7andmultiplyother-arrayelementsby3. 3 Sample Input Data of the array ContentofthearrayafterCalling CHANGE()function (b) An arrayP[50][60]isstoredinthememoryalongthecolumnwitheach of the elementoccupying2bytes,findoutthememorylocationfortheelementP[10] [20], if the BaseAddress of the array is 6800. 3 (c) Write a completeprograminc++toimplement a dynamically allocated Stack containingnamesofCountries. 4 (d) Write a function int SKIPSUM(intA[ ] [3], int N,int M) in C++ to find and return the sum of elements from all alternate elements of a two-dimensional arraystartingfromA[0][0]. 2 Hint: Ifthefollowingisthecontentofthearray
  • 268.
    310 The function SKIPSUM()should add elementsA[0][0],A[0][2],A[1][l], A[2][0] andA[2][2]. (e) Evaluatethefollowingpostfixnotationofexpression: 2 (Show status of Stack after each operation) False, True, NOT, OR, True, False,AND, OR 4. (a) Observetheprogramsegmentgivenbelowcarefullyandfilltheblanks mar- ked as Statement 1 and Statement 2 using tellg() and seekp() functions for performingtherequiredtask. 1 #include <fstream.h> class Client { long Cno; char Name[20], Email[30] ; public: //Function to allow user to enter the Cno, Name, Email void Enter() ; //Function to allow user to enter (modify) Email void Modify() ; long ReturnCno() {return Cno;} }; void ChangeEmail() { Client C; fstream F;
  • 269.
    311 F.open (“INFO.DAT”,ios::binary|ios::in|ios::out); long Cnoc;//Client’sno. whose Email needs to be changed cin>>Cnoc; while (F.read((char*)&C, sizeof(C))) { if (Cnoc= =C.ReturnCno()) { C.Modify(); //Statement 1 int Pos = __________//To find 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)); } } F.close(); } (b) Write a function in C++ to count the words “this” and “these” present in a textfile“ARTICLE.TXT”. 2 [Note that the words “this” and “these” are complete words] (c) Write a function in C++ to search and display details of all flights, whose destination is“Mumbai”fromabinary file “FLIGHT.DAT”.Assuming the binaryfileiscontainingtheobjectsofthefollowingclass. 3
  • 270.
    312 class FLIGHT { int Fno;//Flight Number char From[20]; //Flight Starting Point char To[20]; //Flight Destination public: char* GetFrom() {return From;} char* GetTo() {return To;} void Enter() {cin>>Fno;gets(From);gets(To);} void Display(){cout<<Fno<<“:”<<From<<“:”<<To<<endl;} }; 5. (a) What do you understand by Candidate Keys in a table? Give a suitable exampleofCandidateKeysfromatablecontainingsomemeaningfuldata. 2 (b) Consider the following tables STORE and SUPPLIERS and answer (bl) and (b2) parts of this question: Table:STORE
  • 271.
    313 Table:SUPPLIERS (b1) WriteSQLcommandsforthefollowingstatements: 4 (i)TodisplaydetailsofalltheitemsintheStoretableinascendingorderof LastBuy. (ii) To display ItemNo and Item name of those items from Store table whose Rate is more than 15 Rupees. (iii) To display the details of those items whose Supplier code (Scode) is 22 or Quantity in Store (Qty) is more than 110 from the table Store. (iv) TodisplayMinimumRateofitemsforeachSupplierindividuallyasper Scode from the table Store. (b2) GivetheoutputofthefollowingSQLqueries: 2 (i) SELECT COUNT(DISTINCT Scode) FROM Store; (ii) SELECT Rate*Qty FROM Store WHERE ItemNo=2004; (iii) SELECT Item,Sname FROM Store S, Suppliers P WHERE S.Scode=P.ScodeAND ItemNo=2006; (iv) SELECT MAX(LastBuy) FROM Store; 6. (a) Verifythefollowingalgebraically. 2 (A’+B’).(A+B)=A’.B+A.B’ (b) WritetheequivalentBooleanExpressionforthefollowingLogiccircuit: 2
  • 272.
    314 (c) Write thePOS form of a Boolean function H, which is represented in a truth tableasfollows: 1 (d) ReducethefollowingBooleanExpressionusingK-Map: 3 F (U, V, W, Z) = Σ (3, 5, 7, 10, 11, 13, 15) 7. (a) What was the role ofARPANET in the Computer Network? 1 (b) Whichofthefollowingisnotanunitfordatatransferrate? 1 (i) bps (ii) abps (iii) gbps (iv) kbps (c) WhatisthedifferencebetweenTrojanHorseandVirusintermsofcomputers? 1 (d) What term we use for a software/hardware device, which is used to block, unauthorizedaccesswhilepermittingauthorizedcommunications.Thistermis also used for a device or set of devices configured to permit, deny, encrypt, decrypt,orproxyall(inandout)computertrafficbetweendifferentsecurity domains based upon a set of rules and other criteria. 1 (e) “LearnTogether” is an educational NGO. It is setting up its new campus at Jabalpurforitswebbasedactivities.Thecampushas4compoundsasshown inthediagrambelow: 4
  • 273.
    315 Center to centerdistances between various Compounds as per architectural drawings(inMetre)isasfollows: Expected Number of Computers in each Compound is as follows : (e1) Suggest a cable layout of connections between the compounds. (e2) Suggest the most suitable place (i.e. compound) to house the server for this NGO.Also, provide a suitable reason for your suggestion. (e3) Suggesttheplacementofthefollowingdeviceswithjustification:
  • 274.
    316 (i) Repeater (ii) Hub/Switch (e4)The NGO is planning to connect its International office situated in Mumbai,whichoutofthefollowingwiredcommunicationlink,youwill suggestforaveryhighspeedconnectivity? (i) TelephoneAnalogLine (ii) OpticalFiber (iii) EthernetCable (f) Writethefullformsofthefollowing: 1 (f1) GNU (f2) XML (g) Write one advantage of each for Open Source Software and Proprietary Software. 1 QUESTION PAPER CODE 91 1. (a) What is the difference between call by value and call by reference?Also, give a suitable C++ code to illustrate both. 2 (b) WhichC++headerfile(s)willbeessentiallyrequiredtobeincludedtorun/ executethefollowingC++code: 1 void main() { int Rno=24; char Name[] =”Amen Singhania”; cout<<setw(lO)<<Rno<<setw(20)<<Name<<endl; } (c) RewritethefollowingC++programcodeafterremovingthesyntaxerror(s) (ifany).Underlineeachcorrection. 2 include <iostream.h> class FLIGHT {
  • 275.
    317 long FlightCode; char Description[25]; public voidAddInfo() { cin>>FlightCode; gets (Description) ; { void ShowInfo() ( cout<<FlightCode<<“:”<<Description<<endl; } } ; void main() { FLIGHT F; AddInfo.F(); ShowInfo.F(); } (d) Findtheoutputofthefollowingprogram: 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;
  • 276.
    318 } void MoveOut(THREE_D &T,int Step=l) { T.X-=Step; T.Y+=Step; T.Z-=Step; } void main () { THREE_D Tl={lO,20,5},T2={30,lO,40}; MoveIn(T1); MoveOut(T2,5); cout<<Tl.X<<“,”<<Tl.Y<<“,”<<T1.Z<<endl; cout<<T2.X<<“,”<<T2.Y<<“,”<<T2.Z<<endl; MoveIn(T2,l0); cout<<T2.X<<“,”<<T2.y<<“,”<<T2.Z<<endl; } (e) Find.theoutputofthefollowingprogram: 2 #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]);
  • 277.
    319 else if (Msg[Cnt]==’A’|| Msg[Cnt]==’a’) Msg[Cnt]=CH; else if(Cnt%2==0) Msg[Cnt]=toupper(Msg[Cnt]); else Msg[Cnt]=Msg[Cnt-l]; } } void main () { char MyText [] =” ApEACeDriVE”; MyCode(MyText,’@’); cout<<“NEW TEXT:”<<MyText<<endl; } (f) Thefollowingcodeisfromagame,whichgeneratesasetof4randomnumbers. Prafulisplayingthisgame,helphimtoidentifythecorrectoption(s)outofthe fourchoicesgivenbelowasthepossiblesetofsuchnumbersgeneratedfrom the program code so that he wins the game. Justify your answer. 2 #include <iostream.h> #include <stdlib.h> const int LOW=25; void main () { randomize(); int P01NT=5,Number; for (int I=1;I<=4;I++)
  • 278.
    320 { Number=LOW+random(POINT); Cout<<Number<<“:”; P0INT--; } } (i) 29:26:25:28: (ii) 24:28:25:26: (iii)29:26:24:28: (iv) 29:26:25:26: 2. (a) What do you understand by Data Encapsulation and Data Hiding ?’Also, giveanexampleinC++toillustrateboth. 2 (b) Answerthequestions(i)and(ii)aftergoingthroughthefollowingclass: 2 class Exam { int Rno,MaxMarks,MinMarks,Marks; public: Exam() //Module 1 { Rno=101;MaxMarks=l00;MinMarks=40;Marks=75; } Exam(int Prno, int Pmarks) //Module 2 { Rno=Prno;MaxMarks=l00;MinMarks=40;Marks=Pmarks; } ~Exam() //Module 3
  • 279.
    321 { cout<<“Exam Over”<<endl; } void Show() //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? (ii) What is Module 3 referred as ? When do you think, Module 3 will be invoked/called? (c) DefineaclassSTOCKinC++withfollowingdescription: 4 PrivateMembers ICode of type integer (Item Code) Item of type string (Item Name) Price of type float (Price of each item) Qty of type integer (Quantity in stock) Discountoftypefloat(Discountpercentageontheitem) AmemberfunctionFindDisc()tocalculatediscountasperthefollowing rule: If Qty<=50 Discountis0 If 50<Qty<=100 Discountis5 If Qty>100 Discountis10 PublicMembers A function Buy() to allow user to enter values for ICode, Item, Price, QtyandcallfunctionFindDisc()tocalculatetheDiscount.
  • 280.
    322 A function ShowAll() to allow user to view the content of all the data members. (d) Answerthequestions(i)to(iv)basedonthefollowing: 4 class Director { long DID; //Director Identification Number char Name[20]; protected: char Description[40]; void Allocate(); public: Director(); void Assign(); void Show(); } ; class Ractory:public Director } int FID; //Factory ID char Address[20]; protected: int NOE; //No. of Employees public: Factory(); void Input(); void Output(); }; class ShowRoom:private Factory
  • 281.
    323 { int SID; //ShowroomID char City[20]; public: ShowRoom(); void Enter(); void Display(); }; (i) Whichtypeofinheritanceoutofthefollowingisillustratedintheabove C++ code? (a) SingleLevelInheritance (b) MultiLevelInheritance (c) MultipleInheritance (ii) Write the names of data members, which are accessible by objects of class type ShowRoom. (iii) Writethenamesofallmemberfunctionswhichareaccessiblebyobjects of class type ShowRoom. (iv) Write the names of all members, which are accessible from member functionsofclassFactory. 3. (a) Write a function REASSIGNO in C++, which accepts an array of integers and its size as parameters and divide all those array elements by 5 which are divisibleby5andmultiplyotherarrayelementsby2. 3 Sample Input Data of the array ContentofthearrayaftercallingREASSIGNOfunction
  • 282.
    324 (b) An arrayT[90][100] is stored in the memory along the column with each of the elementsoccupying4bytes.Findoutthememorylocationfortheelement T[10][40], if the BaseAddress of the array is 7200. 3 (c) Write a complete program in C++ to implement a dynamically allocated QueuecontainingnamesofCities. 4 (d) Write a function intALTERSUM (int B[ ] [5], int N, int M in C++ to find andreturnthesumofelementsfromallalternateelementsofatwo-dimensio- nalarraystartingfromB[0][0]. 2 Hint: Ifthefollowingisthecontentofthearray The function should add elements B[0][0], B[0][2], B[l][l], B[2][0] and B[2][2]. (e) Evaluatethefollowingpostfixnotationofexpression: 2 (Show status of Stack after each operation) True, False, NOT, OR, False, True, OR,AND 4. (a) Observetheprogramsegmentgivenbelowcarefullyandfilltheblanksmar- ked as Statement 1 and Statement 2 using tellg() and seekp() functions for performingtherequiredtask. 1 #include <fstream.h> class Customer { long Cno;char Name[20],Mobile[12]; public:
  • 283.
    325 //Function to allowuser 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 (Choc==C.GetCno()) { C.Modify (); //Statement 1 int Pos=_____________//To find 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)); } } F. close () ; }
  • 284.
    326 (b) Write afunction in C++ to count the words “to” and “the” present in a text file “POEM.TXT”. 2 [Note that the words “to” and “the” are complete words] (c) Write a function in C++ to search and display details. of all trains, whose destinationis“Delhi”.fromabinaryfile“TRAIN.DAT”.Assumingthebinary fileiscontainingtheobjectsofthefollowingclass. 3 class TRAIN { int 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);} void Show(){cout<<Tno<<“:”<<From<<“:”<<To<<endl;} }; 5. (a) WhatdoyouunderstandbyPrimaryKey?GiveasuitableexampleofPrimary Keyfromatablecontainingsomemeaningfuldata. 2 (b) Consider the following tables STOCK and DEALERS and answer (b1) and (b2) parts of this question: Table: STOCK
  • 285.
    327 Table:DEALERS (b1) WriteSQLcommandsforthefollowingstatements: 4 (i)To display details of all Items in the Stock table in ascending order of StockDate. (ii) To display ItemNo and Item name of those items from Stock table whose UnitPrice is more than Rupees 10. (iii) To displaythedetailsofthoseitemswhosedealercode(Dcode) is 102 or Quantity in Stock (Qty) is more than 100 from the table Stock. (iv) TodisplayMaximumUnitPriceofitemsforeachdealerindividually as per Dcode from the table Stock. (b2) GivetheoutputofthefollowingSQLqueries: 2 (i) SELECT COUNT(DISTINCT Dcode) FROM Stock; (ii) SELECT Qty*UnitPrice FROM Stock WHERE ItemNo=5006; (iii) SELECT Item,Dname FROM Stock S, Dealers D WHERE S.Dcode=D.DcodeAND ItemNo=5004; (iv) SELECT MIN(StockDate) FROM Stock; 6. (a) Verifythefollowingalgebraically: 2 X’.Y + X.Y’ = (X’+Y’).(X+Y) (b) WritetheequivalentBooleanExpressionforthefollowingLogicCircuit: 2
  • 286.
    328 (c) Write theSOPform of a Boolean function G, which is represented in a truth tableasfollows: 1 (d) ReducethefollowingBooleanExpressionusingK-Map: 3 F(A,B,C,D)= Σ(3,4,5,6,7,13,15) 7. (a) What was the role ofARPANET in the Computer Network? 1 (b) Whichofthefollowingisnotaunitfordatatransferrate? 1 (i) mbps (ii) kbps (iii) sbps (iv) gbps (c) What is the difference betweenVirus andWorms in the computers? 1 (d) Whattermdoweuseforasoftware/hardwaredevice,whichisusedtoblock unauthorizedaccesswhilepermittingauthorizedcommunications?Thisterm isalsousedforadeviceorsetofdevicesconfiguredtopermit,deny,encrypt, decrypt,orproxyall(inandout)computertrafficbetweendifferentsecurity domains based upon a set of rules and other criteria. 1 (e) “Vidya for All” is an educational NGO. It is setting up its new campus at Jaipurforitsweb-basedactivities.Thecampushasfourbuildingsasshownin thediagrambelow: 4
  • 287.
    329 Center to centerdistances between various buildings as per architectural drawings(inmeters)isasfollows: ExpectedNumberofComputersineachBuildingisasfollows: (el) Suggestacablelayoutofconnectionsbetweenthebuildings. (e2) Suggest the most suitable place (i.e. building) to house the server for this NGO.Also, provide a suitable reason for your suggestion. (e3) Suggesttheplacementofthefollowingdeviceswithjustification: (i) Repeater (ii) Hub/Switch
  • 288.
    330 (e4) TheNGOisplanningtoconnectitsInternationalofficesituatedinDelhi. Whichoutofthefollowingwiredcommunicationlinks,willyousuggest foraveryhighspeedconnectivity? (i) TelephoneAnalogLine (ii)OpticalFiber (iii) EthernetCable (f) Writethefullformsofthefollowing: 1 (f1) FTP (f2) FSF (g) Name any two common Web browsers. 1
  • 289.
    331 Marking Scheme —Computer Science General Instructions : 1. TheanswersgiveninthemarkingschemeareSUGGESTIVE,Examinersarerequestedto awardmarksforallalternativecorrectSolutions/Answersconveyingthesimilarmeaning 2. All programming questions have to be answered with respect to C++ Language only. 3. InC++,ignorecasesensitivityforidentifiers (Variable/Functions/Structures/ClassNames) 4. In SQL related questions - both ways of text/character entries should be acceptable for Example: “AMAR” and ‘amar’both are correct. 5. In SQL related questions - all date entries should be acceptable for Example: 'DD-Mon- YY', "DD/MM/YY", 'DD/MM/YY", 'DD/MM/YY', "MM/DD/YY", 'MM/DD/YY', and {MM/DD/YY} are correct. 6. InSQLrelatedquestions-semicolonshouldbeignoredforterminatingtheSQLstatements 7. InSQLrelatedquestions,ignorecasesensitivity. QUESTION PAPER CODE 91/1 EXPECTEDANSWERS 1. (a) What is the difference between automatic type conversion and type casting? Also, give a suitable C++ code to illustrate both. 2 Ans. AutomaticTypeConversion:itisanimplicitprocessofconversionofadata from one type to another. For example int N = 65; char C = N; // Automatic type conversion cout<<C; OUTPUT: A Type Casting: It is an explicit process of conversion of a data from one type to another. For example
  • 290.
    332 int A=1, B=2; floatC = (float)A/B; //Type Casting cout<<C; OUTPUT: 0.5 (½ Mark for each correct explanation ofAutomatic Type Conversion and TypeCasting) (½ Mark for each correct example ofAutomaticType Conversion andType Casting) OR (Full2Marksforcorrectexample(s)demonstratingthemeaningof/difference betweenAutomaticType Conversion andType Casting) OR (Only 1 Mack to be awarded if Explanation without supporting examples) Note:Outputisoptional (b) WhichC++headerfile(s)willbeessentiallyrequiredtobeincludedtorun/ execute the following C++ code? 1 void main( ) { int Eno=123, char Ename[ ]=”Rehan Swamp”; cout<<setw(5)<<Eno<<setw(25)<<EName<<endl; } Ans. (i) iostream.h (ii) iomanip.h OR iomanip.h - (As iostream.h is included in iomanip.h) (½ Mark for writing each correct header file) OR (Full 1 Mark for mentioning only iomanip.h ) Note: Ignore any other header files, if mentioned.
  • 291.
    333 (c) Rewritethefollowingc++programcodeafterremovingthesyntaxerror(s) (ifany).Underlineeachcorrection. 2 include<iostream.h> class TRAIN { long TrainNo; char Description[25]; public void Entry ( ) { cin >>TrainNo; gets(Description); } Void Display ( ) { cout<<TrainNo<<“:”<<Description<<endl; } }; void main( ) { TRAIN T; Entry. T( ); Display. T( ); } Ans. #include<iostream.h> #include<stdio.h> class TRAIN { long TrainNo;
  • 292.
    334 char Description [25]; public: voidEntry () { cin>>TrainNo; gets (Description); } void Display () { cout<<TrainNo<<“:”<<Description<<end1; } }; void main () { TRAIN T; T.Entry(); T.Display(); } (½ Mark for writing # before include<iostream.h> (½ Mark for writing # include <stdio.h> (½ Mark for writing: after public) (½ Mark for writing T.Entry(); and T.Display(); correctly) (d) Findtheoutputofthefollowingprogram: 3 #inc1ude <iostream.h> struct POINT {int X, Y, Z;}; void StepIn(POINT & P, int Step=1) {
  • 293.
    335 P.X+=Step; P.Y-=Step; P.Z+=Step; } void StepOut(POINT &P, int Step=1) { P.X-=Step; P.Y+=Step; P.Z–=Step; } void main ( ) { POINT P1={15, 25, 5}, P2={10, 30, 20}; StepIn(P1); StepOut(P2,4); cout<<P1.X<<“,”<<P1.Y<<“,”<<P1.Z<<endl; cout<<P2.X<<“,”<<P2.Y<<“,”<<P2.Z<<endl; StepIn(P2,12); cout<<P2.X<<“,”<<P2.Y<<“,”<<P2.Z<<endl; } Ans. 16, 24, 6 6, 34, 16 18, 22, 28 (1 Mark for each line with -correct values) OR (½ Mark for any two correct values in each line)
  • 294.
    336 Note: Deduct (½ Markif any/all ‘,’ missing Deduct (½ Mark if endl is not considered at the right positions (e) Findtheoutputofthefollowingprogram: 2 #include <iostream.h> #include <ctype.h> void ChangeIt(char Text[ ], char C) { for (int K=0;Text[K]!='0';K++) { if (Text[K]>=’F’ && Text[K]<=’L’) Text[K]=tolower (Text[K]); else if (Text[K]=’E’ || Text[K]==’e’) Text[K]==C; else if (K%2==O) Text[K]=toupper(Text[K]); else Text[K]=Text[K-l]; } } void main ( ) { char OldText[ ]=”pOwERALone”; ChangeIt(OldText,’%’); cout<<“New TEXT:”<<OldText<<endl; }
  • 295.
    337 Ans. New TEXT: PPW % RR11N% (½ Mark for writing PPW as the first three characters) (½ Mark for writing %RR as the next three characters) (½ Mark for writing 11 as the next two characters) (½ Mark for writing N% as the next two characters) Note: Deduct X Mark for not mentioning New TEXT : (f) Thefollowingcodeisfromagame,whichgeneratesasetof4randomnumbers. Yallavisplayingthisgame,helphimtoidentifythecorrectoption(s)outofthe fourchoicesgivenbelowasthepossiblesetofsuchnumbersgeneratedfrom the program code so that he wins the game. Justify your answer. 2 #include <iostream.h> #include <stdlib.h> const int LOW=15; void main ( ) { randomize( ) ; int POINT=5, Number; for (int 1=1;I<=4;I++) { Number=LOW+random(POINT) ; cout<<Number<<“:” ; POINT--; } } (i) 19:16:15:18: (ii) 14:18:15:16: (iii) 19:16:14:18: (iv) 19:16:15:16:
  • 296.
    338 Ans. (iv) 19:16:15:16: Justificationisasfollows: IPOINT Number Minimum Maximum 1 5 15 19 2 4 15 18 3 3 15 17 4 2 15 16 Theonlyoptionthatsatisfiesthesevaluesisoption(iv). (1 Mark for mentioning correct option) (1 Mark for any valid justification) Note: Only ½ Mark to be given if only options (i) & (iv) are mentioned as correct options; no other combination of options is acceptable; 2. (a) What do you understand by Polymorphism?Also, give an example in C++ toillustratethesame. 2 Ans. Theprocessofusingan-operatororafunctionindifferentwaysfordifferent set of inputs given is known- as polymorphism. Function overloading is- an exampleofpolymorphism,wherethefunctionshavingsamenamewithdifferent set of parameters perform different operations. Example: void Disp ( ) //Function 1 { cout<<“Hello”<<endl; } void Disp(int N) //Function 2 { for(int I=1;I<=N;I++) cout<<I<<endl; }
  • 297.
    339 void Disp (intN,int M) //Function 3 { for (int I=N;I<=M; I++) cout<<N<<“x”<<I<<“=”<<N*I<<endl; } void main ( ) { int x=5, y=10; Disp(x); //Function 2 called-Prints numbers from 1 to 5 Disp(x,y) ; //Function 3 called- Prints from multiples of 5 //ranging from 5 to 10 Disp () ; //Function 1 called- Prints Hello } (1 Mark for correct explanation of Polymorphism) (1 Mark for a valid example of Polymorphism) (b) Answerthequestions(i)and(ii)aftergoingthroughthefollowingclass: 2 class TEST { int Regno, Max, Min, Score; public: TEST() //Function 1 { Regno= 101;Max=100;Min=40;Score=75; } TEST(int Pregno,int Pscore) //Function 2 { Regno=Pregno;Max=100;Min=40;Score=Pscore; }
  • 298.
    340 ~TEST() //Function 3 { cout<<“TESTOver”<<endl; } void Display() //Function 4 { cout<<Regno<<“:”<<Max<<“:”<<Min<<endl; cout<<“[Score]”<<Score<<endl; } }; (i) As per Object Oriented Programming, which. concept is illustrated by Function 1 and Function 2 together? Ans. Polymorphism OR FunctionOverloading OR ConstructorOverloading (1 Mark for naming the concept correctly) (ii) WhatisFunction3specificallyreferredas?Whendoyouthink,Function3 willbeinvoked/called? Ans. Destructor, invoked or called when scope of an Object gets over. (½ Mark for naming Destructor correctly) (½ Mark for mentioning correctly when it is invoked) (c) DefineaclassITEMinC++withfollowingdescription: 4 PrivateMembers Code of type integer (Item Code) Inameoftypestring(ItemName) Price of type float (Price of each item)
  • 299.
    341 Qtyoftypeinteger(Quantityof iteminstock) Offer oftype float (Offer percentage on the item) AmemberfunctionGetOffer()tocalculateOfferpercentageasperthe followingrule: If Qty<=50 Offer is 0 If 50<Qty<=100 Offer is 5 If Qty>100 Offer is 10 PublicMembers A function GetStock() to allow user to enter values for Code, Iname, Price,QtyandcallfunctionGetOffer()tocalculatetheoffer AfunctionShowItem()toallowusertoviewthecontentofallthedata members Ans. classITEM { int Code; char Iname [20] ; floatPrice; intQty; floatOffer; voidGetOffer(); public: void GetStock () { cin>>Code; gets (Iname) ; // OR cin.getline (Iname, 80) ; OR cin>>Iname; cin>>Price>>Qty; GetOffer();
  • 300.
    342 } void ShowItern () { cout<<Code<<Iname<<Price<<Qty<<Offer; }; voidITEM::GetOffer() { if(Qty<=50) Offer = 0; else if (Qty <=100) Offer = 5; / /OR Offer = 0.05; else Offer = 10; / /OR Offer = 0.1; } (½ Mark for correct syntax for class header) (½ Mark for correct declaration of data members) (1 Mark for correct definition of GetOffer()) (1 Mark for correct definition of GetStock () with proper invocation of GetOffer() function) (1 Mark for correct definition of Showltem()) NOTE: Deduct ½ Mark if GetOffer() is not invoked properly inside GetStock()function (d) Answerthequestions(i)to(iv)basedonthefollowing: 4 classChairperson { long CID; //Chairperson Identification Number char CName[20]; protected: char Description [40];
  • 301.
    343 void Allocate(); public: Chairperson(); void Assign(); voidShow(); }; class Director { int DID; //Director ID char Dname[20]; protected: char Profile[30]; public: Director(); void Input(); void output(); }; class Company: private Chairperson, public Director { int CID; //Company ID char City[20], Country[20]; public: Company(); void Enter(); void Display(); };
  • 302.
    344 (i) Whichtypeofinheritanceoutofthefollowingisspecificallyisillustratedin the aboveC++ code? (a) SingleLevelInheritance (b) MultiLevelInheritance (c) MultipleInheritance Ans. (c) MultipleInheritance (1 Mark for writing correct inheritance type) (ii) Write the names of data members, which are accessible by objects of class typeCompany. Ans None (1 Mark for writing None or No data members) (iii) Write the names of all member functions, which are accessible by objects of class type Company. Ans. Enter(),Display(),Input(),output() (1 Mark for writing correct member functions) Note: Both output() or Output() are acceptable as correct answer since differentiation between small and capital O is very difficult. No marks to be awarded for any other alternative answer Ignore mention of Constructor(s) (iv) Writethenamesofallmembers,whichareaccessiblefrommemberfunctions of class Director. Ans. Input(),output(),Profile,Dname,DID (1 Mark for writing correct members) Note: Both output() or Output() are acceptable as correct answer since differentiation between small and capital O is very difficult. No marks to be awarded for any other alternative answer Ignore mention of Constructor(s)
  • 303.
    345 3. (a) Writea function CHANGEO in C++, which accepts an array of integer and its size as parameters and divide all those array elements by 7 which are divisibleby7andmultiplyother-arrayelementsby3. 3 Sample Input Data of the array ContentofthearrayafterCalling CHANGE()function Ans. void CHANGE (int A[ ], int N) { for(int I = 0; I<N; I++) { if (A[I]%7 = = 0) A [I] = A [I] /7; else A[I] = A[I] * 3; } } OR Anyothercorrectequivalentfunctiondefinition ( ½ Mark for correct Function Header) (½ Mark for correct loop) (½ Mark for correct checking of divisibility of array elements by 7) (½ Mark for correct else OR correct checking of non divisibility of array elements by 7) (½ Mark for each correct assignment) (b) An arrayP[50] [60]isstoredinthememoryalongthecolumnwitheach of the elementoccupying2bytes,findoutthememorylocationfortheelementP[10] [20], if the BaseAddress of the array is 6800. 3
  • 304.
    346 Ans.Loc(P[I] [J]) =Base(P)+W(I+J*M) i Loc(P[10][20]) = Base(P)+ 2(10+20*50) Loc(P[10] [20]) = 68OO + 2(10+20*50) = 6800 + 2 (10+1000) = 6800 + 2*1010 = 6800 + 2020 = 8820 OR Address of P[i] [j] = BaseAddress + W((i–L1)+(j–L2)*M) Address of P[10] [20]= 6800 + 2((10-0)+(20-0)x50) = 6800 + 2 x 1010 = 6800 + 2020 = 8820 OR Address of P[I] [J] along the column = BaseAddress + W((I–LBR)+(J–LBC)*M) (where N is the number of rows, LBR = LBC = 1) Address of P[10][20]=6800+2((10-1)+(20-l)x50) = 6800 + 2 ( 9 + 19 x 50 ) = 6800 + 2 x 959 = 6800 + 1918 = 8718 (1 Mark for writing correct formula (for column major) OR substituting formula with correct values for calculating Address) (2 marks for calculating correct address) (c) Write a completeprograminc++toimplement a dynamically allocated Stack containingnamesofCountries. 4
  • 305.
    347 Ans. #include<iostream.h> #include<stdio.h> struct Node { charCountry [20] ; Node *Link; }; class Stack { Node *Top; public: Stack() {Top = NULL;} void Push() ; void Pop() ; void Display() ; ~Stack () ; }; void Stack::Push() { Node *Temp = new Node; gets(Temp -> Country); Temp -> Link = Top; Top = Temp; } void Stack::Pop() { if (Top !=NULL)
  • 306.
    348 { Node *Temp =Top; Top = Top -> Link; delete Temp; } else cout<<“stack Empty”; } void Stack::Display() { Node *Temp = Top; while (Temp! = NULL) { cout<<Temp -> Country <<endl; Temp = Temp -> Link; } } Stack::~Stack () { while (Top!=NULL) { NODE *Temp=Top; Top=Top->Link; delete Temp; } }
  • 307.
    349 void main () { Stack ST; char Ch; do { cout<<“p/O/D/Q” ; cin>>Ch; switch (Ch) { case ‘P’ : ST.Push(); break; case ‘O’ :ST.Pop(); break; case ‘D’ :ST.Disp(); } } while (Ch!=’Q’); } (d) Write a function int SKIPSUM(intA[ ] [3], int N,int M) in C++ to find and return the sum of elements from all alternate elements of a two-dimensional arraystartingfromA[0][0]. 2 Hint: Ifthefollowingisthecontentofthearray
  • 308.
    350 The function SKIPSUM()should add elementsA[0][0],A[0][2],A[1][l], A[2][0] andA[2][2]. Ans. int SKIPSUM(int A[ ][ 3 ], int N,int M) { int S=0: for(int I = 0; 1< N; 1++) for (int J = (I%2)?1:0; J<M; J = J+2) S = S + A [I][J]; return S; } OR int SKIPSlJM(int A[ ][3], int N, int M) { int S=0; for (int I = 0; 1< N; I++) for (int J = (I%2==0)? 0:1 ; J<M; J = J+2) S = S + A [I][J]; return S; } OR int SKIPSUM(int A[][3], int N, int M) { int I,J, S=O; for (I = 0; 1 < N; 1++) { if (I%2) //OR (1%2 !=0 ) OR (I%2 == 1) J = l;
  • 309.
    351 else J = 0; for( ; J<M; J = J+2) S = S + A[I][J]; } return S; } OR int SKIPSUM(int A[][3], int N, int M) { int S=0, C=0; for(int I = 0; 1< N; 1++) for (int J = 0; J<M; J++ ) { if (C%2 == 0) S = S + A[I][J]; C++; } return S; } OR int SKIPSUM(int A[][3], int N, int M) { int S=0, C=l; for(int I = 0; I<N; I++) for (int J = 0; J<M; J++ )
  • 310.
    352 { if (C%2 !=0) S = S + A[I][J]; C++; } return S; } OR int SKIPSUM (int A[][3], int N, int M) { int S=0; for(int I = 0; l< N; l++) for (int J = 0; J<M; J++ ) { if ((I+J)%2 == 0) S = S + A[I][J]; } return S; } OR Anyothercorrectequivalentfunctiondefinition (½ Mark for correct function header) (½ Mark for each correct loop) (½ Mark for checking alternate cells) (½ Mark for finding Sum of elements) (½ Mark for returning the Sum)
  • 311.
    353 (e) Evaluatethefollowingpostfixnotationofexpression: 2 (Showstatus of Stack after each operation) False, True, NOT, OR, True, False,AND, OR Ans. ElementScanned Stack False False True False,True NOT False, False OR False True False,True False False, True, False and False, False OR False RESULT = False OR Step 1: Push False Step 2: Push True False Step 3: NOT Push Pop Op2=True False False False
  • 312.
    354 Step 4 ORPush Pop Pop Op2=False Op1 =False False Op2=False False False False Step 5: Push True False Step 6: Push False True False Step 7: AND Push Pop Pop Op2=False Op1=False True Op2=False False False False False Step 8: OR Push Pop Pop Op2=False Op1=False Op2=False False False Step 9: Pop Result False OR Any other method for evaluating the given postfix expression showing the Stack Status. (½ Mark for correctly evaluating expression up to each operator (1 Mark only to be given for writing correct answer without showing the Stack Status)
  • 313.
    355 4. (a) Observetheprogramsegmentgivenbelowcarefullyandfilltheblanksmar- ked as Statement 1 and Statement 2 using tellg() and seekp() functions for performingtherequiredtask. 1 #include <fstream.h> class Client { long Cno; char Name[20], Email[30] ; public: //Function to allow user to enter the Cno, Name, Email void Enter() ; //Function to allow user to enter (modify) Email void Modify() ; long ReturnCno() {return Cno;} }; void ChangeEmail() { Client C; fstream F; F.open (“INFO.DAT”,ios::binary|ios::in|ios::out); long Cnoc;//Client’s no. whose Email needs to be changed cin>>Cnoc; while (F.read((char*)&C, sizeof(C))) { if (Cnoc==C.ReturnCno()) { C.Modify(); //Statement 1 int Pos = __________//To find the current position of file pointer
  • 314.
    356 // Statement 2 _______________//Tomove the file pointer to write the //modified record back onto the file //for the desired Cnoc F.write((char*)&C, sizeof(C)); } } F.close(); } Ans. Statement1: F. tellg (); Statement2: F. seekp(Pos-sizeof(C)) ; OR F.seekp(-sizeof(C), ios::cur); OR Anyequivalentcorrectmethod (½ Mark for each correct statement) (b) Write a function in C++ to count the words “this” and “these” present in a textfile“ARTICLE.TXT”. 2 [Note that the words “this” and “these” are complete words] Ans. void COUNT ( ) { ifstream Fil; OR ifstream Fil(“ARTICLE.TXT”); Fil.open(“ARTICLE.TXT”); char Word [80]   
  • 315.
    357 int C1 =0, C2 = 0 while (!Fil.eop()) { Fil>>Word; if (strcmp(Word,“this”) ==0) Cl++; else if (strcmp(Word,“these”) ==0) C2++; } cout<<“Count of -this- in file:”<<Cl; cout<<“Count of -these- in file:”<<C2; OR cout<<“Count of -this- and —these- -in file:"<<Cl+C2; Fil.close(); //gnore } OR void COUNT( ) { OR if stream Fil(“ARTICLE.TXT”); ifstream Fil; char Word[80] ; Fil.open(“ARTICLE. TXT”) ; int C = 0; while(!Fil.eof()) { Fil>>Word; if (strcmp(Word,“this”)==0||strcmp(Word,“these”) ==0) C++; } cout<<“Count of -this- and -these- in file:"<<C; Fil.close(); //Ignore      
  • 316.
    358 } OR void COUNT( ) { ifstreamFil(“ARTICLE.TXT”); //OR fstream Fil; // Fil. open(“ARTICLE. TXT”, ios: : in); char STR[l0]; int Cl=0, C2=0; while (Fil.getline (STR,l0, '')) { if (strcmp(STR,“this”)==0) Cl++; else if (strcmp(STR,“these”)==0) C2++; } } cout<<“Count of -this- in file:”<<Cl; cout<<“Count of -these- in file:”<<C2; Fil.close() ;//Ignore } OR cout<<“Count of -this- and -these- in file:”<<Cl+C2; OR void COUNT ( ) { ifstream Fil; OR ifstreamFil(“ARTICLE.TXT"); Fil. open(“ARTICLE.TXT”); char Word[80] ,Ch;      
  • 317.
    359 int Cl =0,C2 = 0, I=O; while(Fil.get(Ch)) { if (Ch! = ' ') Word[I++] = Ch; else { Word[I] = ‘0’; if (strcmp (Word,“this”)==0) Cl++; else if (strcmp(Word,“these”)==0) C2++; I=0, } } cout<<“Count of -this- in file:" <<Cl; cout<<“Count of -these- in file:" <<C2; OR cout<<“Count of -this- and -these- in file: “<<Cl+C2; Fil.close(); //Ignore } OR Anyothercorrectfunctiondefinition (½ Mark for opening ARTICLE. TXT correctly) (½ Mark for reading each word (Whichever method adopted) from the file) (½ Mark for comparing the word with ‘this’and ‘these’and incrementing counter(s) (½ Mark for displaying the individual count of ‘this’ and ‘these’ or the total count of ‘this’ and ‘these’ with/without the Text Message)   
  • 318.
    360 (c) Write afunction in C++ to search and display details of all flights, whose destination is“Mumbai”fromabinary file “FLIGHT.DAT”.Assuming the binaryfileiscontainingtheobjectsofthefollowingclass. 3 class FLIGHT { int Fno; //Flight Number char From[20]; //Flight Starting Point char To[20]; //Flight Destination public: char* GetFrom() {return From;} char* GetTo() {return To;} void Enter() {cin>>Fno;gets(From);gets(To);} void Display(){cout<<Fno<<“:”<<From<<“:”<<To<<endl;} }; Ans. void Read () { FLIGHT F; ifstream fin; fin.open(“FLIGHT.DAT”, ios::binary) ; OR ifstream fin (“FLIGHT. DAT”, iC;s: :binary) ; while(fin.read((char*)&F, sizeof(F))) { if (strcmp(F. GetTo(),“Mumbai”)) F.Display() ; } fin.close(); //Ignore }
  • 319.
    361 OR void Read () { FLIGHTF; ifstream fin; fin” open (“FLIGHT. DAT”, ios:: binary) ; OR ifstream fin (“FLIGHT. DAT” , ios:: binary; if (fin) { fin.read((char*)&F, sizeof (F)); while(!fin.eof()) { if (strcmp(F. GetTo(),“Mumbai”)) F.Display(); fin.read((char*)&F,sizeof(F)) } fin.close(); //Ignore } OR Anyothercorrectfunctiondefinition (½ Mark for opening FLIGHT DAT correctly) (½ Mark for reading each record from FLlGHT.DAT) (½ Mark for correct loop / checking end of file) (1 Mark for comparing value returned by GetTo() with “Mumbai”} (½ Mark for displaying the matching record) 5. (a) What do you understand by Candidate Keys in a table? Give a suitable exampleofCandidateKeysfromatablecontainingsomemeaningfuldata. 2
  • 320.
    362 Ans. A tablemay have more than one such attribute/group of attribute that identi- fies a tuple uniquely, all such attribute(s) are known as Candidate Keys. Table:Item Ino Item Qty I01 Pen 560 I02 Pencil 780 I04 CD 450 I09 Floppy 700 I05 Eraser 300 I03 Duster 200 (1 Mark for writing correct definition of Candidate Key) (1 Mark for giving suitable example) (b) Consider the following tables STORE and SUPPLIERS and answer (bl) and (b2) parts of this question: Table:STORE
  • 321.
    363 Table:SUPPLIERS (b1) WriteSQLcommandsforthefollowingstatements: 4 (i)To display details of all the items in the Store table in ascending order of LastBuy. Ans. SELECT * FROM STORE ORDER BY LastBuy; (1 Mark for correct query) (½ Mark for partially correct answer, (ii) To display ItemNo and Item name of those items from Store table whose Rate is more than 15 Rupees. Ans. SELECT ItemNo, Item..In FROM STORE WHERE Rate >15; (1 Mark for correct query) (½ Mark for partially correct answer, (iii) To display the details of those items whose Supplier code (Scode) is 22 or Quantity in Store (Qty) is more than 110 from the table Store. Ans. SELECT * FROM STORE WHERE Scode = 22 OR Qty >110; (1 Mark for correct query) (½ Mark for partially correct answer, (iv) TodisplayMinimumRateofitemsforeachSupplierindividuallyasperScode from the table Store. Ans. SELECT Scode, MIN(Rate) FROM STORE GROUP BY Scode; (1 Mark for correct query) (½ Mark for partially correct answer, (b2) GivetheoutputofthefollowingSQLqueries: 2 Note: In all output Questions ignore Column Headings
  • 322.
    364 (i) SELECT COUNT(DISTINCTScode) FROM Store; Ans. COUNT(DISTINCT Scode) (½ Mark for correct Output) (ii) SELECT Rate*Qty FROM Store WHERE ItemNo=2004; Ans. RATE*QTY 880 (½ Mark for correct Output) (iii) SELECT Item,Sname FROM Store S, Suppliers P WHERE S.Scode=P.Scode AND ItemNo=2006; Ans. ITEM SNAME Gel Pen Classic Premium Stationers (½ Mark for correct Output) (iv) SELECT MAX(LastBuy) FROM Store; Ans. MAX (LASTBUY) 24-Feb-10 (½ Mark for correct Output) 6. (a) Verifythefollowingalgebraically. 2 (A’+B’).(A+B)=A’.B+A.B’ Ans. LHS (A’ +B’ ) . (A+B) = A’.A + A’.B + A.B’ + B’.B = 0 + A’.B + A.B’+ 0 = A’.B + A.B’ = RHS (Verified) OR Anyothervalidalgebraicverification (2 Marks for verifying LHS = RHS OR RHS = LHS )
  • 323.
    365 (b) WritetheequivalentBooleanExpressionforthefollowingLogiccircuit: 2 Ans.(P + Q’) . (Q + R’) (2 Marks for the final expression (P + Q’) . (Q + R’)) OR (1 Mark for any of the correct terms out of (P + Q’) or (Q + R’)) (c) Write the POS form of a Boolean function H, which is represented in a truth tableasfollows: 1 Ans. (X + Y + Z’).(X’+ Y + Z’) . (X’+ Y’+ Z) OR H(X,Y,Z) = Π (1, 5, 6) (1 Mark for the correct POS form) Note: Deduct % mark if wrong variable names are used
  • 324.
    366 (d) ReducethefollowingBooleanExpressionusingK-Map: 3 Ans.F(U, V, W, Z) = Σ (3, 5, 7, 10, 11, 13, 15) U’V’ U’V UV UV’ W’ Z’ 0 4 12 8 W’ Z 1 1 5 1 13 9 W’ Z 1 3 1 7 1 15 1 11 W Z’ 2 6 14 1 10 OR W’Z’ W’Z WZ WZ’ U’V’ 0 1 1 3 2 U’V 4 1 5 1 7 6 U V 12 1 13 1 15 14 U V’ 8 9 1 11 1 10 F(U,V,W,Z) = WZ + VZ + UV’W (½ Mark for drawing K-Map with correct variable names) (½ Mark for placing all 1s at correct positions in K-Map) (½ Mark for each grouping) (½Markforwritingfinalexpressioninreduced/minimalform) 7. (a) What was the role ofARPANET in the Computer Network? 1 Ans. ThefirstcomputernetworkwasjointlydesignedbyTheAdvanced-Research ProjectsAgency(ARPA)andDepartmentofDefence(DoD)ofUnitedStates in 1969 and was calledARPANET. It was an experimental project, which connected a few computers from some of the reputed universities of USA andDoD.ARPANETallowedaccesstocomputerresourcesharingprojects. ThisARPANETwashandedovertoDefenceCommunicationAgency(DCA) forfurtherdevelopment. (1 Mark for mentioning that ARPANET was the first computer network) OR (½ Mark if only the expansion of ARPANET is mentioned)
  • 325.
    367 (b) Whichofthefollowingisnotanunitfordatatransferrate? 1 (i)bps (ii) abps (iii) gbps (iv) kbps Ans. (ii)abps (1 Mark for writing correct option) (c) WhatisthedifferencebetweenTrojanHorseandVirusintermsofcomputers? 1 Ans. TROJAN HORSE: “Malware” computer programs presented as useful or harmless in order to induce the user to install and run them. VIRUS:Virusisamaliciousprogramthatdamagesdataandfilesandcauses harmtocomputersystem. (1 Mark for mentioning anyone valid difference) OR (½ Mark for correct definition of each term) (d) What term we use for a software/hardware device, which is used to block, unauthorizedaccesswhilepermittingauthorizedcommunications.Thistermis also used for a device or set of devices configured to permit, deny, encrypt, decrypt,orproxyall(inandout)computertrafficbetweendifferentsecurity domains based upon a set of rules and other criteria. 1 Ans. Firewall (1 Mark for writing £orrect term) (e) “LearnTogether” is an educational NGO. It is setting up its new campus at Jabalpurforitswebbasedactivities.Thecampushas4compoundsasshown inthediagrambelow: 4
  • 326.
    368 Center to centerdistances between various Compounds as per architectural drawings(inMetre)isasfollows: Expected Number of Computers in each Compound is as follows : (e1) Suggest a cable layout of connections between the compounds. 1 Ans. OR
  • 327.
    369 (e2) Suggest themost suitable place (i.e. compound) to house the server for this NGO.Also, provide a suitable reason for your suggestion. 1 Ans. TrainingCompoundasitcontainsmaximumnumberofcomputers. (½ Mark for mentioning the correct compound) (½ Mark for correct justification) OR (1 Mark for any other location with a valid justification) (e3) Suggesttheplacementofthefollowingdeviceswithjustification: 1 (i) Repeater (ii) Hub/Switch Ans. (i) ARepeatershouldbeplacedwhenthedistancebetweenanytwocon- necting compounds exceeds 70 m. (ii) Every compound will need one Hub I Switch, to send signals to all of the workstations connected to it OR Anydiagrammaticrepresentationwithvalidjustification (½ Mark for each correct placement of Devices with valid justifications) (e4) The NGO is planning to connect its International office situated in Mumbai, whichoutofthefollowingwiredcommunicationlink,youwillsuggestfor averyhighspeedconnectivity? 1 (1 Mark for mentioning any valid connectivity or topology or diagram connecting various compounds inside the campus)
  • 328.
    370 (i) TelephoneAnalogLine (ii) OpticalFiber (iii)EthernetCable Ans. (ii) OpticalFiber (1 Mark for correct option /answer) (f) Writethefullformsofthefollowing: 1 (f1) GNU (f2) XML Ans (f1) GNU’snotUnix (f2) eXtensibleMarkupLanguage (½ Mark for each full form) (g) Write one advantage of each for Open Source Software and Proprietary Software. 1 Ans. An Open Source Software is freely and liberally licensed because of which users have right to study, change. and improve its design and source code. AProprietary Software has a copyright owner, who can restrict the user's control over the software, its modification, or restrictions in publishing of modifiedorunmodifiedversions. (½ Mark for writing correct advantage / definition for Open Source Software) (½ Mark for writing correct advantage / definition for Proprietary Software) QUESTION PAPER CODE 91 EXPECTEDANSWERS 1. (a) What is the difference between call by value and call by reference?Also, give a suitable C++ code to illustrate both. 2 Ans. Call by value: The formal parameter makes a copy of actual parameter. It does not make the changes In actual parameter If the changes are done In formalparameters. Call by reference:The formal parameter Is an alias of actual parameter.The changes made In the formal parameter are reflected In actual parameter. It is preceded by &.
  • 329.
    371 vcid Caloulato(int A,int& B )// A is oall by value, { // B is call by roforonco A++; a+=A; } (½ Mark for each corroct explanatIon of Call by va/ueand Call by referenco) (½ Mark for each corroct examplo,of Call by value and Call by reference) OR (Full 2 Marks for correct examples demonstrating tho dlfferonce botween Call by value and Call by roforonce) OR (Only 1 Mark to be awarded for ExplanatIon glvon without supporting examples) (b) WhichC++headerfile(s)willbeessentiallyrequiredtobeincludedtorun/ executethefollowingC++code: 1 void main() { int Rno=24; char Name [] =” Amen Singhania”; cout<<setw(lO)<<Rno<<setw(20)<<Name<<endl; } Ans. iostream.h iomanip.h OR iomanip.h - (As iostream.h is included in iomanip.h) (½ Mark for writing each correct header file) OR (Full Mark for mentioning only iomanip.h ) Note: Ignore any other header files, if mentioned.
  • 330.
    372 (c) RewritethefollowingC++programcodeafterremovingthesyntaxerror(s) (ifany).Underlineeachcorrection. 2 include<iostream.h> class FLIGHT { long FlightCode; char Description[25]; public void AddInfo ( ) { cin>>FlightCode; gets (Description) ; { void ShowInfo () ( cout<<FlightCode<<“:”<<Description<<endl; } } ; void main() { FLIGHT F; AddInfo.F(); ShowInfo.F(); } Ans. #include <iostream.h> / / Error 1 #include <stdio.h> / / Error 2 class FLIGHT { long FlightCode; not required if gets( ) is re- placed with cin.getline( ) or cin
  • 331.
    373 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 } (½ Mark for each correction) OR (1 mark for identifying at least three errors, without suggesting correction) (d) Findtheoutputofthefollowingprogram: 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;
  • 332.
    374 T.Z+=Step; } void MoveOut(THREE_D &T,int Step=l) { T.X-=Step; T.Y+=Step; T.Z-=Step; } void main () { THREE_D Tl={lO,20,5},T2={30,lO,40}; MoveIn(T1); MoveOut(T2,5) ; cout<<Tl.X<<“,”<<Tl.Y<<“,”<<T1.Z<<endl; cout<<T2.X<<“,”<<T2.Y<<“,”<<T2.Z<<endl; MoveIn(T2,l0); cout<<T2.X<<“,”<<T2.y<<“,”<<T2.Z<<endl; } Ans. 11, 19, 6 25, 15, 35 35, 5, 45 (1 Mark for each line with correct values) OR (½ Mark for any two correct values in each line) Note: Deduct ½ Mark if any/all ',' missing Deduct ½ Mark if endl is not considered at the right positions
  • 333.
    375 (e) Find.theoutputofthefollowingprogram: 2 #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’|| Msg[Cnt]==’a’) Msg[Cnt]=CH; else if (Cnt%2==0) Msg[Cnt]=toupper(Msg[Cnt]); else Msg[Cnt]=Msg[Cnt-l]; } } void main () { char MyText [] =” ApEACeDriVE”; MyCode(MyText,’@’); cout<<“NEW TEXT:”<<MyText<<endl; } Ans. NEW TEXT :@@e@ccddIIe (½ Mark for writing @,@,e as the first three characters)
  • 334.
    376 (½ Mark forwriting @,c,c as the next three characters) (½ Mark for writing d,d, I as the next three characters) (½ Mark for writing I,e as the next two characters) Note:Deduct ½ Mark for not mentioning NEW TEXT: (f) Thefollowingcodeisfromagame,whichgeneratesasetof4randomnumbers. Prafulisplayingthisgame,helphimtoidentifythecorrectoption(s)outofthe fourchoicesgivenbelowasthepossiblesetofsuchnumbersgeneratedfrom the program code so that he wins the game. Justify your answer. 2 #include <iostream.h> #include <stdlib.h> const int LOW=25; void main () { randomize() ; int P01NT=5,Number; for (int I=1;I<=4;I++) { Number=LOW+random(POINT); Cout<<Number<<“:”; P0INT--; } } (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: Justificationisasfollows:
  • 335.
    377 I POINT Number MinimumMaximum 1 5 25 29 2 4 25 28 3 3 25 27 4 2 25 26 Theonlyoptionthatsatisfiesthesevaluesisoption(iv). (1 Mark for mentioning correct option) (1 Mark for any valid justification) Note: Only ½ Mark to be given if only options (i) & (iv) are mentioned as correct options; no other combination of options is acceptable; 2. (a) What do you understand by Data Encapsulation and Data Hiding ?’Also, giveanexampleinC++toillustrateboth. 2 Ans. Data Encapsulation:Wrapping up of data and functions together in a single unit is known as Data Encapsulation. In a class, we wrap up the data and functionstogetherinasingleunit. DataHidina:Keepingthedatainprivate/protectedvisibilitymodeoftheclass to prevent it from accidental change is known as Data Hiding. class Computer { char CPU[lO] ;int RNM; //Data Hiding public: //Data Encapeulation void STOCK(); void SHOW(); }; (½ MarkforeachcorrectexplanationofDataEncapsulationandDataHiding) (½ Marie for each correct example of Data Encapsulation and Data Hiding) OR
  • 336.
    378 (2 Marks forexplaining the concept of the terms through suitable examples) OR (Only 1 Mark to be awarded for Explanation given without any example) (b) Answerthequestions(i)and(ii)aftergoingthroughthefollowingclass: 2 class Exam { int Rno,MaxMarks,MinMarks,Marks; public: Exam ( ) //Module 1 { Rno=101;MaxMarks=l00;MinMarks=40;Marks=75; } Exam (int Prno, int Pmarks) //Module 2 { Rno=Prno;MaxMarks=l00;MinMarks=40;Marks=Pmarks; } ~Exam () //Module 3 { cout<<“Exam Over”<<endl; } void Show () //Module 4 { cout<<Rno<<“:”<<MaxMarks<<“:”<<MinMarks<<endl; cout<<“[Marks Got]”<<Marks<<endl; } };
  • 337.
    379 (i) As perObject Oriented Programming, which concept is illustrated by Module 1 and Module 2 together? Ans. Polymorphism OR ConstructorOverloading OR FunctionOverloading (1 Mark for mentioning the correct concept) (ii) What is Module 3 referred as ? When do you think, Module 3 will be invoked/called? Ans. Destructor. It is invoked as soon as the scope of the object gets over. (½ Mark for identifying it as Destructor) (½ Mark for mentioning correctly when it be called/invoked) (c) DefineaclassSTOCKinC++withfollowingdescription: 4 PrivateMembers ICode of type integer (Item Code) Item of type string (Item Name) Price of type float (Price of each item) Qty of type integer (Quantity in stock) Discountoftypefloat(Discountpercentageontheitem) AmemberfunctionFindDisc()tocalculatediscountasperthefollowing rule: If Qty<=50 Discountis0 If 50<Qty<=100 Discountis5 If Qty>100 Discountis10 PublicMembers A function Buy() to allow user to enter values for ICode, Item, Price, QtyandcallfunctionFindDisc()tocalculatetheDiscount.
  • 338.
    380 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(); } void STOCK::FindDisc() { if (Qty<=50) Discount=0; else if (Qty<=100) Discount=5; // =0.05; else
  • 339.
    381 Discount=10; // =0.1; } voidSTOCK::ShowAll() { cout<<ICode<<’t’<<Item<<’t’<<Price<<’t’<<Qty <<’t’<<Discount<<endl; } (½ Mark for correct syntax for class header) (½ Mark for correct declaration of data members) (1 Mark for correct definition of FindDisc()) (1 Mark for correct definition of Buy() with proper invocation of FindDisc() function) (1 Mark for correct definition of ShowAll()) NOTE: Deduct ½ Mark if FindDisc() is not invoked properly inside Buy() function (d) Answerthequestions(i)to(iv)basedonthefollowing: 4 class Director { long DID; //Director Identification Number char Name[20]; protected: char Description[40]; void Allocate () ; public: Director() ; void Assign () ; void Show () ; } ;
  • 340.
    382 class Ractory:public Director } intFID; //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) WhichtypeofinheritanceoutofthefollowingisillustratedintheaboveC++ code? (a) SingleLevelInheritance (b) MultiLevelInheritance (c) MultipleInheritance Ans. (b) MultilevelInheritance (1 Mark for mentioning correct option)
  • 341.
    383 (ii) Write thenames of data members, which are accessible by objects of class typeShowRoom. Ans. None (1 Mark for correct answer) Note: No marks to be awarded for any partial/alternative answer (iii) Write the names of all member functions which are accessible by objects of class type ShowRoom. Ans. Enter(), Display() (1 Mark for correct answer) Note: No marks to be awarded for any partial/alternative answer Ignore men- tion of Constructor(s) (iv) Writethenamesofallmembers,whichareaccessiblefrommemberfunctions of class Factory. Ans. FID, Address, NOE, Description, Input(), Output(), Assign(), Show(), Allocate() (1 Mark for correct answer) Note: No marks to be awarded for any partial/alternative answer Ignore men- tion of Constructor(s) 3. (a) Write a function REASSIGNO in C++, which accepts an array of integers and its size as parameters and divide all those array elements by 5 which are divisibleby5andmultiplyotherarrayelementsby2. 3 Sample Input Data of the array ContentofthearrayaftercallingREASSIGNOfunction
  • 342.
    384 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; } OR void REASSIGN(int Arr[ ],int Size) { for (int i=0;i<Size;i++) Arr[i]%5 ? Arr[i]/=5 : Arr[i]*=2; } OR Any other correct equivalent function definition ( ½ Mark for correct Function Header) ( ½ Mark for correct loop) ( ½ Mark for correct checking of divisibility of array elements by 5) ( ½ Mark for correct placing of else OR correct checking of non divisibil- ity of array elements by 5) (½ Mark for each correct assignment) (b) An array T[90][100] is stored in the memory along the column with each of the elementsoccupying4bytes.Findoutthememorylocationfortheelement T[10][40], if the BaseAddress of the array is 7200. 3 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 x 90]
  • 343.
    385 = 7200 +4[10+3600] = 7200 + 4 x 3610 = 7200 + 14440 = 21640 OR Address of T[I][J] along the column = BaseAddress + W [(I-LBR)+(J-LBC)* N] (where N is the number of rows, LBR=LBC = 1) Address of T[10][40]=BaseAddress + 4[ (10 - 1) +(40 - l)x 90] = 7200+4[9 + 39 x 90] = 7200+4[9 + 3510] = 7200+4 x 3519 = 7200+14076 = 21276 (1 Mark for writing correct formula (for column major) OR. substituting formula with correct values for calculating Address) (2 marks for calculating correct address) (c) Write a complete program in C++ to implement a dynamically allocated QueuecontainingnamesofCities. 4 Ans. #include <iostream.h> #include <conio.h> struct NODE { char City[20]; NODE *Next; }; class Queue
  • 344.
    386 { NODE *Rear,*Front; puplic: Queue() {Rear=NULL;Front=NULL;} voidQinsert(); void Qdelete(); void Qdisplay (); ~Queue(); } ; void Queue::Qinsert() { NODE *Temp; Temp=new NODE; cout<<”Data:”; gets (Temp->City); Temp->Next=NULL; if (Rear==NULL) { Rear=Temp; Front=Temp; } else { Rear–>Next=Temp; Rear=Temp; }
  • 345.
    387 } 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) { cout<<Temp->City<<endl; Temp=Temp->Next; } } Queue:: ~Queue()//Destructor Function { while (Front!=NULL) {
  • 346.
    388 NODE *Temp=Front; Front=Front->Next; deleteTemp; } } void main () { Queue QU; char Ch; do { : : } while (Ch!=’Q’); } (4 Marks for correct program) OR (Full 4 Marks for correct logic of either Insertion OR Deletion functions for Dynamically Allocated Queue.) OR (2 Marks for defining class with Constructor, function prototypes for Insertion & deletion and Destructor or equivalent using Structures.) (d) Write a function intALTERSUM (int B[ ] [5], int N, int M in C++ to find andreturnthesumofelementsfromallalternateelementsofatwo-dimensio- nalarraystartingfromB[0][0]. 2 Hint:Ifthefollowingisthecontentofthearray:
  • 347.
    389 The function shouldadd 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; } OR //Sample Code 2 int ALTERSUM(int B[][5],int N,int M) { int Sum=0,J=0; for (int I=0;I<N;I++) { for (;J<M;J+=2) Sum+=B[I][J] ; J-=M; } return Sum; } OR //Sample Code 3 int ALTERSUM(int B[][5],int N,int M)
  • 348.
    390 { int *P=&B[0][0],Sum=0; for (intI=0;I<M*N;I+=2) { Sum+=(*P); P+=2; } return Sum; } OR //Sample Code 4 int ALTERSUM (int B[][5], int N, int M) { int S=0, C=0; for(int I = 0; 1< N; 1++) for (int J = 0; J<M; J++ ) { if (C%2 == 0) S = S + B[I][J]; C++; } return S; } OR //Sample Code 5 int ALTERSUM(int B[][5],int N,int M) {
  • 349.
    391 int Sum=0; for (intI=0;1<N;1++) for (int J=0;J<M;J++) if ((1+J)%2==0) Sum+=B [I][J] ; return Sum; } OR //Sample Code 6 int ALTERSUM(int B[][5],int N,int M) { int Sum=0; for (int I=0;1<N;1++) for (int J=0;J<M;J++) { if ((1%2==0 && J%2=0)||(1%2!=0 && J%2!=0)) Sum+=B [I][J] ; } return Sum; } Note: Kindly note Sample Code 5 and 6 will not work in case of Even Di- mensionalArrays, but keeping in view of the Sample given for 3x3 array thesolutionisacceptable. (½ Mark for correct loops) (1 Mark for finding Sum of alternate cells) (½ Mark for returning the Sum) (e) Evaluatethefollowingpostfixnotationofexpression: 2 (Show status of Stack after each operation)
  • 350.
    392 True, False, NOT,OR, False, True, OR, AND Ans. ElementScanned Stack Content True True False True,False NOT True,True OR True False True,False True True, False,True OR True,True AND True OR Step 1: Push True Step 2: Push False True Step 3: NOT Push Pop Op2=False True True True Step 4 OR Push Pop Pop Op2=True Op1 =True Op2=True True True
  • 351.
    393 Step 5: Push False True Step6: Push True False True Step 7: OR Push Pop Pop Op2=True Op1=False False Op2=True True True True True Step 8: AND Push Pop Pop Op2=True Op1=True Op2=True True True Step 9: Pop Result True OR Any other method for evaluating the given postfix expression showing the Stack Status. (½ Mark for correctly evaluating expression up to each operator) OR (1 Mark only to be given for writing correct answer without showing the Stack Status) 4. (a) Observetheprogramsegmentgivenbelowcarefullyandfilltheblanksmar- ked as Statement 1 and Statement 2 using tellg() and seekp() functions for performingtherequiredtask. 1
  • 352.
    394 #include <fstream.h> class Customer { longCno;char Name[20],Mobile[12]; public: //Function to allow 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 (Choc==C.GetCno()) { C.Modify (); //Statement 1 int Pos=_____________//To find the current position of file pointer //Statement 2 _____//To move the file pointer to write the //modified record back onto the file
  • 353.
    395 //for the desiredCnoc F.write((char*)&C,sizeof(C)); } } F. close( ) ; } Ans. Statement 1: File.tellg() ; Statement 2: File.seekp(Pos-sizeof(C)); OR File.seekp(-l*sizeof(C) ,ios::cur); (½ Mark for each correct Statement) (b) Write a function in C++ to count the words “to” and “the” present in a text file “POEM.TXT”. 2 [Note that the words “to” and “the” are complete words] Ans. void COUNT () { ifstream Fil; Fil. open (“POEM.TXT”); OR ifstream Fil (“POEM. TXT”); char Word[80] ; int Cl = 0, C2 = 0; while(!Fil.eof()) { Fil>>Word; if (strcmp (Word, “to”) ==0) Cl++; else if (strcmp (Word, “the”) ==0) C2++;   
  • 354.
    396 } cout<<”Count of -to-in file:" <<Cl; cout«”Count of -the- in file:”«C2; OR cout<<”Count of -to- and -the- in file:”<<Cl+C2; Fil.close(); //Ignore } OR void COUNT ( ) { ifstream Fil(“POEM.TXT”); // OR fstream Fil; // Fil.open(“POEM.TXT”,ios::in); char STR[l0]; int Cl=O, C2=0; while (Fil.getline(STR,l0,'')) { if (strcmp (STR, “to”) ==0) Cl++; else if (strcmp(STR, “the”) ==0) C2++; } cout<<”Count of -to- in file:”<<Cl; cout<<”Count of -the- in file:”<<C2; OR cout<<”Count of -to- and -the- in file:”<<Cl+C2; Fil.close(); //Ignore }      
  • 355.
    397 OR void COUNT() { ifstream Fil; ORifstream Fill(“POEM.TXT”); Fil. open (“POEM.TXT”); char Word[BO], Chi int Cl =0, C2=0, 1=0; while(Fil.get(Ch)) { if (Ch! = ‘ ‘) Word[1++] = Chi else { Word[I] = ‘0’; if (strcmp (Word, “to”) ==0) Cl++; else if (strcrap (Word, “the”) ==0) C2++; 1=0; } } cout<<”Count of -to- in file:”<<Cl; cout<<”Count of -the- in file:”<<C2; OR cout«”Count of -to- and -the- in Fil.close(); //1gnore } OR      
  • 356.
    398 Any-othercorrectfunctiondefinition (½ Mark foropening POEM. TXT correctly) (½ Mark for reading each word (using any method) from the file) (½ Mark for comparing the word with ‘to’ and ‘the’ ) (½ Mark for incrementing counter(s)) (c) Write a function in C++ to search and display details. of all trains, whose destinationis“Delhi”.fromabinaryfile“TRAIN.DAT”.Assumingthebinary fileiscontainingtheobjectsofthefollowingclass. 3 class TRAIN { int 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);} void Show () {cout<<Tno<<“:”<<From<<“:”<<To<<endl;} }; Ans. void Read ( ) { TRAIN T; ifstream fin; fin. open (“TRAIN.DAT”, ios::binary); OR ifstream fin (“TRAIN.DAT”, ios::binary); while(fin.read((char*)&T, sizeof(T))) { if(strcmp(T.GetTo() ,”Delhi”)==O) T.Show() ;
  • 357.
    399 } fin.close(); //Ignore } OR Anyothercorrectfunctiondefinition (½ Markfor opening TRAIN .DAT correctly) (½ Mark for reading each record from TRAIN.DAT) (½ Mark for correct loop / checking end of file) (1 Mark for comparing value returned by GetTo() with “Delhi”) (½ Mark for displaying the matching record) 5. (a) WhatdoyouunderstandbyPrimaryKey?GiveasuitableexampleofPrimary Keyfromatablecontainingsomemeaningfuldata. 2 Ans. An attribute or set of attributes which are used to identify a tuple uniquely is known as Primary Key Table:Item Ino Item Qty I01 Pen 300 I02 Pencil 780 I04 CD 450 I09 Floppy 700 (1 Mark for writing correct definition/purpose of valid Primary Key) (1 Mark for giving suitable example) OR (2 Marks for illustrating the purpose of Key with/without showing it as a part of a Table) (b) Consider the following tables STOCK and DEALERS and answer (b1) and (b2) parts of this question: Table: STOCK PRIMARY KEY
  • 358.
    400 Table:DEALERS (b1) WriteSQLcommandsforthefollowingstatements: 4 (i)To display details of all Items in the Stock table in ascending order of StockDate. Ans. SELECT * FROM STOCK ORDER BY StockDate; (1 Mark for correct query) (½ Mark for partially correct answer) (ii) To display ItemNo 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; (1 Mark for correct query) (½ Mark for partially correct answer) (iii) Todisplaythedetailsofthoseitemswhosedealercode(Dcode)is102 or Quantity in Stock (Qty) is more than 100 from the table Stock. Ans. SELECT * FROM STOCK WHERE Dcode=102 OR Qty >100; (1 Mark for correct query) (½ Mark for partially correct answer)
  • 359.
    401 (iv) TodisplayMaximumUnitPriceofitemsforeachdealerindividuallyas per Dcodefrom the table Stock. Ans. SELECT Dcode, MAX (UnitPrice) FROM STOCK GROUP BY Dcode; OR Any other query that will give an equivalent output (1 Mark for correct query) (½ Mark for partially correct answer) (b2) GivetheoutputofthefollowingSQLqueries: 2 (i) SELECT COUNT(DISTINCT Dcode) FROM Stock; Ans. Count(DISTINCT Dcode) 3 (½ Mark for correct output) (ii) SELECT Qty*UnitPrice FROM Stock WHERE ItemNo=5006; Ans. Qty*UnitPrice 4400 (½ Mark for correct output) (iii) SELECT Item,Dname FROM Stock S, Dealers D WHERE S.Dcode=D.DcodeAND ItemNo=5004; Ans. Item Dname Eraser Big Clear Deals (½ Mark for correct output) (iv) SELECT MIN(StockDate) FROM Stock; Ans. MIN (StockDate) 01-Jan-09 (½ Mark for correct output) 6. (a) Verifythefollowingalgebraically: 2 X’.Y + X.Y’ = (X’+Y’).(X+Y)
  • 360.
    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 OR L.H.S. X’.Y + X.Y’ = (X’.Y+X) (X’.Y+Y’) = (X’+X).(Y+X).(X’+Y’).(Y+Y’) = 1.(X+Y).(X’ +Y’).1 = (X+Y).(X’+Y’) = R.H.S. (2 Marks for correct verification) (b) WritetheequivalentBooleanExpressionforthefollowingLogicCircuit: 2 Ans. (U’+V) . (V’+W) (2 Marks for the final expre~sion (U’+V).(V’+W)) OR (1 Mark for anv one of the correct terms out of (U'+V) or (V'+W)) (c) Write the SOPform of a Boolean function G, which is represented in a truth tableasfollows: 1
  • 361.
    403 Ans. G(P,Q,R)=P’.Q.R’+P’.Q.R+P.Q’.R’+P.Q.R’+P.Q.R OR G(P,Q,R) =Σ(2,3,4,6,7) (1 Mark for the correct SOP form) Note: Deduct ½ mark if wrong variable names are used (d) ReducethefollowingBooleanExpressionusingK-Map: 3 F (A,B,C,D) = Σ (3,4,5,6, 7,13,15) Ans. A’B’ A’B AB AB’ C’ D’ 0 1 4 12 8 C’ D 1 1 5 1 13 9 C D 1 3 1 7 1 13 11 C D 2 1 6 14 10 OR C’D’ C’D CD CD’ A’B’ 0 1 1 3 2 A’B 1 4 1 5 1 7 1 6 A B 12 1 13 1 15 14 A B’ 8 9 11 10
  • 362.
    404 F(A,B,C,D) = A’B+ BD + A’CD (½ Mark for drawing K-Map with correct variable names) (½ Mark for placing all 1s at correct positions in K-Map) (½ Mark for each grouping) (½ Mark for writing final expression in reduced/minimal form) 7. (a) What was the role ofARPANET in the Computer Network? 1 Ans. ThefirstcomputernetworkwasjointlydesignedbyTheAdvancedResearch ProjectsAgency(ARPA)andDepartmentofDefence(DoD)ofUnitedStates in 1969 and was calledARPANET. It was an experimental project, which connected a few computers from some of the reputed universities of USA andDoD.ARPANETallowedaccesstocomputerresourcesharingprojects. ThisARPANETwashandedovertoDefenceCommunicationAgency(DCA) forfurtherdevelopment. (1 Mark for mentioning that ARPANET was the first computer network) OR (½ Mark if only the expansion of ARPANET is mentioned) (b) Whichofthefollowingisnotaunitfordatatransferrate? 1 (i) mbps (ii) kbps (iii) sbps (iv) gbps Ans. (iii)sbps (1 Mark for the correct option/answer) (c) What is the difference betweenVirus andWorms in the computers? 1 Ans. Virus:Virus is a malicious program that damages data and files and causes harmtocomputersystem. Worms:Worms disrupt services and create system management problems. In some cases worms can install viruses that cause damage to system. (1 Mark for mentioning anyone valid difference) OR (½ Mark for correct definition of each term)
  • 363.
    405 (d) Whattermdoweuseforasoftware/hardwaredevice,whichisusedtoblock unauthorizedaccesswhilepermittingauthorizedcommunications?Thisterm isalsousedforadeviceorsetofdevicesconfiguredtopermit,deny,encrypt, decrypt,orproxyall(inandout)computertrafficbetweendifferentsecurity domains basedupon a set of rules and other criteria. 1 Ans. Firewall (1 Mark for writing correct term) (e) “Vidya for All” is an educational NGO. It is setting up its new campus at Jaipurforitsweb-basedactivities.Thecampushasfourbuildingsasshownin thediagrambelow: 4 Center to center distances between various buildings as per architectural drawings(inmeters)isasfollows: ExpectedNumberofComputersineachBuildingisasfollows:
  • 364.
    406 (el) Suggestacablelayoutofconnectionsbetweenthebuildings. Ans. OR (1 Markfor mentioning any valid connectivity or topology or dia- gram connecting various buildings inside the campus) (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. TrainingBuildingasitcontainsmaximumnumberofcomputers. (½ Mark for mentioning the building) (½ Mark for correct justification) OR (1 Mark for any other location with a valid justification) (e3) Suggesttheplacementofthefollowingdeviceswithjustification: (i) Repeater (ii) Hub/Switch Ans. (i) A Repeater should be placed when the distance between any twoconnectingbuildingsexceeds70m.
  • 365.
    407 (ii) EverybuildingwillneedoneHub/Switch,tosendsignalstoall of theworkstations connected to it OR Anydiagrammaticrepresentationwithvalidjustification (½ Mark for correct placement of Repeater with justification) (½ Mark for correct placement of Hub/Switch with justification) (e4) TheNGOisplanningtoconnectitsInternationalofficesituatedinDelhi. Whichoutofthefollowingwiredcommunicationlinks,willyousuggest foraveryhighspeedconnectivity? (i) TelephoneAnalogLine (ii) OpticalFiber (iii) EthernetCable Ans. (ii) OpticalFibre (1 Mark for correct Option / Answer) (f) Writethefullformsofthefollowing: 1 (f1) FTP (f2) FSF Ans. (f1) FILE TRANSFER PROTOCOL (f2) FREE SOFTWARE FOUNDATION (½ Mark. for each full form) (g) Name any two common Web browsers. 1 Ans. Internetexplorer Firefox Netscape Chrome Opera Safari OR any other Web Browser (½ Mark each for any two web browsers)
  • 366.
    314 COMPUTER SCIENCE Time allowed: 3 hours Maximum Marks : 70 Instructions: (i) All questions are compulsory. (ii) Programming Language: C+ + QUESTION PAPER CODE 91/1 1. (a) What is the difference between LocalVariable and Global Variable? Also, give a suitable C++ code to illustrate both. 2 (b) Writethenamesoftheheaderfiles,whichis/areessentiallyrequiredtorun/ executethefollowingC++code: voidmain() { char C, String [ ] = "Excellence Overload"; for (int I=0; String [ I ] ! = ' 0'; I ++ ) if (String [I] ==' ') cout<<end1; else { C=toupper(String[I]); cout<<C ; } } (c) Rewritethefollowingprogramafterremovingthesyntacticalerrors(ifany). Underlineeachcorrection. 2 #include[iostream.h]
  • 367.
    315 typedef char Text(80); voidmain() { TextT="Indian"; intCount=strlen(T); cout<<T<<'has'<<Count<< 'characters' <<end1; } (d) Findtheoutputofthefollowingprogram: 3 #inc1ude<iostream.h> voidChangeArray(intNumber,intARR[],intSize) { for (int L =0; L<Size; L++) if(L<Number) ARR [L] +=L; e1se ARR [L] *=L; } void Show (intARR [ ], int Size) { for (int L=0; L<Size; L++) (L%2!=0) ?cout<<ARR[L] <<"#": cout<<ARR[L]<<end1 ; } voidmain() { int Array [ ] = {30, 20, 40, 10, 60, 50}; ChangeArray (3,Array, 6) ; Show (Array, 6) ; }
  • 368.
    316 (e) Findtheoutputofthefollowingprogram: 2 #include<iostream.h> voidmain() { intTrack [ ] = {10, 20, 30, 40}, *Striker ; Stxiker=Track: Track [1] += 30 ; cout<<"Striker>"<<*Striker<<end1; Striker – =10 ; Striker++ ; cout<<"Next@"<<*Striker<<end1 ; Striker+=2 ; cout<<"Last@"<<*Striker<<end1; cout<< "Reset To" <<Track[0] <<end1 ; } (f) Go through the C++ code shown below, and find out the possible output or outputs from the suggested Output Options (i) to (iv).Also, write the least value and highest value, which can be assigned to the variable Guess. 2 #include<iostream.h> #include<stdlib.h> voidmain() { randomize ( ) ; intGuess,High=4; Guess=random{High)+50; for{int C=Guess ; C<=55 ; C++) cout<<C<<"#";
  • 369.
    317 } (i) 50 #51 # 52 # 53 # 54 # 55 # (ii) 52 # 53 # 54 # 55 (iii) 53 # 54 # (iv) 51 # 52 # 53 # 54 # 55 2. (a) Differentiatebetweenmembers,whicharepresentwithintheprivatevisibility modewiththosewhicharepresentwithinthepublicvisibilitymodes. 2 (b) Write the output of the following C++ code.Also. write the name of feature of Object Oriented Programming used in the following program jointly illustratedbythefunction[I]to[IV]. 2 #include<iostream.h> void Print ( ) //Function[I] { for (int K=1 ; K<=60 ; K++) cout<< "-" ; cout<<end1 ; } voidPrint(intN) //Function[II] { for (int K=1 ; K<=N ; L++) cout<<"*" ; cout<<end1 ; } voidPrint(intA,int.B) //Function[III] { for (int K=1. ;K<=B ;K++) cout <<A*K ; cout<<end1 ; } void Print (char T, int N) //Function[IV]
  • 370.
    318 { for (int K=1; K<=N ; K++) cout<<T ; cout<<end1; } voidmain() { int U=9, V=4, W=3; char C='@' ; Print (C,V) ; Print (U,W) ; } (c) DefineaclassCandidateinC++withfollowingdescription: 4 PrivateMembers A data member RNo (Registration Number) of type long A data member Name of type string A data member Score of type float A data member Remarks of type string Amember functionAssignRem( ) to assign Remarks as per the Score obtained by a candidate. Score range and the respective Remarks are shownasfollows: Score Remarks >=50 Selected less than 50 Not selected PublicMembers A function ENTER ( ) to allow user to enter values for RNo, Name, Score&callfunctionAssignRem()toassigntheremarks. AfunctionDISPLAY()toallowusertoviewthecontentofallthedata members.
  • 371.
    319 (d) Answerthequestions(i)to(iv)basedonthefollowing: 4 classStrident ( intRno; charName [20] ; floatMarks; protected: void Result( ) ; public: Student( ) ; void Register( ); void Display( ) ; } ; classFaculty { long FCode; char FName[20]; protected: floatPay; public: Faculty ( ) ; void Enter ( ) ; void Show ( ) ; } ; class Course : public Student, private Faculty { long CCode [10]; char CourseName [50] ; char StartDate[8], EndDate[8] ;
  • 372.
    320 public: Course ( ); void Commence ( ) ; void CDetail ( ) ; } ; (i) Which type of inheritance is illustrated in the above C++ code? (ii) Writethenamesofthealldatamembers,whichis/areaccessiblefrom memberfunctionCommenceofclassCourse. (iii) Writethenamesofmemberfunctions,whichareaccessiblefromobjects of class Course. (iv) Write the name of all the members, which are accessible from objects ofclassFaculty. 3 (a) Write a Get1From2 ( ) function in C++ to transfer the content from two arrays FIRST[ ] and SECOND[ ] to arrayALL[ ]. The even places (0, 2, 4, ...) of arrayALL[ ] should get the content from the array FIRST[ ] and odd places (1, 3, 5, ) of the arrayALL[] should get the content from the array SECOND[ ]. 3 Example: If the FIRST[ ] array contains 30, 60, 90 And the SECOND[ ] array contains 10, 50, 80 TheALL[]arrayshouldcontain 30, 10, 60, 50, 90, 80 (b) AnarrayP[20][50]isstoredinthememoryalongthecolumnwitheachofits element occupying 4 bytes, find out the 1ocation of P[15][10], if P[0][0] is stored at 5200. 3 (c) WriteafunctioninC++toperformInsert:operationonadynamicallyallocated Queue containing Passenger details as given in the following definition of NODE. 4
  • 373.
    321 struct NODE { longPno; //passengerNumber charPname[20] ; //passenger Name NODE *Link.; } ; (d) Write a COLSUM( ) function in C++ to find sum of each column of a NxM Matrix. 2 (e) Evaluatethefollowingpostfixnotationofexpression: 2 50, 60, + , 20, 10, -, * 4. (a) Observetheprogramsegmentgivenbelowcarefullyandfilltheblanksmarked as Statement 1 and Statement 2 using seekg( ), seekp( ), tellp( ) and tellg( ) functionsforperformingtherequiredtask. 1 #include<fstream.h> class PRODUCT { int Pno; char Pname[20); int Qty; public: void ModifyQty( ) ; //ThefunctionistomodifyquantityofaPRODUCT } ; voidPRODUCT::ModifyQty() { fstreamFile; Fil.open("PRODUCT.DAT",ios::binary|ios::in|ios::out); intMPno;
  • 374.
    322 cout<<"Product No tomodify quantity : "; cin>>MPNo; While(Fil.read((char*)this,sizeof(PRODUCT)) { if (MPno == Pno) { Cout<<"PresentQuantity:"<<Qty<<end1; cout<<"ChangedQuantity:";cin>>Qty; int Position = _______________; //Statement 1 _________________________; // Statement 2 Fil.write((char*)this,sizeof(PRODUCT)); //Re-writing the record } } Fil.close ( ) ; } (b) Write a function in C++ to count the no. of "Me" or "My" words present in a textfile"DIARY.TXT". 2 Ifthefile"DIARY.TXT"contentisasfollows: My first book was Me and My family. It gave me chance to be known to the world. Theoutputofthefunctionshouldbe Count of Me/My in file : 4 (c) WriteafunctioninC++tosearchforalaptopfromabinaryfile"LAPTOP.DAT" containingtheobjectsofclassLAPTOP(asdefinedbelow).The user should enter the Model No and the function should search and display the details of the laptop. 3 classLAPTOP {
  • 375.
    323 long ModelNo ; floatRAM, HDD ; char Details [120] ; public: void StockEnter ( ) {cin>>ModelNo>>RAM>>HDD;gets(Details);} void StockDisplay ( ) {cout<<ModelNo<<RAM<<HDD<<Details<<endl;} long ReturnModelNo ( ) {return ModelNo ;} } ; 5 (a) What do you understand by Union & Cartesian Product operations in rela- tionalalgebra? 2 Consider the following tables WORKER and PAYYLEVELand answer (b) and (c) parts of this question: 4 Table:WORKER ECODE NAME DESIG PLEVEL DOJ DOB 11 RadheShyam Supervisor P001 13- Sep- 2004 23-Aug-1981 12 Chander Nath Operator P003 22-Feb-2010 12-Jul-1987 13 Fizza Operator P003 14-Jun-2009 14-0ct-1983 15 AmeenAhmed Mechanic P002 21-Aug-2006 13-Mar-1984 18 Sanya Clerk P002 19-Dec-2005 09-Jun-1983 Table:PAYLEVEL PLEVEL PAY ALLOWANCE P001 26000 12000 P002 22000 10000 P003 12000 6000
  • 376.
    324 (b) WriteSQLcommandsforthefollowingstatements: (i) Todisplay the details of all WORKERs in descending order of DOB. (ii) TodisplayNAMEandDE;SIGofthoseWORKERs,whosePLEVEL is either P001 or P002. (iii) To display the content of all the WORKERs table, whose DOB is in between '19-JAN-1984' and '18-JAN-1987'. (iv) Toaddanewrowwiththefollowing: 19, 'Daya Kishore', 'Operator', 'P003', '19-Jun-2008', '11-Jun-1984' (c) GivetheoutputofthefollowingSQLqueries: 2 (i) SELECTCOUNT(PLEVEL),PLEVELFROMWORKERGROUP BYPLEVEL; (ii) SELECT MAX (DOB), MIN (DOJ) FROM WORKER; (iii) SELECT Name, Pay FROM WORKER W, PAYLEVEL P WHERE W. PLEVEL = S. PLEVELAND P.ECODE<13 ; (iv) SELECT PLEVEL, PAY+ALLOWANCE FROM PAYLEVEL WHERE PLEVEL= 'P003' ; 6 (a) VerifythefollowingusingTruthTable. 2 U. (U' +V) = (U + V) (b) WritetheequivalentBooleanExpressionforthefollowinglogicCircuit. 2 (c) Write the POS form of a Boolean function F, which is represented in a truth tableasfollows: 1
  • 377.
    325 A B CF 0 0 0 0 0 0 1 1 0 1 0 1 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 0 1 1 1 1 (d) ReducethefollowingBooleanExpressionusingK-Map: 3 F(P, Q, R, S) = Σ (0,1,2,4,5,6,8, 12) 7. (a) Differentiatebetweenpacketswitchingandmessageswitchingtechniquein networkcommunication. 1 (b) Differentiate between BUS and STAR topology of networks. 1 (c) What is VoIP? 1 (d) Outofthefollowing,identifyclientsidescript(s)andserversidescript(s). 1 (a) ASP (b) Javascript (c) VBScript (d) JSP (e) QuicklearnUniversityissettingupitsAcademicblocksatPrayagNagarand planning to set up a network. The university has 3 academic blocks and one Human Resource Center as shown in the diagram below. 4
  • 378.
    326 Center to centerdistance between various block/center is as follows: Law Block to Business Block 40m Law Block toTechnology Block 80m Law Block to HR Center 105m BusinessBlocktoTechnologyBlock 30m Business Block to HR Center 35m Technology Block to HR Center 15m Number of Computers in each of the Blocks/Centre is follows: LawBlock 15 TechnologyBlock 40 HR Center 115 BusinessBlock 25 (e1 ) Suggestthemostsuitableplace(i.e.Block/Center)toinstalltheserverofthis universitywithasuitablereason. (e2) Suggest an ideal layout for connecting these blocks/centers for a wired con- nectivity. (e3) Whichdeviceyouwillsuggesttobeplaced/installedineachoftheseblocks/ centertoefficientlyconnectallthecomputerswithintheseblocks/center. (e4) Theuniversityisplanningtoconnectitsadmissionofficeintheclosestbigcity, which is more than 250 km from university, which type of network out of LAN, MAN or WAN will be formed? Justify your answer. (f) WhichofthefollowingwillcomeunderCyberCrime? 1 (i) Theft of a brand new sealed pack Laptop (ii) AccesstoabankaccountforgettingunauthorizedMoneyTransaction (iii) Modificationinacompanydatawithunauthorizedaccess (iv) Photocopying a printed report (g) Compare open source software and proprietary software. 1
  • 379.
    327 COMPUTER SCIENCE QUESTION PAPERCODE 91 1. (a) What isthedifferencebetweenTypeCastingandAutomaticTypeconversion? Also, give a suitable C++ code to illustrate both. 2 (b) Write the names of the header files, which is/are essentially required torun/ executethefollowingc++code: 1 voidmain() { charCH,Text[]="+veAttitude"; for (int I=0 ; Text[I] ! ='0' ;I++) if (Text[I]== ' ') cout<<end1; else { CH=toupper (Text [I]) ; cout<<CH; } } (c) Rewritethefollowingprogramafterremovingthesyntacticalerrors(ifany). Underlineeachcorrection. 2 include<iostream.h> typedef char [80] String; voidmain() { StringS="Peace"; intL=strlen(S); cout<<S<< 'has'<<L<< 'characters'<<end1; }
  • 380.
    328 (d) Findtheoutputofthefollowingprogram: 3 #include<iostream.h> voidSwitchOver(intA[ ], int N, int Split) { for (int K=0 ; K<N; K++) if(K<Split) A(K]+ =K; else A [K]*=K; } void Display (intA[ ], int N) { for (int K=0 ; K<N ; K++) (K%2==0)? cout<<A[K]<<"%":cout<<A(K]<<end1; } voidmain() { int H[ ]= {30,40,50,20,10,5}; SwitchOver (H, 6, 3); Display(H,6); } (e) Findtheoutputofthefollowingprogram: 2 #include<iostream.h> voidmain() { int *Queen, Moves [ ] = {11, 22, 33, 44};
  • 381.
    329 Queen = Moves; Moves[2] + = 22; Cout<< "Queen @"<<*Queen<<end1; *Queen - = 11; Queen + = 2; cout<< "Now @"<<*Queen<<end1; Queen++; cout<<"Finally@"<<*Queen«end1; cout<< "New Origin @"<<Moves[0]<<end1; } (f) Go through the C++ code shown below, and find out the possible output or outputsfromthesuggestedOutputOptions(i)to(iv).Also,writetheminimum andmaximumvalues,whichcanbeassignedtothevariableMyNum. 2 #include<iostream.h> #include<stdlib.h> voidmain() { randomize ( ) ; intMyNum,Max=5; MyNum = 20 + random (Max) ; for (int N=MyNum; 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
  • 382.
    330 2. (a) DifferentiatebetweenConstructorandDestructorfunctionwithrespectto ObjectOrientedProgramming.2 (b) Write the output of the following C++ code.Also, write the .name of feature of Object Oriented Programming used in the following program jointly illustratedbythefunction[I]to[IV] 2 #include<iostream.h> void Line ( ) //Function[I] { for (int L=1;L<=80;L++) cout<<"-"; cout<<end1; } voidLine(intN) //Function[II] { for(intL=l;L<=N;L++) Cout<<"*"; cout<<endl; } void Line (char C, int N) //Function[III] { for(intL=l;L<=N;L++) cout<<C; cout<<end1; } void Line (int M, int, N) //Function[IV] { for (int L=1;L<=N;L++) cout<<M*L; cout<<end1; } voidmain()
  • 383.
    331 { intA=9, B=4, C=3; charK= '#' ; Line(K,B); Line(A,C); } (c) DefineaclassApplicantinC++withfollowingdescription: 4 PrivateMembers Adata memberANo (Admission Number) of type long A data member Name of type string Adata memberAgg (Aggregate Marks) of type float A data member Grade of type char AmemberfunctionGradeMe()tofindtheGradeaspertheAggregate Marks obtained by a student. EquivalentAggregate Marks range and the respective Grades are shown as follows: AggregateMarks Grade >=80 A less than 80 and >=65 B less than 65 and >=50 C less than 50 D PublicMembers AfunctionENTER()toallowusertoentervaluesforANo,Name,Agg & call function GradeMe() to find the Grade. Afunction_RESULT()toallowusertoviewthecontentofallthedata members. (d) Answerthequestions(i)to(iv)basedonthefollowing: 4 classStudent {
  • 384.
    332 intRollno: char SName[20]; floatMarksl; protected: void Result( ) ; public: Student ( ) ; void Enroll ( ) ;void Display ( ) ; } ; classTeacher { longTCode; char TName [20]; protected: floatSalary; public: Teacher ( ); void Enter ( ) ; void Show ( ) ; } ; class Course: public Student, private Teacher } long CCode [10]; char CourseName [50]; char StartDate [8] , EndDate [8]; public: Course ( ) ; void Commence ( ); void CDetail ( ) ; } ;
  • 385.
    333 (i) Write thenames of member functions, which are accessible from objects of class Course (ii) Writethenamesofallthedatamembers,whichis/areaccessiblefrommember functionCommenceofclassCourse (iii) Write the names of all the-members, which are accessible from objects of classTeacher. (iv) Which type of Inheritance is illustrated in the above C++ code? 3. (a) Write a Get2From1() function in C++ to transfer the content from one array ALL[] to two different arrays Odd[] and Even[]. The Odd[] array should contain the values from odd positions (1,3,5,...) ofALL[] and Even [] array should contain the values from even positions (0, 2, 4,…..) ofALL[]. 3 Example IftheALL[]arraycontains 12, 34, 56, 67, 89, 90 The Odd[] array should contain 34, 67, 90 And the Even [] array should contain 12, 56, 89 (b) An array G[50][20] is stored in the memory along the row with each of its elementsoccupying8bytes.FindoutthelocationofG[10][15],ifG[0][0]is stored at 4200. 3 (c) WriteafunctioninC++toperformDelete operationona dynamicallyallocated QueuecontainingMembersdetailsasgiveninthefollowingdefinitionofNODE: 4 struct NODE { longMno //MemberNumber char Mname[20]; //Member Name NODE*Link; };
  • 386.
    334 (d) WriteaDSUMOfunctioninC++tofindsumofDiagonalElementsfroma NxN Matrix.2 (Assuming that the N is a odd number) (e) Evaluatethefollowingpostfixnotationofexpression: 2 True, False, NOT,AND, True, True,AND,OR 4. (a) Observetheprogramsegmentgivenbelowcarefullyandfilltheblanksmarked as Statement 1 and Statement 2 using seekg( ), seekp( ) tellp( ) and tellg( ) functionsforperformingtherequiredtask. 1 #include<fstream.h> classITEM { intIno;charIname[20];floatPrice; public: voidModifyPrice();//Thefunctionistomodify price of a particular ITEM } ; voiditem::ModiyPrice() { fstreamFile; File.open("ITEM.DAT",ios::binary|ios::in|ios::out)||; intCIno; cout<<"ItemNotomodifyprice:";cin>>CIno; while(file.read((char*)this,sizeof(ITEM))) { if(CIno==Ino) { cout<<"PresentPrice:"<<Price<<end1; cout<<"Changedprice:";cin>>Price;
  • 387.
    335 int FilePos =__________ ; //Statement 1, ___________________; //Statement 2 File.write((char*)this,sizeof(ITEM)); // Re-writing the record } } File.close ( ) ; } (b) Write a function in C++ to count the no. of "He" or "She" words present in a textfile"STORY.TXT". 2 Ifthefile"STORY.TXT"contentisasfollows: Heisplayingintheground.Sheis Playingwithherdolls. Theoutputofthefunctionshouldbe CountofHe/Sheinfile:2 (c) Write a function in C++ to search for a camera from a binary file "CAMERA.DAT" containing the objects of class" CAMERA (as defined below). The user should enter the Model No and the function should search display the details of the camera. 3 classCAMERA { longModelNo; floatMegaPixel; intZoom; charDetails[120]; public: voidEnter(){cin>>ModelNo>>MegaPixel>>Zoom;gets(Details);} voidDisplay() {cout<<ModelNo<<MegaPixel<<Zoom<<Details<<endl;} long GetModelNo ( ) {return ModelNo;} };
  • 388.
    336 5. (a) Whatdo you understand by Selection & Projection operations in relational algebra? 2 Consider the following tables EMPLOYEE and SALGRADE and answer (b) and (c) parts of this question: Table: EMPLOYEE ECODE NAME DESIG SGRADE DOJ DOB 101 AbdulAhmad EXECUTIVE S03 23-Mar-2003 13-Jan-1980 102 Rav:i.Chander HEAD-IT S02 12-Feb-2010 22-Jul-1987 103 John Ken RECEPTIONIST S03 24-June-2009 24-Feb-1983 105 NazarAmeen GM S02 11-Aug-2006 03-Mar-1984 108 PriyamSen CEO S01 29-Dec-2004 19-Jan-1982 Table:SALGRADE SGRADE SALARY HRA S0l 56000 18000 S02 32000 12000 S03 24000 8000 (b) WriteSQLcommandsforthefollowingstatements: 4 (i) TodisplaythedetailsofallEMPLOYEEs,indescendingorderofDOJ (ii) To display NAME and DE51G of those EMPLOYEEs, whose SALGRADE is either 502 or 503 (iii) To display the content of all the EMPLOYEEs table, whose DOJ is in between'09-Feb-2006' and '08-Aug-2009'. (iv) Toaddanewrowwiththefollowing: 109, 'Harish Roy', 'HEAD-IT', 'S02', '09-Sep-2007, '21-Apr-1983' (c) Give:theoutputofthefollowingSQLqueries: 2 (i) SELECT COUNT (SGRADE), SGRADE FROM EMPLOYEE GROUPBYSGRADE; (ii) SELECT MIN(DOB), MAX (DOJ) FROM EMPLOYEE;
  • 389.
    337 (iii) SELECT NAME, SALARYFROM EMPLOYEE E, SALGRADE S WHERE E.SGRADE= S.SGRADEAND E.ECODE<103; (iv) SELECTSGRADE,SALARY+HRAET:)MSALGRADEWHERE SGRADE='S02'; 6 (a) YerifythefollowingusingTruthTable: 2 X+Y. Z=(X+Y).(X+Z) (b) WritetheequivalentBooleanExpressionforthefollowingLogicCircuit: 2 (c) Write the SOPform of a Boolean function F, which is represented in a truth tableasfollows: 1 U V W F 0 0 0 1 0 0 1 0 0 1 1 1 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 1 (d) ReducethefollowingBooleanExpressionusingK-Map: 3 F(A, B,C, D) = Σ (0,1, 2, 4, 5, 6, 7, 8, 10) 7. (a) In networking, what-is WAN? How is it different from LAN? 1 (b) DifferentiatebetweenXMLandHTML. 1 (c) What is WEB2.0? 1
  • 390.
    338 (d) Out ofthe following, identify client side script (s) and server side script (s). 1 (i) Javascript (ii) ASP (iii) vbscript (iv) JSP (e) Great Studies University is setting up itsAcademic schools at Sunder Nagar andplanningtosetupanetwork.Theuniversityhas3academicschoolsand oneadministrationcenterasshowninthediagrambelow: 4 Center to center distances between various buildings is as follows : Law School to Business School 60m Law School to Technology School 90m Law School toAdmin Center 115m BusinessSchooltoTechnologySchool 40m BusinessSchoolto.AdminCenter 45m TechnologySchooltoAdminCenter 25m Number of Computers in each of the Schools/Center is follows: LawSchool 25 TechnologySchool 50 AdminCenter 125 BusinessSchool 35
  • 391.
    339 (i) Suggest themost suitable place (i.e. School/Center) to install the serverofthisuniversitywithasuitablereason. (ii) Suggest an ideal layout for connecting these schools/ center for a wiredconnectivity. (iii) Whichdevicewillyousuggesttobeplaced/installedineachofthese schools/centertoefficientlyconnectallthecomputerswithinthese schools / center? (iv) Theuniversityisplanningtoconnectitsadmissionofficeintheclosest bigcity,whichismorethan350kmfromtheuniversity.Whichtypeof network out of LAN, MAN or WAN will be formed? Justify your answer. (f) Compare Open Source Software and Proprietary Software. 1 (g) What are cookies? 1
  • 392.
    340 Marking Scheme óComputer Science General Instructions : 1. TheanswersgiveninthemarkingschemeareSUGGESTIVE,Examinersarerequestedto awardmarksforallalternativecorrectSolutions/Answersconveyingthesimilarmeaning 2. All programming questions have to be answered with respect to C++ Language only. 3. InC++,ignorecasesensitivityforidentifiers (Variable/Functions/Structures/ClassNames) 4. In SQL related questions - both ways of text/character entries should be acceptable for Example: “AMAR” and ‘amar’both are correct. 5. In SQL related questions - all date entries should be acceptable for Example: 'DD-Mon- YY',"DD/MM/YY",'DD/MM/YY',"MM/DD/YY",'MM/DD/YY',and{MM/DD/YY} are correct. 6. InSQLrelatedquestions-semicolonshouldbeignoredforterminatingtheSQLstatements 7. InSQLrelatedquestions,ignorecasesensitivity. QUESTION PAPER CODE 91/1 EXPECTEDANSWERS 1. (a) What is the difference between Local Variable and Global Variable? Also, give a suitable C++ code to illustrate both. 2 Ans Local Variables: Local variables are those variables which are declared within a function or a compound statement and these variables can only be usedwithinthatfunction/scope. GlobalVariables:Globalvariablesarethosevariableswhicharenotdeclared within any function or scope. So, these variables can be accessed by any functionoftheprogram. Example #include<iostream.h> #include<conio.h.> intG; //Globalvariabledeclared
  • 393.
    341 void Fun () { int L = 25; // Local variable of function Fun ( ) assigned value 25 G=5; // GlobalVariable is accessed and assigned value 5 Cout<<G<<endl; //Value of global variable is displayed as 5 Cout<<L<<endl; //Value of local variable is displayed as 25 } voidmain() { Fun ( ) ; //Functioncall G = G + 5; //Globalvariableisincrementedby5 cout<<G<<endl; // Global variable is displayed as 10 } (½ Mark for each correct explanation of Local Variable and Global Variable) (½ Mark for each correct example of Local variable and Global Variable) OR (Full 2 Maries for correct example(s) demonstrating the meaning of / difference between Local Variable and Global Variable) OR (Only 1 Mark to be awarded if Explanation without supporting examples) (b) Writethenamesoftheheaderfiles,whichis/areessentiallyrequiredtorun/ executethefollowingC++code: voidmain() { char C, String [ ] = "Excellence Overload"; for (int I=0; String [ I ] ! = ' 0'; I ++ ) if (String [I] ==' ')
  • 394.
    342 cout<<end1; else { C=toupper(String[I]); cout<<C ; } } Ans iostream.h ctype.h (½Mark for writing each correct header file) (c) Rewritethefollowingprogramafterremovingthesyntacticalerrors(ifany). Underlineeachcorrection. 2 #include[iostream.h] typedef char Text(80) ; voidmain() { TextT="Indian"; intCount=strlen(T); cout<<T<<'has'<<Count<< 'characters' <<end1; } Ans #include<iostream.h> #include<string.h> typedef char Text [80]; voidmain() { TextT="Indian"; intCount=str1en(T); cout<<T<< "has" <<Count<< "cbaracters"<<end1 ;
  • 395.
    343 } (½Markforwriting#include<iostream.h> (½Markforwriting#include<string.h> (½ Mark forwriting typedef char Text(80]; (½Markforwriting"has"and"characters") (d) Findtheoutputofthefollowingprogram: 3 #inc1ude<iostream.h> voidChangeArray(intNumber,intARR[],intSize) { for (int L =0; L<Size; L++) if(L<Number) ARR [L] +=L; e1se ARR [L] *=L; } void Show (intARR [ ], int Size) { for (int L=0; L<Size; L++) (L%2!=0) ?cout<<ARR[L] <<"#": cout<<ARR[L]<<end1 ; } voidmain() { int Array [ ] = {30, 20, 40, 10, 60, 50}; ChangeArray (3,Array, 6) ; Show (Array, 6) ; }
  • 396.
    344 Ans 30 21#42 30#240 250# (½ Markfor each correct value) Note: Deduct ½ Mark for not writing # at proper places Deduct ½ Mark for not considering endl at proaer places (e) Findtheoutputofthefollowingprogram: 2 #include<iostream.h> voidmain() { int Track [ ] = {10, 20, 30, 40}, *Striker ; Stxiker=Track: Track [1] += 30 ; cout<<"Striker>"<<*Striker<<end1; Striker – =10 ; Striker++ ; cout<<"Next@"<<*Striker<<end1 ; Striker+=2 ; cout<<"Last@"<<*Striker<<end1; cout<< "Reset To" <<Track[0] <<end1 ; } Ans Striker>10 Next@50 Last@40 Reset to 0
  • 397.
    345 (½forwritingeachlineofoutputcorrectly) Note: Deduct½Markifany/allspecialcharactersaremissing Deduct ½ Markif endl is not considered at the right positions (f) Go through the C++ code shown below, and find out the possible output or outputs from the suggested Output Options (i) to (iv).Also, write the least value and highest value, which can be assigned to the variable Guess. 2 #include<iostream.h> #include<stdlib.h> voidmain() { randomize ( ) ; intGuess,High=4; Guess=random{High)+50; for{int C=Guess ; C<=55 ; C++) cout<<C<<"#"; } (i) 50 # 51 # 52 # 53 # 54 # 55 # (ii) 52 # 53 # 54 # 55 (iii) 53 # 54 # (iv) 51 # 52 # 53 # 54 # 55 Ans (i) 50 # 51 # 52 # 53 # 54 # 55 # Least value 50 Highestvalue53 (1 Mark for mentioning correct option (i)) ( ½ Mark for mentioning correct Least value of Guess) (½ Mark for mentioning correct Highest value of Guess)
  • 398.
    346 2. (a) Differentiatebetweenmembers,whicharepresentwithintheprivatevisibility modewiththosewhicharepresentwithinthepublicvisibilitymodes.2 Ans Privatemembersofaclassareaccessibleonlytothememberfunctionsofthe sameclass. Publicmembersofaclassareaccessibletothememberfunctionsofthesame classaswellasmemberfunctionsofitsderivedclass(es)andalsotoanobject of the class. Example: class Base { intN; public: voidAssign() { N=10; } }; classDerived:publicBase { intX; public: voidDisplayBase() { cout<<N; //NotAccessible Assign ( ) ; //Accessible } } ; voidmain()
  • 399.
    347 { Base B; B.Assign(); //Accessible } (1MarkforcorrectexplanationORexampleillustratingnonaccessibilityof PrivateMembersinsideDerivedclass) (1MarieforcorrectexplanationORexampleillustratingaccessibilityofPublic Membersinside Derived Class and to object of the class) (b) Write the output of the following C++ code.Also. write the name of feature of Object Oriented Programming used in the following program jointly illustratedbythefunction[I]to[IV]. 2 #include<iostream.h> void Print ( ) //Function[I] { for (int K=1 ; K<=60 ; K++) cout<< "-" ; cout<<end1 ; } voidPrint(intN) //Function[II] { for (int K=1 ; K<=N ; L++) cout<<"*" ; cout<<end1 ; } voidPrint(intA,int.B) { for (int K=1. ;K<=B ;K++) cout <<A*K ; cout<<end1 ; } void Print (char T, int N) //Function[IV]
  • 400.
    348 { for (int K=1; K<=N ; K++) cout<<T ; cout<<end1; } voidmain() { int U=9, V=4, W=3; char C='@' ; Print (C,V) ; Print (U,W) ; } Ans. @@@@ 91827 OR No Output as L is not declared in void Print (int N) Polymorphism OR FunctionOverloading (½ Mark for writing each correct line of output) (1 Mark for writing the feature name correctly) (c) DefineaclassCandidateinC++withfollowingdescription: 4 PrivateMembers A data member RNo (Registration Number) of type long A data member Name of type string A data member Score of type float A data member Remarks of type string
  • 401.
    349 Amember functionAssignRem( )to assign Remarks as per the Score obtained by a candidate. Score range and the respective Remarks are shownasfollows: Score Remarks >=50 Selected less than 50 Not selected PublicMembers A function ENTER ( ) to allow user to enter values for RNo, Name, Score&callfunctionAssignRem()toassigntheremarks. AfunctionDISPLAY()toallowusertoviewthecontentofallthedata members. Ans class Candidate { longRNo; char Name[20]; float Score; char Remarks[20]; voidAssignRem(); public: voidEnter(); voidDisplay(); } ; voidCandidate::AssignRem() { if (Score>=50) strcpy(Remarks,"Selected"); else strcpy(Remarks,"Not Selected") ; }
  • 402.
    350 void Candidate: :Enter ( ) { cin>>RNo ; gets (Name) ; cin>>Score; AssignRem(); } voidCandidate::Display() { cout<<RNo<<Name<<Score<<Remarks<<end1; } (½ Mark for correct syntax for class header) (½ Mark for correct declaration of data members) (1 Mark for correct definition of AssignRem()) (1 Mark for correct definition of Enter() with proper invocation of AssignRem() function) (1 Mark for correct definition of Display()) NOTE: Deduct ½ Mark to be deducted if Assignrem() is not invoked properly inside Enter( ) function No marks to be deducted if member function definitions are written inside the class (d) Answerthequestions(i)to(iv)basedonthefollowing: classStrident ( intRno; char Name [20] ; floatMarks;
  • 403.
    351 protected: void Result( ); public: Student( ) ; void Register( ); void Display( ) ; } ; classFaculty { long FCode; char FName[20]; protected: floatPay; public: Faculty ( ) ; void Enter ( ) ; void Show ( ) ; } ; class Course : public Student, private Faculty { long CCode [10]; char CourseName [50] ; char StartDate[8], EndDate[8] ; public: Course ( ) ; void Commence ( ) ; void CDetail ( ) ; } ;
  • 404.
    352 (i) Which typeof inheritance is illustrated in the above C++ code? Ans MultipleInheritance (1 Mark for correct answer) (ii) Writethenamesofthealldatamembers,whichis/areaccessiblefrom memberfunctionCommenceofclassCourse. Ans CCode, CourseName, StartDate, EndDate, Pay (1 Mark for correct answer) Note: No marks to be awarded for any other alternative answer (iii) Writethenamesofmemberfunctions,whichareaccessiblefromobjects of class Course. Ans Commence( ), CDetail( ), Register( ), Display( ) (1 Mark for correct answer) Note: No marks to be awarded for any other alternative answer Constructor functions to be ignored (iv) Write the name of all the members, which are accessible from objects ofclassFaculty. Ans Enter( ), Show( ) (1 Mark for correct answer) Note: No marks to be awarded for any other alternative answer Constructor functions to be iqnored 3 (a) Write a Get1From2 ( ) function in C++ to transfer the content from two arrays FIRST[ ] and SECOND[ ] to arrayALL[ ]. The even places (0, 2, 4, ...) of arrayALL[ ] should get the content from the array FIRST[ ] and odd places (1, 3, 5, ) of the arrayALL[] should get the content from the array SECOND[ ].
  • 405.
    353 Example: If the FIRST[] array contains 30, 60, 90 And the SECOND[ ] array contains 10, 50, 80 TheALL[]arrayshouldcontain 30, 10, 60, 50, 90, 80 Ans void Get1From2 (intALL[],int FIRST[],int SECOND[], intN,intM) { for(int I=0,J=0,K=0;i<N+M; I++) if(I%2==0) ALL[I]=FIRST[J++]; else ALL[I]=SECOND[K++]; } OR voidGet1From2(intALL[],intFIRST[],intSECOND[], int N, int M) { int J=0,K=0; for(int I=0;i<N+M; I++) { if(I%2==0) { ALL [I] =FIRST [J] ; J++; }
  • 406.
    354 else { ALL[I]=SECOND[K]; K++; } } } (1 Mark forcorrect loop) (½ Mark for checking even locations) (½ Mark for checking even locations or writing else for odd locations) ( 1 Mark for incrementing FIRST and SECOND Array Locations) (b) AnarrayP[20][50]isstoredinthememoryalongthecolumnwitheachofits element occupying 4 bytes, find out the 1ocation of P[15][10], if P[0][0] is stored at 5200. 3 Ans AssuminqLBR=LBC=0 B=5200 W=4 bytes Number of Rows(N)=20 NumberofColumns(M)=50 LOC(Arr[I] [J]) = B +(I + J*N)*W LOC(Arr[15][10]) = 5200+(15+10*20)*4 = 5200 + (215*4) = 5200 + 860 = 6060 (1 Mark for writing correct formula (for row major) OR substituting formula with correct values for calculating Address) (2 marks for calculating correct address) Note: 1 Mark to be awarded for writing only the correct answer (i.e. 6060)
  • 407.
    355 (c) WriteafunctioninC++toperformInsert:operationonadynamicallyallocated Queue containingPassenger details as given in the following definition of NODE. 4 struct NODE { longPno; //passengerNumber char Pname[20] ; //passenger Name NODE *Link.; } ; Ans class Queue { NODE *Front, *Rear; public: Queue ( ) {Front = NULL; Rear = NULL; } void QueInsert ( ) ; void QueDel ( ) ; void QueDis ( ) ; ~Queue ( ) ; } ; void Queue: : QueInsert ( ) { NODE*Temp=new NODE; cin>>Temp->Pno; gets (Temp->Pname) ; Temp->Link = NULL; Rear->Li.nk = Temp; Rear = Temp ; }
  • 408.
    356 (1 Mark forcreating a new NODE dynamically) (1 Mark for assigning NULL to Link of new NODE) (1 Mark for linking the Rearmost NODE to the new NODE) (1 Mark for making the new NODE as the Rearmost NODE) (d) Write a COLSUM( ) function in C++ to find sum of each column of a NxM Matrix. 2 Ans void COLSUM(intA[] [100], int N, int M) { intSUMC; for (int j=0; j<M; j++) { SUMC = 0; for (int i=0; i<N; i++) SUMC = SUMC + A[i] [j] ; Cout<< "Sum of Column "<<j<<" = "<<SUMC ; } } (½ Mark for writing correct outer loop) (½ Mark for initializing SUMC with 0 for each column) (½ Mark tor writing correct inner loop) (½ Mark for finding sum of each column) (e) Evaluatethefollowingpostfixnotationofexpression: 2 50, 60, + , 20, 10, -, * Ans ElementScanned STACK 50 50 60 50, 60 + 110
  • 409.
    357 20 110, 20 10110, 20, 10 – 110, 10 * 1100 (2 Mark for evaluating 1100 as the final answer) Note: (½ Mark for writing only the final answer as 1100 without showing the operations or Stack) 4. (a) Observetheprogramsegmentgivenbelowcarefullyandfilltheblanksmarked as Statement 1 and Statement 2 using seekg( ), seekp( ), tellp( ) and tellg( ) functionsforperformingtherequiredtask. 1 #include<fstream.h> class PRODUCT { int Pno; char Pname[20); int Qty; public: : void ModifyQty( ) ; //ThefunctionistomodifyquantityofaPRODUCT } ; voidPRODUCT::ModifyQty() { fstreamFile; Fil.open("PRODUCT.DAT",ios::binary|ios::in|ios::out); intMPno; cout<<"Product No to modify quantity : "; cin>>MPNo; While(Fil.read((char*)this,sizeof(PRODUCT))
  • 410.
    358 { if (MPno ==Pno) { Cout<<"PresentQuantity:"<<Qty<<end1; cout<<"ChangedQuantity:";cin>>Qty; int Position = _______________; //Statement 1 _________________________; // Statement 2 Fil.write((char*)this,sizeof(PRODUCT)); //Re-writing the record } } Fil.close ( ) ; } Ans Option 1 Statement1: File. tellp ( ) ; OR File.tellg(); Statement2: File.seekp (FilePos - sizeof (PRODUCT)) ; OR File.seekp (-sizeof (PRODUCT), ios: :cur)); OR File.seekg (FilePos - sizeof (PRODUCT)); OR File.seekg(-sizeof(PRODUCT),ios::cur)); Option 2 Statement1: File.tellp ( ) - sizeof (PRODUCT) ; OR File.tellg() - sizeof (PRODUCT) ; Statement2: File. seekp (FilePos) ; OR File.seekg (FilePos) ; (½ Mark for writing Statement 1 correctly) (½ Mark for writing Statement 2 correctly) Note: File / Fil both are acceptable as the name of the File object
  • 411.
    359 (b) Write afunction in C++ to count the no. of "Me" or "My" words present in a textfile"DIARY.TXT". 2 Ifthefile"DIARY.TXT"contentisasfollows: My first book was Me and My family. It gave me chance to be known to the world. Theoutputofthefunctionshouldbe Count of Me/My in file : 4 Ans void COUNT ( ) { ifstreamFil("DIARY.TXT"); char STR [10] ; int count = 0 ; while(!Fil.eof()) { Fil>>STR; if (strcmp (STR, "Me")==0 | | strcmp (STR, "My") ==0) count++; } Cout<<"CountofMe/Myinfile:"<<count<<end1; Fil.close( ) ; //Ignore } OR Any other correct function definition performing the desired operation (½ Mark for opening DIARY. TXT correctly) (½ Mark for reading each word (Whichever method adopted) from, the file) (½ Mark for comparing the word with 'Me' and 'My' and incrementing counter) (½ Mark for displaying the number of 'Me/My' with/without the Text Message) NOTE: Ignore case sensitivity check for Me/My
  • 412.
    360 (c) Write afunction in C++ to search for a laptop from a binary file "LAPTOP.DAT"containingtheobjectsofclassLAPTOP(asdefinedbelow). The user should enter the Model No and the function should search and display the details of the laptop. 3 classLAPTOP { long ModelNo ; float RAM, HDD ; char Details [120] ; public: void StockEnter ( ) {cin>>ModelNo>>RAM>>HDD;gets(Details);} void StockDisplay ( ) {cout<<ModelNo<<RAM<<HDD<<Details<<endl;} long ReturnModelNo ( ) {return ModelNo ;} } ; Ans void Search( ) { LAPTOPL; longmodelnum; cin>>modelnum; ifstreamfin; fin.open("LAPTOP.DAT",ios::binary|ios::in); while(fin.read((char*)&L,sizeof(L))) { if(L.ReturnModelNo()==modelnum) L.StockDisplay ( ) ;
  • 413.
    361 } Fin.close();//Ignore } OR voidSearch(longmodelnum) { LAPTOPL; ifstreamfin; fin.open("LAPTOP.DAT",ios::binary|ios::in); while(fin.read((char*)&L,sizeof(L))) { if(L.ReturnModelNo()==modelnum) L.StockDisplay ( ); } fin.close ( ) ; //Ignore } (½ Mark for declaring and entering a model number for a LAPTOP to search OR passing it as a parameter to the function) (½ Mark for opening LAPTOP.DA T correctly) (½ Mark for reading each record from LAPTOP.DA T) (½ Mark for correct loop / checking end of file) (½ Mark for comparing value returned by ReturnModelNo() with model number entered) (½ Mark for displaying the matching record) 5 (a) What do you understand by Union & Cartesian Product operations in rela- tionalalgebra? 2 Ans Cartesian Product (binary operator): It operates on two relations and is denoted by X. For example Cartesian product of two relations R1 and R2 is
  • 414.
    362 represented by R= R1 X R2. The degree of R is equal to sum of degrees of R1andR2.ThecardinalityofRisproductofcardinalityofR1andcardinality of R2. Example: Relation:R1 RollNo Student Name Class 1 Akash XII 4 Debakar X 10 Rishi XI Relation:R2 Teacher Code Teacher Name 102 MsRinee 309 MrTanmoy Resultant: R = R1 × R2 Col1 Col2 Col3 Col4 Col5 1 Akash XII 102 MsRinee 1 Akash XII 309 MrTanmoy 4 Debakar X 102 MsRinee 4 Debakar X 309 MrTanmoy 10 Rishi XI 102 MsRinee 10 Rishi XI 309 MrTanmoy Union (binary operator): It operates on two relations and is indicated by U. For example, R=R1 U R2 represents union operation between two relations R1 and R2. The degree of R is equal to degree of R1. The cardinality of R is sumofcardinalityofR1andcardinalityofR2. Following have to be considered for the operation R1 U R2. Degree of R1 = Degree of R2 jth attribute of R1 and jth attribute of R2 must have a common domain.
  • 415.
    363 Example: Relation:R1 Student_I D Name R490Fatima R876 Faraz R342 Gauri Relation:R2 Student_Code Student_Name S123 Rekha S456 Tushi Resultant Relation: R = R1 U R2 Column1 Column2 R490 Fatima R876 Faraz R342 Gauri S123 Rekha S456 Tushi (1 Marie for explaining Union correctly) (1 Marie for explaining Cartesian Product correctly) Consider the following tables WORKER and PAYYLEVELand answer (b) and (c) parts of this question: 4 Table:WORKER ECODE NAME DESIG PLEVEL DOJ DOB 11 RadheShyam Supervisor P001 13- Sep- 2004 23-Aug-1981 12 Chander Nath Operator P003 22-Feb-2010 12-Jul-1987 13 Fizza Operator P003 14-Jun-2009 14-0ct-1983 15 AmeenAhmed Mechanic P002 21-Aug-2006 13-Mar-1984 18 Sanya Clerk P002 19-Dec-2005 09-Jun-1983
  • 416.
    364 Table:PAYLEVEL PLEVEL PAY ALLOWANCE P00126000 12000 P002 22000 10000 P003 12000 6000 (b) WriteSQLcommandsforthefollowingstatements: (i) To display the details of all WORKERs in descending order of DOB. SELECT FROM WORKER ORDER BY DOB DESC; (1 Mark for correct query) (½ Mark for partially correct answer) (ii) TodisplayNAMEandDE;SIGofthoseWORKERs,whosePLEVEL is either P001 or P002. SELECT NAME, DESIG FROM WORKER WHERE PLEVEL IN ('P001', 'P002') ; OR SELECT NAME, DESIG FROM WORKER WHERE PLEVEL = 'P001' OR PLEVEL= 'P002'; (1 Marie for correct query) (½ Marie for partially correct answer) (iii) To display the content of all the WORKERs table, whose DOB is in between '19-JAN-1984' and '18-JAN-1987'. SELECT * FROM WORKER WHERE DOB BETWEEN '19-JAN-1984' AND '18-JAN-1987' ; OR SELECT * FROM WORKER WHERE DOB >= '19-JAN-1984' AND DOB<='18-JAN-1987'; OR
  • 417.
    365 SELECT * FROMWORKER WHERE DOB > '19-JAN-1984' AND DOB<'18-JAN-1987' ; (1 Mark for correct query) (½ Mark for partially correct answer) (iv) Toaddanewrowwiththefollowing: 19, 'Daya Kishore', 'Operator', 'P003', '19-Jun-2008', '11-Jun-1984' INSERT INTO WORKER VALUES (19, 'Daya Kishore', 'Operator' , 'P003' , '11-Jun-1984'); (1 Mark for correct query) (½ Mark for partially correct answer) (c) GivetheoutputofthefollowingSQLqueries: 2 (i) SELECTCOUNT(PLEVEL),PLEVELFROMWORKERGROUP BYPLEVEL; Ans. COUNT (PLEVEL) PLEVEL 1 P001 2 P002 2 P003 ( ½ Mark for correct output) (ii) SELECT MAX (DOB), MIN (DOJ) FROM WORKER; MAX (DOB) MIN (DOJ) 12-Jul-1987 13-Sep-2004 ( Mark for correct output) (iii) SELECT Name, Pay FROM WORKER W, PAYLEVEL P WHERE W. PLEVEL = S. PLEVELAND P.ECODE<13 ; Name Pay RadheShyam 26000 Chander Nath 12000
  • 418.
    366 OR P.ECode does notexist (½ Mark for correct output) OR ( Mark for writing No Output) (iv) SELECT PLEVEL, PAY+ALLOWANCE FROM PAYLEVEL WHERE PLEVEL= 'P003' ; PLEVEL PAY+ALLOWANCE P003 118000 (½ Mark for correct output) 6 (a) VerifythefollowingusingTruthTable. 2 U. (U' +V) = (U + V) Ans U V U' U'+V U.(U'+V) U+V 0 0 1 1 0 0 0 1 1 1 0 1 1 0 0 0 0 1 1 1 0 1 1 1 VERIFIED FALSE (2 Marks to be awarded if Truth Table is made OR any equivalent term conveyingthesamemeaning) (b) WritetheequivalentBooleanExpressionforthefollowinglogicCircuit. 2
  • 419.
    367 Ans F=(X+Y').(X+Z') (2 Marksfor the final expression (X+Y').(X+Z') OR (1 Mark for anyone of the correct terms out of (X+Y’) or (X+ Z’) (c) Write the POS form of a Boolean function F, which is represented in a truth tableasfollows: 1 A B C F 0 0 0 0 0 0 1 1 0 1 0 1 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 0 1 1 1 1 Ans F(A,B,C) = (A+B+C).(A+B'+C').(A'+B+C').(A'+B'+C) (1 Mark for the correct POS form) Note: Deduct ½ mark if wrong variable names are used (d) ReducethefollowingBooleanExpressionusingK-Map: 3 F(P, Q, R, S) = E (0,1,2,4,5,6,8, 12) P' Q' P' Q P Q P Q' R' S' 1 1 1 1 R' S 1 1 R S R S' 1 1 OR
  • 420.
    368 R' S' R'S R S R S' P' Q' 1 1 1 P' Q 1 1 1 P Q 1 P Q' 1 Ans F(P,Q,R,S) = P'R' + R'S' + P'S' (½ Mark for placing all 1s at correct positions in K-Map) (½ Mark for each grouping) (1 Mark for writing final expression in reduced/minimal form) Note: Deduct ½ mark if wrong variable names are used 7. (a) Differentiatebetweenpacketswitchingandmessageswitchingtechniquein networkcommunication. 1 Ans Packet switching: In packet switching, a fixed size of data packet that can be transmittedacrossthenetworkisspecifiedandthenthedatapacketsaresent throughswitchingstationstothefinaldestination.Allthepacketsarestoredin the main memory instead of disk. As a result accessing time of packets is reduced. Message switching: The source computer sends data (message) to the switching station, which stores data in a buffer. It then looks for a free link to anotherswitchingstationandsendsdatatothatstation.Thisprocesscontinues until data is delivered to the destination computer. This type of switching techniqueisalsoknownas"storeandforward"switching. (½ Marks for written OR diagrammatic explanation of correct Packet Switching) (½ Marks for written OR diagrammatic explanation of correct Message Switching) (b) Differentiate between BUS and STAR topology of networks. 1 Ans BusTopology StarTopology Slower as compared to star Expensive as compared to Bus topologiesofnetwork topology
  • 421.
    369 Breakage of wireat any point Longwirelength disturbstheentirenetwork (½ Marks for written or diagrammatic explanation of correct Bus Topology) (½ Marks for written or diagrammatic explanation of correct Star Topology) (c) What is VoIP? 1 Ans VoiceoverInternetProtocol(VoiceoverIP,VoIP)iscommunicationprotocols and transmission technologies for delivery of voice communications and multimediasessionsoverInternetProtocol(IP)networks,suchastheInternet. Also, we can say,VoIPare IPtelephony, Internet telephony and broadband telephony. (1 Mark for explaining VoIP) Note: 1 Mark for writing full form of VoIP (d) Outofthefollowing,identifyclientsidescript(s)andserversidescript(s). 1 (a) ASP (b) Javascript (c) VBScript (d) JSP Ans Java script & VB script are client side scripts JSP &ASPare server side scripts (½ Mark for writing correct Client Side Scripts) (½ Mark for writing correct Server Side Scripts) (e) QuicklearnUniversityissettingupitsAcademicblocksatPrayagNagarand planning to set up a network. The university has 3 academic blocks and one Human Resource Center as shown in the diagram below. 4
  • 422.
    370 Center to centerdistance between various block/center is as follows" Law Block to Business Block 40m Law Block toTechnology Block 80m Law Block to HR Center 105m BusinessBlocktoTechnologyBlock 30m Business Block to HR Center 35m Technology Block to HR Center 15m Number of Computers in each of the Blocks/Centre is follows: LawBlock 15 TechnologyBlock 40 HR Center 115 BusinessBlock 25 (e1 ) Suggestthemostsuitableplace(i.e.Block/Center)toinstalltheserverofthis universitywithasuitablereason. Ans HRcenter: Reasonasithasthemaximumnumberofcomputers OR BusinessBlock ReasonasitisclosesttoallotherCenters(minimumcablelengthrequired) (½ Mark for mentioning any correct place) (½ Mark for correct reason) OR (1 Mark for any other location with a valid reason) (e2) Suggest an ideal layout for connecting these blocks/centers for a wired con- nectivity.
  • 423.
    371 Ans. Option1: Option2: (1 Markfor mentioning any valid connectivity or topology or diagram connecting various compounds inside the campus) (e3) Whichdeviceyouwillsuggesttobeplaced/installedineachoftheseblocks/ centertoefficientlyconnectallthecomputerswithintheseblocks/center. Ans Switch (1 Mark for mentioning correct device) Note: (1 mark to be awarded if Switch / Hub is mentioned)
  • 424.
    372 (e4) Theuniversityisplanningtoconnectitsadmissionofficeintheclosestbigcity, which ismore than 250 km from university, which type of network out of LAN, MAN or WAN will be formed? Justify your answer. Ans WAN as the given distance is more than the range of LAN and MAN. (1 Mark for correct network type) (f) WhichofthefollowingwillcomeunderCyberCrime? 1 (i) Theft of a brand new sealed pack Laptop (ii) AccesstoabankaccountforgettingunauthorizedMoneyTransaction (iii) Modificationinacompanydatawithunauthorizedaccess (iv) Photocopying a printed report Ans. (ii) and (iii) Note: No marks to be awarded for any other alternative answer (½ Mark for each correct option) (g) Compare open source software and proprietary software. 1 Ans. Open source software refers to a program or software in which the source code (the form of the program when a programmer writes a program in a particular programming language) is available to the general public for use and/ormodificationfromitsoriginaldesignfreeofcharge. Proprietarysoftwareissoftwarethatisownedbyanindividualoracompany (usuallytheonethatdevelopedit).Therearealmostalwaysmajorrestrictions on its use, and its source code is almost always kept secret. (½ Mark for each correct explanation/comparison) MARKING SCHEME COMPUTER SCIENCE QUESTION PAPER CODE 91 EXPECTEDANSWERS 1. (a) What isthedifferencebetweenTypeCastingandAutomaticTypeconversion? Also, give a suitable C++ code to illustrate both. Ans AutomaticTypeConversion:Itisanimplicitprocessofconversionofadata from one type to another. For example:
  • 425.
    373 int N =65; char C = N; //Automatic type conversion ; conversion cout<<C; Type Casting: It is an explicit process of conversion of a data from one type to another. For example intA=1, B=2; float C = (float)A/B; //Type Casting cout<<C; (½ Mark for each correct explanation of Automatic Type Conversion and Type Casting) (½ Mark for each correct example of Automatic Type Conversion and Type Casting) OR (Full 2 Marks for correct example(s) demonstrating the meaning of / difference between Automatic Type Conversion and Type Casting) OR (Only 1 Mark to be awarded if Explanation is given without supporting example) (b) Write the names of the header files, which is/are essentially required torun/ executethefollowingc++code: voidmain() { charCH,Text[]="+veAttitude"; for (int I=0 ; Text[I] ! ='0' ;I++) if (Text[I]== ' ') cout<<end1; else {
  • 426.
    374 CH=toupper (Text [I]); cout<<CH; } } Ans iostream.h ctype.h (½ Mark for writing each correct header file) (c) Rewritethefollowingprogramafterremovingthesyntacticalerrors(ifany). Underlineeachcorrection. 2 include<iostream.h> typedef char [80] String; voidmain() { StringS="Peace"; intL=strlen(S); cout<<S<< 'has'<<L<< 'characters'<<end1; } Ans #include<string.h> #include<iostream.h> typedef char String [80]; voidmain() { String S = "Peace"; intL=strlen(S); cout<<S<< "has" << L << "characters"<<end1; }
  • 427.
    375 (½ Mark forwriting # include<string.h> (½ Mark for adding # before include<iostream.h> (½ Mark for writing typedef char string[80];) (½ Mark for writing "has" and "characters") (d) Findtheoutputofthefollowingprogram: 3 #include<iostream.h> void SwitchOver(intA[ ], int N, int Split) { for (int K=0 ; K<N; K++) if(K<Split) A(K]+ =K; else A [K]*=K; } void Display (intA[ ], int N) { for (int K=0 ; K<N ; K++) (K%2==0)? cout<<A[K]<<"%":cout<<A(K]<<end1; } voidmain() { int H[ ]= {30,40,50,20,10,5}; SwitchOver (H, 6, 3); Display(H,6); }
  • 428.
    376 Ans 30%41 52%60 40%25 (1 Markfor each line with correct values) Note: Deduct½Markifany/all'%tmissing Deduct ½ Mark if endl is not considered at the right positions (e) Findtheoutputofthefollowingprogram: 2 #include<iostream.h> voidmain() { int *Queen, Moves [ ] = {11, 22, 33, 44}; Queen = Moves; Moves [2] + = 22; Cout<< "Queen @"<<*Queen<<end1; *Queen - = 11; Queen + = 2; cout<< "Now @"<<*Queen<<end1; Queen++; cout<<"Finally@"<<*Queen«end1; cout<< "New Origin @"<<Moves[0]<<end1; } Ans Queen @11 Now @55 Finally@44 New origin @0
  • 429.
    377 (½ Mark forwriting each line of output correctly) Note: Deduct ½ Mark if any/all '@' missing or/and endl is not considered at the right positions (f) Go through the C++ code shown below, and find out the possible output or outputsfromthesuggestedOutputOptions(i)to(iv).Also,writetheminimum andmaximumvalues,whichcanbeassignedtothevariableMyNum. 2 #include<iostream.h> #include<stdlib.h> voidmain() { randomize ( ) ; intMyNum,Max=5; MyNum = 20 + random (Max) ; for (int N=MyNum; 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 Ans ii) 22*23*24*25* Minimumvalue20 Maximumvalue24 (1 Marie for mentioning correct option) (½ Mark for mentioning correct minimum value of MyNum) (½ Marie for mentioning correct maximum value of MyNum)
  • 430.
    378 2. (a) DifferentiatebetweenConstructorandDestructorfunctionwithrespectto ObjectOrientedProgramming.2 Ans Constructor Destructor It is a special member function of class It is a special member function of class withthefollowinguniquefeatures: withthefollowinguniquefeatures: It has same name as the name of the It has same name as the name of the class they belong to. class preceded by a symbol ~ (tilde). It has no return type. It has no return type. Itisdefinedinpublicvisibilitymode Itisdefinedinpublicvisibilitymode Itisautomaticallycalledand Itisautomaticallycalledand executed at the time of executed when scope of an object creation/declaration of the object gets over Constructor can be overloaded. Moreover,destructorfunctionscan NOT be overloaded. classTrial classItem } { inta,b; public: public: Item ( ) Trial ( ) {a=0;b=0;}//Constructor {cout<<"ItemManufactured.."<<endl} void Disp ( ) void Working ( ) { {cout<<"ItemisWorking"<<endl;} cout<<a<<b<<endl; ~Item()//Destructor } {cout<<"Itemdestroyed..."«end1} } ; } ; voidmain() voidmain() { { TrialT;//Constructorinvoked ItemI; T . Disp ( ) ; I . Working ( ) ;
  • 431.
    379 } for (intC=0; C<2; C++) { ItemJ; J.Working ( ) ; }// Call of Destructor for J }// Call of Destructor for I (1 Marie for correct explanation OR example illustrating a Constructor) (1 Marie for correct explanation OR example illustrating a Destructor) (b) Write the output of the following C++ code.Also, write the .name of feature of Object Oriented Programming used in the following program jointly illustratedbythefunction[I]to[IV] 2 #include<iostream.h> void Line ( ) //Function[I] { for (int L=1;L<=80;L++) cout<<"-"; cout<<end1; } voidLine(intN) //Function[II] { for(intL=l;L<=N;L++) Cout<<"*"; cout<<endl; } void Line (char C, int N) //Function[III] { for(intL=l;L<=N;L++) cout<<C; cout<<end1; }
  • 432.
    380 void Line (intM, int, N) //Function[IV] { for (int L=1;L<=N;L++) cout<<M*L; cout<<end1; } voidmain() { intA=9, B=4, C=3; char K= '#' ; Line(K,B); Line(A,C); } Ans #### 91827 PolymorphismORFunctionOverloading (½ Mark for writing each correct line of output) (1 Mark for writing the feature. name correctly) (c) DefineaclassApplicantinC++withfollowingdescription: 4 PrivateMembers Adata memberANo (Admission Number) of type long A data member Name of type string Adata memberAgg (Aggregate Marks) of type float A data member Grade of type char AmemberfunctionGradeMe()tofindtheGradeaspertheAggregate Marks obtained by a student. EquivalentAggregate Marks range and the respective Grades are shown as follows:
  • 433.
    381 AggregateMarks Grade >=80 A lessthan 80 and >=65 B less than 65 and >=50 C less than 50 D PublicMembers AfunctionENTER()toallowusertoentervaluesforANo,Name,Agg & call function GradeMe() to find the Grade. Afunction_RESULT()toallowusertoviewthecontentofallthedata members. Ans classApplicant { longANo; char Name [20] ; floatAgg; char Grade; void Grademe ( ) ; public: void Enter ( ) ; void Result ( ) ; } ; voidApplicant::GradeMe() { if(Agg>=80) Grade=' A' ; elseif(Agg>=65) Grade=' B' ;
  • 434.
    382 elseif(Agg>=50) Grade=' C' ; else Grade='D' ; } voidApplicant::Enter() { cin>>ANo; gets (Name) ; cin>>Agg; GradeMe() ; } voidApplicant::Result() { cout<<ANo<<Name<<Agg<<Grade<<end1; } (½ Mark for correct syntax for class header) (½ Mark for correct declaration of data members) (1 Mark for correct definition of GradeMe( )) (1 Mark for correct definition of Enter() with proper invocation of GradeMe( ) function) (1 Mark for correct definition of Result()) NOTE: ½ mark to be deducted if Grademe() is not invoked within Enter() No marks to be deducted if member function definitions are inside the Class
  • 435.
    383 (d) Answerthequestions(i)to(iv)basedonthefollowing: 4 classStudent { intRollno: charSName[20]; floatMarksl; protected: void Result ( ) ; public: Student ( ) ; void Enroll ( ) ;void Display ( ) ; } ; classTeacher { longTCode; char TName [20]; protected: floatSalary; public: Teacher ( ); void Enter ( ) ; void Show ( ) ; } ; class Course: public Student, private Teacher } long CCode [10]; char CourseName [50]; char StartDate [8] , EndDate [8];
  • 436.
    384 public: Course ( ); void Commence ( ); void CDetail ( ) ; } ; (i) Write the names of member functions, which are accessible from objects of class Course Ans Commence() CDetail() Enroll() Display() (1 Mark for correct answer) Note: No marks to be awarded for a partially correct answer Constructorfunctionstobeignored ii) Writethenamesofallthedatamembers,whichis/areaccessiblefrommember functionCommenceofclassCourse Ans CCode CourseName StartDate EndDate Salary (1 Mark for correct answer) Note: No marks to be awarded for a partially correct answer iii) Write the names of all the-members, which are accessible from objects of classTeacher. Ans Enter( ), Show( )
  • 437.
    385 (1 Mark forcorrect answer) Note: No marks to be awarded for a partially correct answer Constructorfunctionstobeignored iv) Which type of Inheritance is illustrated in the above C++ code? Ans MultipleInheritance (1 Mark for correct answer) Note: No marks to be awarded for a partially correct answer 3. (a) Write a Get2From1() function in C++ to transfer the content from one array ALL[] to two different arrays Odd[] and Even[]. The Odd[] array should contain the values from odd positions (1,3,5,...) ofALL[] and Even [] array should contain the values from even positions (0, 2, 4,…..) ofALL[]. 3 Example IftheALL[]arraycontains 12, 34, 56, 67, 89, 90 The Odd[] array should contain 34, 67, 90 And the Even [] array should contain 12,56,89 Ans voilGet2From1(intAll[],intEven[],intOdd[],intSize) { int J=0,K=0; for (int I=0 ;I<Size; 1++) { if(I%2==0) {
  • 438.
    386 Even[J]=All[I]; J++; } else { Odd[K]=All[I); K++; } } } (1 Mark forcorrect loop) (½ Mark for checking even locations) (½ Mark for checking odd locations or writing else for even locations) (½ Mark for assigning elements to the corresponding Even and Odd Array) (½ Mark for incrementing Even and Odd Array Locations) (b) An array G[50][20] is stored in the memory along the row with each of its elementsoccupying8bytes.FindoutthelocationofG[10][15],ifG[0][0]is stored at 4200. 3 Ans AssumingLBR=LBC=0 B=4200 W=8 bytes Number of Rows(N)=50 Number of Columns (M)=20 LOC(Arr[I] [J]) = B +(I*M + J) *W LOC (Arr [10] [15]) = 4200+ (10*20+15)*8 = 4200 + (215*8) = 4200+1720 = 5920
  • 439.
    387 (1 Mark forwriting correct formula (for row major) OR substituting formula with correct values for calculating Address) (2 marks for calculating correct address) Note: 1 mark to be awarded for writing only the correct answer i.e. 5920, without showinganyformula/calculation. (c) WriteafunctioninC++toperformDelete operationona dynamicallyallocated QueuecontainingMembersdetailsasgiveninthefollowingdefinitionofNODE: 4 struct NODE { longMno //MemberNumber char Mname[20]; //Member Name NODE*Link; }; Ans class Queue { NODE *Front, *Rear; public: Queue ( ) {Front = NULL; Rear = NULL; } void QueAdd ( ); void QueDel ( ); void QueDis ( ); ~Queue(); } ; void Queue: :QueDel ( ) { if(Front!=NULL)
  • 440.
    388 { NODE *Temp=Front; cout<<Front->Mno<< "" ; cout<<Front->Mname<<"Deleted"; Front=Front->Link; deleteTemp; if (Front==NULL) Rear=NULL; } else cout<<"Underflow!Queueisempty.."; } (1 Mark for checking Empty Queue) (½ Mark for assigning Front to Temp) (1 Mark for reassigning Front with Front->Link) (1 Mark for deleting Temp) (½ Mark for assigning Rear with NULL if Queue becomes Empty) (d) WriteaDSUMOfunctioninC++tofindsumofDiagonalElementsfroma NxN Matrix. 2 (Assuming that the N is a odd number) Ans void DSUM (intA[ ] [100] ,int N) { int SUMR =0, SUML=0; for(inti=0;i<N;i++} { SUMR=SUMR +A[i] [i] ; SUML = SUML +A[i] [N-1-i] ; }
  • 441.
    389 cout<< " Sumof Diagonal Elements = "<<SUMR + SUML – A[N/2] [N/2] ; } OR void DSUM (intA[] [100], int N) { int SUMR =0, SUML=0; for (int i=0; i<N; i++) { SUMR = SUMR +A[i] [i] ; SUML = SUML +A[i] [N-1-i] ; } cout<<"SumofRightDiagonalElements="<<SUMR<<end1; cout<<"SumofLeftDiagonalElements="<<SUML<<end1; } OR void DSUM (intA[] [100] , int N) { int SUMR =0, SUML=0; for (int i = 0; i<N; i++) { for (int j = 0; j<N; j++) { if(i==j) SUMR=SUMR +A[i] [j] ; else if (i+j == N-1) SUML= SUML+A[i] [j];
  • 442.
    390 } } cout<< "Sum ofDiagonal Elements ="<< SUMR + SUML-A[N/2] [N/2]; } (½ Mark for writing correct Function Header) (½ Mark for writing correct loop) (1 Mark for finding sum of Right Diagonal Elements and/or Left Diagonal Elements) (e) Evaluatethefollowingpostfixnotationofexpression: 2 True, False, NOT,AND, True, True,AND,OR Ans Element Scanned STACK Status True TRUE False TRUE,FALSE NOT TRUE,TRUE AND TRUE True TRUE,TRUE True TRUE,TRUE,TRUE AND TRUE,TRUE OR TRUE FinalResult:TRUE (½ Mark for evaluating each operator correctly) OR (½ Mark only for writing TRUE as the final answer without showing any calculation/Stack) 4. (a) Observetheprogramsegmentgivenbelowcarefullyandfilltheblanksmarked as Statement 1 and Statement 2 using seekg( ), seekp( ) tellp( ) and tellg( ) functionsforperformingtherequiredtask. 1
  • 443.
    391 #include<fstream.h> classITEM { intIno;charIname[20];floatPrice; public: voidModifyPrice();//Thefunctionistomodify price of aparticular ITEM } ; voiditem::ModiyPrice() { fstreamFile; File.open("ITEM.DAT",ios::binary|ios::in|ios::out)||; intCIno; cout<<"ItemNotomodifyprice:";cin>>CIno; while(file.read((char*)this,sizeof(ITEM))) { if(CIno==Ino) { cout<<"PresentPrice:"<<Price<<end1; cout<<"Changedprice:";cin>>Price; int FilePos = __________ ; //Statement 1, ___________________; //Statement 2 File.write((char*)this,sizeof(ITEM)); // Re-writing the record } } File.close( ) ; }
  • 444.
    392 Ans Option 1 Statement1: File.tellp ( ) ; OR File. tellg ( ) ; Statement 2: File.seekp (FilePos - sizeof (ITEM) ) ; OR File.seekp(-sizeof(ITEM),ios::cur)); OR File.seekg(FilePos-sizeof(ITEM)); OR. File.seekg(-sizeof(ITEM),ios::cur)); Ogtion2 Statement 1: File. tellp ( ) – sizeof (ITEM) ; OR File.tellg()-sizeof(ITEM); Statement 2: File.seekp (FilePos) ; OR File.seekg (FilePos) ; (½ Mark for writing Statement 1 correctly) (½ Mark for writing Statement 2 correctly) (b) Write a function in C++ to count the no. of "He" or "She" words present in a textfile"STORY.TXT". 2 Ifthefile"STORY.TXT"contentisasfollows: Heisplayingintheground.Sheis Playingwithherdolls. Theoutputofthefunctionshouldbe CountofHe/Sheinfile:2 Ans void COUNT ( ) { ifstreamFil("STORY.TXT"); char STR [10]; int count = 0; while(!Fil.eof()) {
  • 445.
    393 Fil>>STR; if (strcmp (STR,"He") ==0 | | strcmp (STR, "She") = =0) count++; } Cout<<"CountofHe/Sheinfile:"<<count<<end1; Fil.close();//Ignore } OR Anyothercorrectfunctiondefinitionperformingthedesiredoperation (½ Mark for opening STORY. TXT correctly) (½ Mark for reading each word (Whichever method adopted) from the file) (½ Mark for comparing the word with 'He' and 'She' and incrementing counter) (½ Mark for displaying the count of 'He/She' with/without the Text Message) Note:IgnorecasesensitivityforHe/She (c) Write a function in C++ to search for a camera from a binary file "CAMERA.DAT" containing the objects of class" CAMERA (as defined below). The user should enter the Model No and the function should search display the details of the camera. 3 classCAMERA { longModelNo; floatMegaPixel; intZoom; charDetails[120]; public: voidEnter(){cin>>ModelNo>>MegaPixel>>Zoom;gets(Details);} voidDisplay() {cout<<ModelNo<<MegaPixel<<Zoom<<Details<<endl;} long GetModelNo ( ) {return ModelNo;} };
  • 446.
    394 Ans void Search( ) { CAMERAC; longmodelnum; cin>>modelnum; ifstreamfin; fin.open("CAMERA.DAT",ios::binary|ios::in); while(fin.read((char*)&C,sizeof(C))) { if (C. GetModelNo ( ) modelnum) C.Display(); } Fin.close( ) ; //Ignore } OR voidSearch(longmodelnum) { CAMERAC; ifstreamfin; fin.open("CAMERA.DAT",ios::binary|ios::in); while(fin.read((char*)&C,sizeof(C))) { if (C.GetModelNo() = = modelnum) C. Display (); } Fin.close();//Ignore }
  • 447.
    395 (½ Mark fordeclaring and entering a model number for a camera to search OR passing it as a parameter to the function) (½ Marie for opening CAMERA.DAT in correct mode) (½ Marie for reading each record from CAMERA.DAT) (½ Marie for correct loop / checking end of file) (½ Marie for comparing value returned by GetModelNo() with model number entered) (½ Marie for displaying the matching record) 5. (a) What do you understand by Selection & Projection operations in relational algebra? 2 Ans Projectionforselectingthecolumnsoftable Selection for selecting the rows of table (1 Marie for correct explanation of Projection) (1 Marie for correct explanation of Selection correctly) OR (Full 2 Marks for correct example(s) demonstrating the meaning of Projection & Selection) Consider the following tables EMPLOYEE and SALGRADE and answer (b) and (c) parts of this question: Table: EMPLOYEE ECODE NAME DESIG SGRADE DOJ DOB 101 AbdulAhmad EXECUTIVE S03 23-Mar-2003 13-Jan-1980 102 Rav:i.Chander HEAD-IT S02 12-Feb-2010 22-Jul-1987 103 John Ken RECEPTIONIST S03 24-June-2009 24-Feb-1983 105 NazarAmeen GM S02 11-Aug-2006 03-Mar-1984 108 PriyamSen CEO S01 29-Dec-2004 19-Jan-1982
  • 448.
    396 Table:SALGRADE SGRADE SALARY HRA S0l56000 18000 S02 32000 12000 S03 24000 8000 (b) WriteSQLcommandsforthefollowingstatements: (i) To display the details of all EMPLOYEEs, in descending order of DOJ Ans SELECT * FROM EMPLOYEE ORDER BY DOJ DESC; (1 Mark for correct query) OR (½ Mark for partially correct answer) (ii) TodisplayNAMEandDE51GofthoseEMPLOYEEs,whose5ALGRADE is either 502 or 503 Ans SELECT NAME, DESIG FROM EMPLOYEE WHERE SGRADE = 'S02' OR SGRADE= 'S03'; OR SELECT NAME, DESIG FROM EMPLOYEE WHERE SALGRADE ='S02' OR SALGRADE='S03'; (1 Mark for correct query) OR (½ Mark for partially correct answer) (iii) To display the content of all the EMPLOYEEs table, whose DOJ is in between'09-Feb-2006' and '08-Aug-2009'. Ans SELECT * FROM EMPLOYEE WHERE DOJ BETWEEN '09-Feb-2006'and '08-Aug-2009'; OR SELECT * FROM EMPLOYEE WHERE DOJ > = '09-Fab-2006' and DOJ <='08-Aug-2009';
  • 449.
    397 OR SELECT * FROMEMPLOYEE WHERE DOJ > '09-Feb-2006' and DOJ <' 08-Aug-2009" ; (1 Mark for correct query) OR (½ Mark for partially correct answer) (iv) Toaddanewrowwiththefollowing: 109, 'Harish Roy', 'HEAD-IT', 'S02', '09-Sep-2007, '21-Apr-1983' Ans INSERT INTO EMPLOYEE VALUES(109,'Harish Roy' ,'HEAD-IT' ,'S02' ,'09-Sep-2007' ,'21-Apr- 1983' ) ; (1 Mark for correct query) OR (½ Mark for partially correct answer) (c) Give:theoutputofthefollowingSQLqueries: 2 (i) SELECT COUNT (SGRADE),SGRADE FROM EMPLOYEE GROUP BYSGRADE; Ans COUNT (SGRADE) SGRADE 1 S01 2 S02 2 S03 (½ Mark. for correct output) (ii) SELECT MIN(DOB), MAX (DOJ) FROM EMPLOYEE; Ans MIN (DOB) MAX (DOJ) 13-Jan-1980 12-Feb-2010 (½ Mark for correct output)
  • 450.
    398 (iii) SELECT NAME, SALARYFROM EMPLOYEE E, SALGRADE S WHERE E.SGRADE= S.SGRADEAND E.ECODE<103; Ans Name Salary AbdulAhmad 24000 RaviChander 32000 (½ Mark for correct output) (iv) SELECTSGRADE,SALARY+HRAET:)MSALGRADEWHERESGRADE= 'S02'; Ans SGRADE SALARY+HRA S02 44000 (½ Mark for correct output) 6 (a) YerifythefollowingusingTruthTable: 2 X+Y. Z=(X+Y).(X+Z) Ans X Y Z Y.Z X+Y.Z X+Y X+Z (X+Y).(X+Z) 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0 1 0 0 0 1 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 0 1 0 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 VERIFIED ( 2 Mark for correct verification using Truth Table) NOTE: No marks are to be awarded if only algebraic proof is given.
  • 451.
    399 (b) WritetheequivalentBooleanExpressionforthefollowingLogicCircuit: 2 AnsF = P.Q' + P.R' (2 Marks for the final expression P.Q'+P.R') OR (1 Mark for anyone of the correct terms out of P .Q' or P .R' (c) Write the SOPform of a Boolean function F, which is represented in a truth tableasfollows: 1 U V W F 0 0 0 1 0 0 1 0 0 1 1 1 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 1 Ans F(U, V, W) = U'.V'.W'+ U'.V.W + U.V.W'+ U.V.W (1 Mark for the correct SOP form) Note: Deduct ½ mark if wrong variable names are used (d) ReducethefollowingBooleanExpressionusingK-Map: 3 F(A, B,C, D) = Σ (0,1, 2, 4, 5, 6, 7, 8, 10)
  • 452.
    400 A' B' A'B AB AB' C' D' 1 1 1 C' D 1 1 C D C D' 1 1 1 OR C'D' C'D CD CD' A' B' 1 1 1 A' B 1 1 1 AB AB' 1 1 Ans F (A,B,C,D) = A'C' + A'D' + B'D' (½ Mark for placing all 1s at correct positions in K-Map) (½ Mark for each grouping) (1 Mark for writing final expression in reduced/minimal form) Note : Deduct ½ mark if wrong variable names are used 7. (a) In networking, what-is WAN? How is it different from LAN? 1 Ans A WAN (wide area network), is not restricted to a geographical location, althoughitmightbeconfinedwithintheboundsofastateorcountry.AWAN connects several LANs, and may be limited to an enterprise (a corporation or an organization) or accessible to the public. The technology is high speed and relatively expensive. The Internet is an example of a worldwide public WAN. A LAN (local area network) is a group of computers and network devices connectedtogether,usuallywithinthesamebuildingorcampus. (½ Marks for writing WAN correctly) (½ Marks for writing LAN correctly)
  • 453.
    401 (b) DifferentiatebetweenXMLandHTML. 1 AnsTheExtensibleMarkupLanguage(XML)wasinitiallyvisualizedasalanguage for defining new document formats for the World WideWeb. XMLis text- based formats that provide mechanisms for describing document structures with the help of user defined Tags. HTML - short for Hypertext Markup Language is the predominant markup language for the creation of web pages. It provides a means to describe the structureoftext-basedinformationinadocumentbydenotingcertaintextas headings,paragraphs,lists,andtosupplementthattextwithinteractiveforms, embedded images, and other objects using predefined Tags. (½ Marks for explaining XML correctly) (½ Marks for explaining HTML correctly) OR (½ Mark Only if correct expansion of both the terms XML and HTML are given) (c) What is WEB2.0? 1 Ans The term Web 2.0 is associated with web applications that facilitate participatoryinformationsharing,interoperability,user-centereddesign, and collaboration on the World Wide Web. Web 2.0 is also used for social networking. Example: Social Networking Sites, Blogs, Facebook, VideoSharingSites,VideoConferencingApplicationsetc. (1 Mark for correctly explaining Web 2.0 - anyone of the highlighted text to be consider appropriate) Note: Only ½ Mark for mentioning an example or an improved Web Application of WWW (d) Out of the following, identify client side script (s) and server side script (s). 1 (i) Javascript (ii) ASP (iii) vbscript (iv) JSP
  • 454.
    402 Ans Javascript &vbscript are client side scripts JSP &ASPare server side scripts (½ Mark for writing correct 'Client Side Scripts) ( ½ Mark for writing correct Server Side Scripts) (e) Great Studies University is setting up itsAcademic schools at Sunder Nagar andplanningtosetupanetwork.Theuniversityhas3academicschoolsand oneadministrationcenterasshowninthediagrambelow: 4 Center to center distances between various buildings is as follows : Law School to Business School 60m Law School to Technology School 90m Law School toAdmin Center 115m BusinessSchooltoTechnologySchool 40m BusinessSchoolto.AdminCenter 45m TechnologySchooltoAdminCenter 25m Number of Computers in each of the Schools/Center is follows: LawSchool 25 TechnologySchool 50 AdminCenter 125 BusinessSchool 35
  • 455.
    403 (i) Suggest themost suitable place (i.e. School/Center) to install the server of this universitywithasuitablereason. 1 Ans Option 1 : Admin center as it has the most number of computers Option 2. BusinessSchoolasitwillrequireminimumcablelengthtoconnectotherblocks (½ Mark for mentioning the correct place) (½ Mark for mentioning a valid reason) OR (1 Mark for any other location with a valid reason) (ii) Suggest an ideal layout for connecting these schools/ center for a wired connectivity. 1 Ans Option1: Option2:
  • 456.
    404 (1 Mark formentioning any valid connectivity or topology or diagram connecting various compounds inside the campus) (iii) Which device will you suggest to be placed/installed in each of these schools / centertoefficientlyconnectallthecomputerswithintheseschools/center? 1 Ans Switch (1 Mark for mentioning correct device) NOTE:Award1fullmarkifHub/Switchismentioned. (iv) Theuniversityisplanningtoconnectitsadmissionofficeintheclosestbigcity, whichismorethan350kmfromtheuniversity.Whichtypeofnetworkoutof LAN, MAN or WAN will be formed? Justify your answer. 1 Ans WAN as the distance is more than the range of LAN or MAN. 1 (1 Mark for correct network type) (f) Compare Open Source Software and Proprietary Software. 1 Ans Open source software refers to a program or software in which the source code (the form of the program when a programmer writes a program in a particular programming language) is available to the general public for use and/ormodificationfromitsoriginaldesignfreeofcharge. Proprietarysoftwareissoftwarethatisownedbyanindividualoracompany (usuallytheonethatdevelopedit).Therearealmostalwaysmajorrestrictions on its use, and its source code is almost always kept secret. (1 Mark for correct/valid comparison) OR ( Mark for defining each term correctly) (g) What are cookies? 1 Ans A small piece of information that a server sends to a client. When a person visitsaWebsitewithcookiecapabilities,itsserversendscertaininformation about him/her to the browser, which is stored on his/her hard drive as a text file.At some later time (such as returning to the site the next day), the server retrieves the cookie. (1 Mark for correct definition)
  • 457.
    1 COMPUTER SCIENCE (Theory) ClassXII - Code : 083 Blue Print S.No. UNIT VSA SA I SA II LA TOTAL (1 Mark) (2 Marks) (3 Marks) (4 Marks) 1 Review of C++ covered in Class XI 1 (1) 8 (4) 3 (1) 12 (6) 2 Object Oriented Programming in C++ a) Introduction to OOP using C++ 2 (1) 4 (1) 6 (2) b) Constructor & Destructor 2 (1) 2 (1) c) Inheritance 4 (1) 4 (1) 3 Data Structure & Pointers a) Address Calculation 3 (1) 3 (1) b) StaticAllocation of Objects 2 (1) 3 (1) 5 (2) c) DynamicAllocation of Objects 4 (1) 4 (1) d) Infix & Postfix Expressions 2 (1) 2 (1) 4 Data File Handling in C++ a) Fundamentals of File Handling 1 (1) 1 (1) b) Text File 2 (1) 2 (1) c) Binary Files 3 (1) 3 (1) 5 Databases and SQL a) Database Concepts 2 (1) 2 (1) b) Structured Query Language 2 (1) 4 (1) 6 (2)
  • 458.
    2 6 Boolean Algebra a)Introduction to BooleanAlgebra & Laws 2 (1) 2 (1) b) SOP & POS 1 (1) 1 (1) c) Karnaugh Map 3 (1) 3 (1) d) Basic Logic Gates 2 (1) 2 (1) 7 Communication & Open Source Concepts a) Introduction to Networking 2 (2) 2 (2) b) Media,Dvices,Topologies & Protocols 4 (1) 4 (1) c) Security 2 (2) 2 (2) d) Webservers 1 (1) 1 (1) e) Open Source Terminologies 1 (1) 1 (1) TOTAL 9 (9) 26 (13) 15 (5) 20 (5) 70 (32)
  • 459.
    3 COMPUTER SCIENCE (Theory) ClassXII - Code : 083 Design of Question Paper for 2009-2010 TIME : 3 Hrs MM : 70 Weightage of marks over different dimensions of the question paper shall be as follows: A. Weightage to different topics/content units S.No Topics Marks 1 Review of C++ covered in Class XI 12 2 Object Oriented Programming in C++ 12 3 Data Structure & Pointers 14 4 Data File Handling in C++ 06 5 Databases and SQL 08 6 BooleanAlgebra 08 7 Communication and Open Source Concepts 10 Total 70 B. Weightage to different forms of questions S.No Forms of Questions Marks for No. of Total each question Questions Marks 1 Very ShortAnswer questions (VSA) 01 09 09 2 Short answer questions - Type I (SAI) 02 13 26 3 Short answer questions - Type II (SAII) 03 05 15 4 Long answer questions (LA) 04 05 20 Total 32 70 C. Scheme of Options There will be no overall choice.All questions are compulsory. D. Difficulty level of questions S.No. Estimated difficulty level Percentage of marks 1 Easy 15% 2 Average 70% 3 Difficult 15% • Based on the above design, two sets of sample papers along with their blue prints and Mark- ing schemes have been included in this document. • About 20% weightage has been assigned to questions testing higher order thinking (HOT) skills of learners.
  • 460.
    4 COMPUTER SCIENCE (Theory)- Class XII Sample Question Paper–I Subject Code - 083 TIME : 3 Hrs MM : 70 1. (a) What is the difference between Global Variable and Local Variable? Also, give a suitable C++ code to illustrate both. 2 (b) Which C++ header file(s) will be essentially required to be included to run / execute the following C++ code: 1 void main() { char Msg[ ]="Sunset Gardens"; for (int I=5;I<strlen(Msg);I++) puts(Msg); } (c) Rewrite the following program after removing the syntactical errors (if any). Underline each correction. 2 #include [iostream.h] class MEMBER { int Mno;float Fees; PUBLIC: void Register(){cin>>Mno>>Fees;} void Display{cout<<Mno<<" : "<<Fees<<endl;} }; void main() { MEMBER M; Register(); M.Display(); } No. Questions Marks
  • 461.
    5 No. Questions Marks (d)Find the output of the following program: 3 #include <iostream.h> struct GAME { int Score, Bonus;}; void Play(GAME &g, int N=10) { g.Score++;g.Bonus+=N; } void main() { GAME G={110,50}; Play(G,10); cout<<G.Score<<":"<<G.Bonus<<endl; Play(G); cout<<G.Score<<":"<<G.Bonus<<endl; Play(G,15); cout<<G.Score<<":"<<G.Bonus<<endl; } (e) Find the output of the following program: 2 #include <iostream.h> void Secret(char Str[ ]) { for (int L=0;Str[L]!='0';L++); for (int C=0;C<L/2;C++) if (Str[C]=='A' || Str[C]=='E') Str[C]='#'; else { char Temp=Str[C];
  • 462.
    6 No. Questions Marks Str[C]=Str[L-C-1]; Str[L-C-1]=Temp; } } voidmain() { char Message[ ]="ArabSagar"; Secret(Message); cout<<Message<<endl; } (f) In the following program, if the value of Guess entered by the user is 65, what will be the expected output(s) from the following options (i), (ii), (iii) and (iv)? 2 #include <iostream.h> #include <stdlib.h> void main() { int Guess; randomize(); cin>>Guess; for (int I=1;I<=4;I++) { New=Guess+random(I); cout<<(char)New; } } (i) ABBC (ii) ACBA (iii) BCDA (iv) CABD
  • 463.
    7 No. Questions Marks 2. (a)What do you understand by Data Encapsulation and Data Hiding? Also, give a suitable C++ code to illustrate both. 2 (b) Answer the questions (i) and (ii) after going through the following class: 2 class Seminar { int Time; public: Seminar() //Function 1 { Time=30;cout<<"Seminar starts now"<<end1; } void Lecture() //Function 2 { cout<<"Lectures in the seminar on"<<end1; } Seminar(int Duration) //Function 3 { Time=Duration;cout<<"Seminar starts now"<<end1; } ~Seminar() //Function 4 { cout<<"Vote of thanks"<<end1; } }; i) In Object Oriented Programming, what is Function 4 referred as and when does it get invoked/called? ii) In Object Oriented Programming, which concept is illustrated by Function 1 and Function 3 together? Write an example illustrating the calls for these functions.
  • 464.
    8 No. Questions Marks (c)Define a class TEST in C++ with following description: 4 Private Members • TestCode of type integer • Description of type string • NoCandidate of type integer • CenterReqd (number of centers required) of type integer • A member function CALCNTR() to calculate and return the number of centers as (NoCandidates/100+1) Public Members • Afunction SCHEDULE() to allow user to enter values for TestCode, Description, NoCandidate & call function CALCNTR() to calculate the number of Centres • A function DISPTEST() to allow user to view the content of all the data members (d) Answer the questions (i) to (iv) based on the following: 4 class PUBLISHER { char Pub[12]; double Turnover; protected: void Register(); public: PUBLISHER(); void Enter(); void Display(); }; class BRANCH { char CITY[20]; protected: float Employees;
  • 465.
    9 No. Questions Marks public: BRANCH(); voidHaveit(); void Giveit(); }; classAUTHOR : private BRANCH , public PUBLISHER { int Acode; charAname[20]; floatAmount; public: AUTHOR(); void Start(); void Show(); }; (i) Write the names of data members, which are accessible from objects belong- ing to classAUTHOR. (ii) Write the names of all the member functions which are accessible from ob- jects belonging to class BRANCH. (iii) Write the names of all the members which are accessible from member func- tions of classAUTHOR. (iv) How many bytes will be required by an object belonging to classAUTHOR? 3. (a) Write a function in C++ to merge the contents of two sorted arrays A & B into third array C. Assuming array A and B are sorted in ascending order and the resultant array C is also required to be in ascending order. (b) An array S[40][30] is stored in the memory along the row with each of the ele- ment occupying 2 bytes, find out the memory location for the element S[20][10], if the Base Address of the array is 5000. (c) Write a function in C++ to perform Insert operation in a dynamically allocated Queue containing names of students. (d) Write a function in C++ to find the sum of both left and right diagonal ele- 3 3 4 2
  • 466.
    10 No. Questions Marks mentsfrom a two dimensional array (matrix). (e) Evaluate the following postfix notation of expression: 20, 30, +, 50, 40, - ,* 4. (a) Observe the program segment given below carefully and fill the blanks marked as Statement 1 and Statement 2 using seekp() and seekg() functions for performing the required task. 1 #include <fstream.h> class Item { int Ino;char Item[20]; public: //Function to search and display the content from a particular record number void Search(int ); //Function to modify the content of a particular record number void Modify(int); }; void Item::Search(int RecNo) { fstream File; File.open("STOCK.DAT",ios::binary|ios::in); ______________________ //Statement 1 File.read((char*)this,sizeof(Item)); cout<<Ino<<"==>"<<Item<<endl; File.close(); } void Item::Modify(int RecNo) { fstream File; File.open("STOCK.DAT",ios::binary|ios::in|ios::out); 2
  • 467.
    11 No. Questions Marks cout>>Ino;cin.getline(Item,20); ______________________//Statement 2 File.write((char*)this,sizeof(Item)); File.close(); } (b) Write a function in C++ to count the number of lines present in a text file "STORY.TXT". 2 (c) Write a function in C++ to search for a BookNo from a binary file "BOOK.DAT", assuming the binary file is containing the objects of the following class. 3 class { int Bno; char Title[20]; public: int RBno(){return Bno;} void Enter(){cin>>Bno;gets(Title);} void Display(){cout<<Bno<<Title<<endl;} }; 5. (a) What do you understand by Degree and Cardinality of a table? 2 Consider the following tables ACTIVITY and COACH and answer (b) and (c) parts of this question: Table: ACTIVITY A Code ActivityName Stadium Participants Prize Schedule Num Money Date 1001 Relay 100x4 StarAnnex 16 10000 23-Jan-2004 1002 High jump StarAnnex 10 12000 12-Dec-2003 1003 Shot Put Super Power 12 8000 14-Feb-2004 1005 Long Jump StarAnnex 12 9000 01-Jan-2004 1008 Discuss Throw Super Power 10 15000 19-Mar-2004
  • 468.
    12 No. Questions Marks Table:COACH PCode Name Acode 1 Ahmad Hussain 1001 2 Ravinder 1008 3 Janila 1001 4 Naaz 1003 (b) Write SQL commands for the flowing statements: 4 (i) To display the names of all activities with their Acodes in descending order. (ii) To display sum of PrizeMoney for theActivities played in each of the Stadium separately. (iii) To display the coach's name and ACodes in ascending order of ACode from the table COACH (iv) To display the content of theActivity table whose ScheduleDate earlier than 01/01/2004 in ascending order of ParticipantsNum. (c) Give the output of the following SQL queries: 2 (i) SELECT COUNT(DISTINCT ParticipantsNum) FROMACTIVITY; (ii) SELECT MAX(ScheduleDate),MIN(ScheduleDate) FROMACTIVITY; (iii) SELECT Name,ActivityName FROMACTIVITYA,COACH C WHERE A.Acode=C.AcodeAND A.ParticipantsNum=10; (iv) SELECT DISTINCTAcode FROM COACH; 6. (a) State and verify Demorgan's Laws algebraically. 2 (b) Write the equivalent Boolean Expression for the following Logic Circuit 2
  • 469.
    13 No. Questions Marks (c)Write the POS form of a Boolean function F, which is represented in a truth table as follows: 1 U V W F 0 0 0 1 0 0 1 0 0 1 0 1 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 1 1 1 (d) Reduce the following Boolean Expression using K-Map: 3 F(A,B,C,D)= (0,1,2,4,5,6,8,10) 7. a) Compare any two Switching techniques. 1 b) Which of the following is not a Client Side script: 1 (i) VB Script (ii) Java Script (iii) ASP (iv) PHP c) If someone has hacked your Website, to whom you lodge the Complain? 1 d) What do you mean by IP Address? How is it useful in Computer Security? 1 e) Knowledge Supplement Organisation has set up its new center at Mangalore for its office and web based activities. It has 4 blocks of buildings as shown in the diagram below: 4
  • 470.
    14 No. Questions Marks Centerto center distances between various blocks Black A to Block B 50 m Block B to Block C 150 m Block C to Block D 25 m Block A to Block D 170 m Block B to Block D 125 m Block A to Block C 90 m Number of Computers BlackA 25 Block B 50 Block C 125 Block D 10 e1) Suggest a cable layout of connections between the blocks. e2) Suggest the most suitable place (i.e. block) to house the server of this organisation with a suitable reason. e3) Suggest the placement of the following devices with justification (i) Repeater (ii) Hub/Switch e4) The organization is planning to link its front office situated in the city in a hilly region where cable connection is not feasible, suggest an economic way to connect it with reasonably high speed? f) What do you mean by Spam Mails? How can you protect your mailbox from Spams? 1 g) Mention any two advantages of Open Source Software over Proprietary Software. 1
  • 471.
    15 COMPUTER SCIENCE (Theory)- Class XII Marking Scheme Sample Question Paper–I Subject Code - 083 TIME : 3 Hrs MM : 100 1. (a) Global Variable Local Variable 2 l It is a variable which is declared l It is a variable which is declared with outside all the functions in a function or with in a compound statement l It is accessible throughout l It is accessible only within a function/ the program compound statement in which it is declared #include <iostream.h> float NUM=900; //NUM is a global variable void LOCAL(int T) { int Total=0; //Total is a local variable for (int I=0;I<T;I++) Total+=I; cout<<NUM+Total; } void main() { LOCAL(45); } (1 Mark for two differences) No. Answers Marks
  • 472.
    16 (1 Mark forthe suitable example) OR (Full 2 Mark for explanation of differences with the help of an example) OR (1 Mark for only example with no explanation) (b) (i) string.h (ii) stdio.h 1 ( ½ Mark for mentioning each correct header filename) (c) #include <iostream.h> 2 class MEMBER { int Mno;float Fees; public: void Register(){cin>>Mno>>Fees;} void Display(){cout<<Mno<<":"<<Fees<<endl;} }; void main() { MEMBER M; M.Register(); M.Display(); } ( ½ Mark each correction) (d) 111:60 3 112:70 113:85 (1 Mark for each correct line of output) No. Answers Marks
  • 473.
    17 (e) #agaSbarr 2 (2Marks for correct line of output) (f) (i) ABBC 2 (2 Marks for mentioning correct option) 2. (a) Data Encapsulation: Wrapping up of data and functions together in a single unit is 2 known as Data Encapsulation. In a class, we wrap up the data and functions together in a single unit. Data Hiding: Keeping the data in private visibility mode of the class to prevent it from accidental change is known as Data Hiding. class Computer { char CPU[10];int RAM; public: Data Encapsulation void STOCK(); void SHOW(); }; ( ½ Mark each for appropriate definitions) (1 Mark for appropriate example showing both) (b) i) Destructor, it is invoked as soon as the scope of the object gets over. 2 ( ½ Mark for mentioning destructor) ( ½ Mark for remaining answer) ii) Constructor Overloading (or Function Overloading or Polymorphism) Seminar S1; //Function 1 Seminar S2(90); //Function 3 ( ½ Mark for mentioning the correct concept) ( ½ Mark for the example) No. Answers Marks
  • 474.
    18 (c) class TEST4 { int TestCode; char Description[20]; int NoCandidate,CenterReqd; void CALCNTR(); public: void SCHEDULE(); void DISPTEST(); }; void TEST::CALCNTR() { CenterReqd=NoCandidate/100 + 1; } void TEST::SCHEDULE() { cout<<"Test Code :";cin>>TestCode; cout<<"Description :";gets(Description); cout<<"Number :";cin>>NoCandidate; CALCNTR(); } void TEST::DISPTEST() { cout<<"Test Code :"<<TestCode<<endl; cout<<"Description :"<<Description<<endl; cout<<"Number :"<<NoCandidate<<endl;; cout<<"Centres :"<<CenterReqd<<endl;; } (½ Mark for correct syntax for class header) (½ Mark for correct declarations of data members) (1 Mark for appropriate definition of function CALCNTR()) (1 Mark for appropriate definition of SCHEDULE() with a call for CALCNTR()) (1 Mark for appropriate definition of DISPTEST()) (d) (i) None of data members are accessible from objects belonging to class 4 AUTHOR. No. Answers Marks
  • 475.
    19 No. Answers Marks (1Mark for correct answer) (ii) Haveit(), Giveit() (1 Mark for correct answer) (iii) Data members: Employees,Acode, Aname,Amount Member function: Register(), Enter(), Display(), Haveit(), Giveit(), Start(), Show(), (1 Mark for correct answer) (iv) 70 (1 Mark for correct answer) 3. (a) voidAddNSave(int A[ ],int B[ ],int C[ ],int N,int M, int &K) 3 { int I=0,J=0; K=0; while (I<N && J<M) if (A[I]<B[J]) C[K++]=A[I++]; else if (A[I]>B[J]) C[K++]=B[J++]; else { C[K++]=A[I++]; J++; } for(;I<N;I++) C[K++]=A[I]; for (;J<M;J++) C[K++]=B[J]; } ( ½ Mark for correct Function Header) ( ½ Mark for correct initialization of required variables) ( ½ Mark for correct formation of loop) ( ½ Mark for appropriate conditions and assignments in the loop) ( ½ Mark for appropriately transferring the remaining elements from first array) ( ½ Mark for appropriately transferring the remaining elements from second array)
  • 476.
    20 No. Answers Marks (b)Given, 3 W=2 N=40 M=30 Base(S)=5000 Row Major Formula: Loc(S[I][J]) =Base(S)+W*(M*I+J) Loc(S[20][10]) =5000+2*(30*20+10) =5000+2*(600+10) =5000+1220 =6220 (1 Mark for writing correct formula (for column major) OR substituting formula with correct values) (1 Mark for writing calculation step - at least one step) (1 Mark for correct address) (c) struct NODE 4 { char Name[20]; NODE *Link; }; class QUEUE { NODE *R,*F; public: QUEUE(); void Insert(); void Delete(); }; void QUEUE::Insert() {
  • 477.
    21 No. Answers Marks NODE*Temp; Temp=new NODE; gets(Temp->Name); Temp->Link=NULL; if (Rear==NULL) { Rear=Temp; Front=Temp; } else { Rear->Link=Temp; Rear=Temp; } } (1 Mark for creating a new node and assigning/entering appropriate values in it) (1 Mark for checking if Queue is Empty) (1 Mark for assigning Rear and Front as Temp - if Queue is Empty) (1 Mark for eassigning Rear->Link as Front and Rear as Temp) (d) void DiagSum(int M[][4],int N,int M) 2 { int SumD1=0,SumD2=0; for (int I=0;I<N;I++) { SumD1+=M[I][I];SumD2+=M[N-I-1][I]; } cout<<"Sum of Diagonal 1:"<<SumD1<<endl; cout<<"Sum of Diagonal 2:"<<SumD2<<endl;
  • 478.
    22 No. Answers Marks } (½ Mark for correct function header) ( ½ Mark for initialization of SumD1 and SumD2 as 0) ( ½ Mark for appropriate loop) ( ½ Mark for correct expression for adding each diagonal elements) (e) 2
  • 479.
    23 (½ Mark forcorrectly evaluating each operator) (½ Mark for the correct result) 4. a) 1 File.seekg(RecNo*sizeof(Item)); //Statement 1 File.seekp(RecNo*sizeof(Item)); //Statement 2 (½ Mark for each correct Statement) (b) 2 void CountLine() { ifstream FIL("STORY.TXT"); int LINES=0; char STR[80]; No. Answers Marks
  • 480.
    24 No. Answers Marks while(FIL.getline(STR,80)) LINES++; cout<<"No. of Lines:"<<LINES<<endl; f.close(); } (½ Mark for opening STORY.TXT correctly) (½ Mark for initializing a counter variable as 0) (½ Mark for correctly reading a line from the file) (½ Mark for correctly incrementing the counter) (c) void BookSearch() 3 { fstream FIL; FIL.open("BOOK.DAT",ios::binary|ios::in); BOOK B; int bn,Found=0; cout<<"Enter Book No. to search…"; cin>>bn; while (FIL.read((char*)&S,sizeof(S))) if (FIL.RBno()==bn) { S.Display(); Found++; } if (Found==0) cout<<"Sorry! Book not found!!!"<<endl; FIL.close(); } ( ½ Mark for opening BOOK.DAT correctly) ( ½ Mark for reading each record from BOOK.DAT) ( ½ Mark for correct loop / checking end of file) ( 1 Mark for comparing Book number) ( ½ Mark for displaying the matching record)
  • 481.
    25 No. Answers Marks 5. (a)Degree: Number of Columns in a table 2 Cardinality: Number of rows in a table (1 Mark for each definition) (b) (i) SELECTAcodes,ActivityName FROM ACTIVITY ORDER BYAcode DESC; 4 (1 Mark for correct query) OR (½ Mark for partially correct answer) (ii) SELECT SUM(PrizeMoney), Stadium FROMACTIVITY GROUP BY Stadium; (1 Mark for correct query) OR (½ Mark for partially correct answer) (iii) SELECT Name, Acode FROM COACH ORDER BY Acode; (1 Mark for correct query) OR (½ Mark for partially correct answer) (v) SELECT * FROMACTIVITY WHERE SchduleDate<'01-Jan-2004' ORDER BY ParticipantsNum; 1 Mark for correct query) OR (½ Mark for partially correct answer) (c) 2 (i) 3 (½ Mark for correct output) (ii) 19-Mar-2004 12-Dec-2003 (½ Mark for correct output)
  • 482.
    26 No. Answers Marks (iii)Ravinder Discuss Throw (½ Mark for correct output) (iv) 1001 1003 1008 (½ Mark for correct output) 6. 2 (X+Y)' = X'.Y' Verification (X+Y)'.(X+Y) = X'.Y'.(X+Y) 0 = X'.Y'.X + X'.Y'.Y 0 = X'.X .Y'+ X'.0 0 = 0 .Y'+ 0 0 = 0 + 0 0 = 0 L.H.S = R.H.S (1 Mark for stating any one of the Demorgan's Law) (1 Mark for verifying the law) (b) 2 F(P,Q)=(P'+Q).(P+Q') (2 Marks for the final expression ) OR (1 Mark for any one of the correct terms out of P'+Q or P+Q') (c) F(U,V,W) = (U+V+W').(U+V'+W').(U'+V+W') 1 (1 Mark for the correct expression )
  • 483.
    27 No. Answers Marks (d)3 F(A,B,C,D)=A'C'+A'D'+B'D' ( ½ Mark for placing all 1s at correct positions in K-Map) ( ½ Mark for each grouping) (1 Mark for writing final expression in reduced/minimal form) Note: Deduct ½ mark if wrong variable names are used 7. a) Appropriate comparison between any two out of Circuit Switching, Message 1 Switching, Packet Switching (1 Mark for writing Appropriate comparison between any two switching technique) b) (iii) ASP and (iv) PHP are not client side scripts 1 (1 Mark for correct answer) c) The complaint has to be lodged with the Police under ITAct 1 (1 Mark for correct answer) d) An Internet Protocol (IP) address is a numerical identification and logical address 1 that is assigned to devices connected in a computer network. An IPAddress is used to uniquely identify devices on the Internet and so one can quickly know the location of the system in the network. ( ½ Mark for meaning of IP Address) ( ½ Mark for mentioning the usefulness in network security)
  • 484.
    28 No. Answers Marks e)e1) (Any of the following option) 4 Layout Option 1: Layout Option 2: Since the distance between Block A and Block B is quite short (1 Mark for showing any of the above suitable cable layout) e2) The most suitable place / block to house the server of this organisation would be Block C, as this block contains the maximum number of computers, thus decreasing the cabling cost for most of the computers as well as increasing the efficiency of the maximum computers in the network. ( ½ Mark for suggesting suitable place and ½ for appropriate reason)
  • 485.
    29 No. Answers Marks e3)(i) For Layout 1, since the cabling distance between Blocks A and C, and that between B and C are quite large, so a repeater each, would ideally be needed along their path to avoid loss of signals during the course of data flow in these routes. For layout 2, since the distance between Blocks A and C is large so a repeater would ideally be placed in between this path ( ½ Mark for suggesting suitable place for connecting repeater)
  • 486.
    30 No. Answers Marks (ii)In both the layouts, a hub/switch each would be needed in all the blocks, to interconnect the group of cables from the different computers in each block Layout 1 Layout 2 ( ½ Mark for suggesting suitable place for connecting hub) e4) The most economic way to connect it with a reasonable high speed would be to use radio wave transmission, as they are easy to install, can travel long distances, and penetrate buildings easily, so they are widely used for communication, both indoors and outdoors. Radio waves also have the advantage of being omni directional, which is they can travel in all the directions from the source, so that the transmitter and receiver do not have to be carefully aligned physically. ( 1 Mark for appropriate answer) f) Spam mails, also known as junk e-mail, is a subset of spam that involves nearly 1 identical messages sent to numerous recipients by e-mail. We can protect our mailbox from spams by creating appropriate filters. ( ½ Mark for the definition of Spam Mails) ( ½ Mark for the appropriate suggestion for protecting mailbox from it)
  • 487.
    31 No. Answers Marks g)Open Source's proponents often claim that it offers significant benefits when com- 1 pared to typical Proprietary Software. Proprietary Software typically favour visible features (giving marketing advantage) over harder-to measure qualities such as sta- bility, security and similar less glamorous attributes. Open Source Software developers are evidently motivated by many factors but favouring features over quality is not noticeable amongst them. For many developers, peer review and acclaim is important, so it's likely that they will prefer to build software that is admired by their peers. Highly prized factors are clean design, reliability and maintainability, with adherence to standards and shared community values preeminent. ( 1 Mark for appropriate answer)
  • 488.
    32 No. Questions Marks COMPUTERSCIENCE (Theory) - Class XII Sample Question Paper–II Subject Code - 083 TIME : 3 Hrs MM : 70 1. (a) What is the difference between Actual Parameter and Formal Parameters? Also, give a suitable C++ code to illustrate both 2 (b) Write the names of the header files to which the following belong: 1 (i) frexp() (ii) isalnum() (c) Rewrite the following program after removing the syntactical errors (if any). Underline each correction. 2 #include <iostream.h> struct Pixels { int Color,Style;} void ShowPoint(Pixels P) { cout<<P.Color,P.Style<<endl;} void main() { Pixels Point1=(5,3); ShowPoint(Point1); Pixels Point2=Point1; Color.Point1+=2; ShowPoint(Point2); } (d) Find the output of the following program: 3 #include <iostream.h> void Changethecontent(intArr[ ], int Count) { for (int C=1;C<Count;C++)
  • 489.
    33 No. Questions Marks Arr[C-1]+=Arr[C]; } voidmain() { intA[]={3,4,5},B[]={10,20,30,40},C[]={900,1200}; Changethecontent(A,3); Changethecontent(B,4); Changethecontent(C,2); for (int L=0;L<3;L++) cout<<A[L]<<'#'; cout<<endl; for (L=0;L<4;L++) cout<<B[L] <<'#'; cout<<endl; for (L=0;L<2;L++) cout<<C[L] <<'#'; } (e) Find the output of the following program: 2 #include <iostream.h> struct Game { char Magic[20];int Score; }; void main() { Game M={"Tiger",500}; char *Choice; Choice=M.Magic; Choice[4]='P'; Choice[2]='L'; M.Score+=50; cout<<M.Magic<<M.Score<<endl;
  • 490.
    34 No. Questions Marks GameN=M; N.Magic[0]='A';N.Magic[3]='J'; N.Score-=120; cout<<N.Magic<<N.Score<<endl; } (f) In the following program, if the value of N given by the user is 20, what maximum and minimum values the program could possibly display? 2 #include <iostream.h> #include <stdlib.h> void main() { int N,Guessnum; randomize(); cin>>N; Guessnum=random(N-10)+10; cout<<Guessnum<<endl; } 2. (a) What do you understand by Polymorphism? Give a suitable example of the same. 2 (b) Answer the questions (i) and (ii) after going through the following program: 2 class Match { int Time; public: Match() //Function 1 { Time=0; cout<<"Match commences"<<end1;
  • 491.
    35 No. Questions Marks } voidDetails() //Function 2 { cout<<"Inter Section Basketball Match"<<end1; } Match(int Duration) //Function 3 { Time=Duration; cout<<"Another Match begins now"<<end1; } Match(Match &M) //Function 4 { Time=M.Duration; cout<<"Like Previous Match "<<end1; } }; i) Which category of constructor - Function 4 belongs to and what is the purpose of using it? ii) Write statements that would call the member Functions 1 and 3 (c) Define a class in C++ with following description: 4 Private Members • A data member Flight number of type integer • A data member Destination of type string • A data member Distance of type float • A data member Fuel of type float • A member function CALFUEL() to calculate the value of Fuel as per the following criteria Distance Fuel <=1000 500 more than 1000 and <=2000 1100
  • 492.
    36 No. Questions Marks morethan 2000 2200 Public Members " A function FEEDINFO() to allow user to enter values for Flight Number, Destination, Distance & call function CALFUEL() to calculate the quantity of Fuel " AfunctionSHOWINFO()toallowusertoviewthecontentofallthedatamembers (d) Answer the questions (i) to (iv) based on the following: 4 class CUSTOMER { int Cust_no; char Cust_Name[20]; protected: void Register(); public: CUSTOMER(); void Status(); }; class SALESMAN { int Salesman_no; char Salesman_Name[20]; protected: float Salary; public: SALESMAN(); void Enter(); void Show(); }; class SHOP : private CUSTOMER , public SALESMAN {
  • 493.
    37 No. Questions Marks charVoucher_No[10]; char Sales_Date[8]; public: SHOP(); void Sales_Entry(); void Sales_Detail(); }; (i) Write the names of data members which are accessible from objects belonging to class CUSTOMER. (ii) Write the names of all the member functions which are accessible from objects belonging to class SALESMAN. (iii) Write the names of all the members which are accessible from member functions of class SHOP. (iv) How many bytes will be required by an object belonging to class SHOP? 3. (a) Write a function in C++ to combine the contents of two equi-sized arrays A and B by adding their corresponding elements as the formula A[i]+B[i]; where value i varies from 0 to N-1 and transfer the resultant content in the third same sized array C. 3 (b) An array P[20][30] is stored in the memory along the column with each of the element occupying 4 bytes, find out the Base Address of the array, if an element P[2][20] is stored at the memory location 5000. 3 (c) Write a function in C++ to perform Push operation on a dynamically allocated Stack containing real numbers. 4 (d) Write a function in C++ to find sum of rows from a two dimensional array. 2 (e) Evaluate the following postfix notation of expression: 2 True, False,AND, True, True, NOT, OR,AND 4. (a) Observe the program segment given below carefully and fill the blanks marked as Statement 1 and Statement 2 using seekg() and tellg() functions for performing the required task. 1 #include <fstream.h> class Employee
  • 494.
    38 No. Questions Marks { intEno;char Ename[20]; public: //Function to count the total number of records int Countrec(); }; int Item::Countrec() { fstream File; File.open("EMP.DAT",ios::binary|ios::in); ______________________ //Statement 1 int Bytes = ______________________ //Statement 2 int Count = Bytes / sizeof(Item); File.close(); return Count; } (b) Write a function in C++ to count the number of alphabets present in a text file "NOTES.TXT". 2 (c) Write a function in C++ to add new objects at the bottom of a binary file "STUDENT.DAT", assuming the binary file is containing the objects of the following class. 3 class STUD { int Rno; char Name[20]; public: void Enter(){cin>>Rno;gets(Name);} void Display(){cout<<Rno<<Name<<endl;} }; - To take the file pointer to the end of file. - To return total number of bytes from the beginning of file to the file pointer.
  • 495.
    39 No. Questions Marks 5. (a)What do you understand by Primary Key & Candidate Keys? 2 Consider the following tables GAMES and PLAYER and answer (b) and (c) parts of this question: Table: GAMES GCode GameName Type Number Prize Schedule Money Date 101 Carom Board Indoor 2 5000 23-Jan-2004 102 Badminton Outdoor 2 12000 12-Dec-2003 103 Table Tennis Indoor 4 8000 14-Feb-2004 105 Chess Indoor 2 9000 01-Jan-2004 108 Lawn Tennis Outdoor 4 25000 19-Mar-2004 Table: PLAYER PCode Name Gcode 1 Nabi Ahmad 101 2 Ravi Sahai 108 3 Jatin 101 4 Nazneen 103 (b) Write SQL commands for the flowing statements: 4 (i) To display the name of all GAMES with their GCodes (ii) To display details of those GAMES which are having PrizeMoney more than 7000. (iii) To display the content of the GAMES table in ascending order of Schedule Date. (iv) To display sum of PrizeMoney for each Type of GAMES (c) Give the output of the following SQL queries: 2 (i) SELECT COUNT(DISTINCT Number) FROM GAMES; (ii) SELECT MAX(ScheduleDate),MIN(ScheduleDate) FROM GAMES; (ii) SELECT Name, GameName FROM GAMES G, PLAYER P WHERE G.Gcode=P.GcodeAND G.PrizeMoney>10000;
  • 496.
    40 No. Questions Marks (iv)SELECT DISTINCT Gcode FROM PLAYER; 6. (a) State and algebraically verify Absorption Laws. 2 (b) Write the equivalent Boolean Expression for the following Logic Circuit 2 (c) Write the SOP form of a Boolean function G, which is represented in a truth table as follows: 1 P Q R G 0 0 0 0 0 0 1 0 0 1 0 1 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 1 1 1 1 1 (d) Reduce the following Boolean Expression using K-Map: 3 F(U,V,W,Z)= π(0,1,2,4,5,6,8,10) 7. a) Define the term Bandwidth. Give any one unit of Bandwidth. 1 b) When do you prefer XML over HTML and why? 1 c) How firewall protect our Network? 1 d) What is the importance of URL in networking? 1 e) Ravya Industries has set up its new center at Kaka Nagar for its office and web based activities. The company compound has 4 buildings as shown in the diagram below: 4
  • 497.
    41 No. Questions Marks Centerto center distances between various buildings is as follows: Harsh Building to Raj Building 50 m Raz Building to Fazz Building 60 m Fazz Building to Jazz Building 25 m Jazz Building to Harsh Building 170 m Harsh Building to Fazz Building 125 m Raj Building to Jazz Building 90 m Number of Computers in each of the buildings is follows: Harsh Building 15 Raj Building 150 Fazz Building 15 Jazz Bulding 25 e1) Suggest a cable layout of connections between the buildings. e2) Suggest the most suitable place (i.e. building) to house the server of this organisation with a suitable reason. e3) Suggest the placement of the following devices with justification: (i) Internet Connecting Device/Modem (ii) Switch e4) The organisation is planning to link its sale counter situated in various parts of the same city, which type of network out of LAN, MAN or WAN will be formed? Justify your answer. f) Compare freeware and Shareware. 1 g) How Trojan Horses are different from Worms? Mention any one difference. 1
  • 498.
    42 COMPUTER SCIENCE (Theory)- Class XII Marking Scheme Sample Question Paper–II Subject Code - 083 TIME : 3 Hrs MM : 100 1. (a) Actual Parameter Formal Parameter 2 It is a parameter, which is used in It is a parameter, which is used in function call to send the value from function header, to receive the value calling environment from actual parameter #include <iostream.h> void Calc(int T) //T is formal parameter { cout<<5*T; } void main() { intA=45; Calc(A);//A is actual parameter } (1 Mark for two differences) (1 Mark for the suitable example) OR (Full 2 Mark for explanation of differences with the help of an example) (b) (i) math.h (ii) ctype.h 1 ( ½ Mark for mentioning each correct header filename) No. Answers Marks
  • 499.
    43 No. Answers Marks (c)#include <iostream.h> 2 struct Pixels { int Color,Style;}; void ShowPoint(Pixels P) { cout<<P.Color<<P.Style<<endl;} void main() { Pixels Point1={5,3}; ShowPoint(Point1); Pixels Point2=Point1; Point1.Color+=2; ShowPoint(Point2); } ( ½ Mark for each correction) (d) 7#9#5# 3 30#50#70#40# 2100#1200# (1 Mark for each line of output) (e) TiLeP550 2 AiLJP430 (1 Mark for each line of output) (f) Maximum Value: 19 Minimum Value: 10 2 (2 Marks for correct values)
  • 500.
    44 No. Answers Marks 2. (a)Polymorphism: It is a method of using the same operator or function (method) to work 2 using different set of inputs. Function overloading is one of the examples of polymor- phism, where more than one function carrying same name behave differently with different set of parameters passed to them. void Display() { cout<<"Hello!"<<endl; } void Display(int N) { cout<<2*N+5<<endl; } (1 Mark each for appropriate definition) (1 Mark for appropriate example) (b) i) Copy constructor, It will help to copy the data from one object to another. 2 ( ½ Mark for mentioning copy constructor) ( ½ Mark for remaining answer) ii) Match M; //Function 1 Match N(10); //Function 3 ( ½ Mark for each statement) (c) class FLIGHT 4 { int Fno; char Destination[20]; float Distance, Fuel; void CALFUEL(); public:
  • 501.
    45 No. Answers Marks voidFEEDINFO(); void SHOWINFO(); }; void FLIGHT::CALFUEL() { if (Distance<=1000) Fuel=500; else if (Distance<=2000) Fuel=1100; else Fuel=2200; } void FLIGHT::FEEDINFO() { cout<<"Flight No :";cin>>Fno; cout<<"Destination :";gets(Destination); cout<<"Distance :";cin>>Distance; CALFUEL(); } void FLIGHT::SHOWINFO() { cout<<"Flight No :"<<Fno<<endl; cout<<"Destination :"<<Destination<<endl; cout<<"Distance :"<<Distance<<endl;; cout<<"Fuel :"<<Fuel<<endl;; } (½ Mark for correct syntax for class header) (½ Mark for correct declarations of data members)
  • 502.
    46 No. Answers Marks (1Mark for appropriate definition of function CALFUEL()) (1 Mark for appropriate definition of FEEDINFO() with a call for CALFUEL()) (1 Mark for appropriate definition of SHOWINFO()) (d) 4 (i) None of data members are accessible from objects belonging to class AUTHOR. (1 Mark for correct answer) (ii) Enter(), Show() (1 Mark for correct answer) (iii) Data members: Voucher_No, Sales_Date, Salary Member function:Sales_Entry(),Sales_Detail(),Enter(),Show(),Register(), Status() (1 Mark for correct answer) (iv) 66 (1 Mark for correct answer) 3. (a) voidAddNSave(intA[ ],int B[ ],int C[ ],int N) 3 { for (int i=0;i<N;i++) C[i]=A[i]+B[i]; } (1 Mark for correct Function Header with appropriate parameters) (1 Mark for appropriate loop) (1 Mark for correct expression for addition of corresponding elements) (b) Given, 3 W=4 N=20 M=30 Loc(P[2][20])=5000
  • 503.
    47 No. Answers Marks ColumnMajor Formula: Loc(P[I][J]) =Base(P)+W*(N*J+I) Loc(P[2][20]) =Base(P)+4*(20*20+2) Base(P) =5000 -4*(400+2) =5000-1608 =3392 (1 Mark for writing correct formula (for column major) OR substituting formula with correct values) (1 Mark for writing calculation step - at least one step) (1 Mark for correct address) (c) struct NODE 3 { float Data; NODE *Link; }; class STACK { NODE *Top; public: STACK(); void Push(); void Pop(); void Display(); ~STACK(); }; void STACK::Push() { NODE *Temp; Temp=new NODE;
  • 504.
    48 No. Answers Marks cin>>Temp->Data; Temp->Link=Top; Top=Temp; } (1Mark for declaring Temp pointer) (1 Mark for creating a new node and assigning/entering appropriate values in it) (1 Mark for connecting link part of new node to top) (1 Mark for assigning Top as the new node i.e. Temp) (d) void MatAdd(int M[][4],int N,int M) 2 { for (int R=0;R<N;R++) { int SumR=0; for (int C=0;C<M;C++) SumR+=M[C][R]; cout<<SumR<<endl; } } ( ½ Mark for correct function header) ( ½ Mark for appropriate outer loop) ( ½ Mark for appropriate inner loop) ( ½ Mark for correctly initializing SumR and calculatin the sum) (e) 2 (½ Mark for correctly evaluating each operator) OR
  • 505.
    49 No. Answers Marks (1Mark for correct answer)
  • 506.
    50 No. Answers Marks 4.(a) File.seekg(0,ios::end); //Statement 1 1 File.tellg(); //Statement 2 (½ Mark for each correct Statement) (b) void CountAlphabet() 2 { ifstream FIL("NOTES.TXT"); int CALPHA=0; char CH=FIL.get(); while (!FIL.eof()) { if (isalpha(CH)) CALPHA++; CH=FIL.get(); } cout<<"No. ofAlphabets:"<<CALPHA<<endl; } (½ Mark for opening NOTES.TXT correctly) (½ Mark for initializing a counter variable as 0) (½ Mark for correctly reading a character from the file) (½ Mark for correctly incrementing the counter) (c) voidAddnew() 3 { fstream FIL; FIL.open("STUDENT.DAT",ios::binary|ios::app); STUD S; char CH; do {
  • 507.
    51 No. Answers Marks S.Enter(); FIL.write((char*)&S,sizeof(S)); cout<<"More(Y/N)?";cin>>CH; } while(CH!='Y'); FIL.close(); } (½ Mark for opening STUDENT.DAT correctly) ( ½ Mark for user input for the new object) (1 Mark for appropriate loop) ( 1 Mark for writing the record on to the binary file) 5. (a) An attribute or set attributes which are used to identify a tuple uniquely is known as 2 Primary Key. If a table has more than one such attributes which identify a tuple uniquely than all such attributes are known as Candidate Keys. (1 Mark for each definition) (b) Write SQL commands for the flowing statements: 4 (i) SELECT GameName,Gcode FROM GAMES; (1 Mark for correct query) OR (½ Mark for partially correct answer) (ii) SELECT * FROM Games WHERE Prizemoney>7000; (1 Mark for correct query) OR (½ Mark for partially correct answer) (iii) SELECT * FROM Games ORDER BY ScheduleDate; (1 Mark for correct query)
  • 508.
    52 No. Answers Marks OR (½Mark for partially correct answer) (iv) SELECT SUM(Prizemoney),Type FROM Games GROUP BY Type; (1 Mark for correct query) OR (½ Mark for partially correct answer) (c) (i) 2 2 (½ Mark for correct output) (ii) 19-Mar-2004 12-Dec-2003 (½ Mark for correct output) (iii) Ravi Sahai Lawn Tennis (½ Mark for correct output) (iv) 3 (½ Mark for correct output) 6. (a) X+X.Y = X 2 L.H.S = X+X.Y = X.1+X.Y = X.(1+Y) = X.1 = X = R.H.S X+X'.Y = X+Y L.H.S. = X+X'.Y
  • 509.
    53 No. Answers Marks =(X+X').(X+Y) = 1.(X+Y) = X+Y = R.H.S (1 Mark for stating any one of the Absorption Law) (1 Mark for verifying the law) (b) F(U,V)=U'.V+U.V' 2 (2 Marks for the final expression ) OR (1 Mark for any one of the correct terms out of U'.V or U.V') (c) F(P,Q,R) = P'.Q'R'+P'.Q'R+P'.Q.R+P.Q'.R 1 (1 Mark for the correct expression ) (d) F(U,V,W,Z)=UV+WZ+UZ 3 ( ½ Mark for placing all 1s at correct positions in K-Map) ( ½ Mark for each grouping) (1 Mark for writing final expression in reduced/minimal form) Note: Deduct ½ mark if wrong variable names are used U’V’ U’V UV UV’ W’Z’ 0 4 8 W’Z 1 8 9 WZ 11 WZ’ 2 6 10 1 12 1 3 1 5 1 14 1 7 1 3
  • 510.
    54 No. Answers Marks 7. a)Bandwidth is referred to the volume of information per unit of time that a transmission 1 medium (like an Internet connection) can handle. OR The amount of data that can be transmitted in a fixed amount of time is known as bandwidth. For digital devices, the bandwidth is usually expressed in bits per second(bps) or bytes per second. For analog devices, the bandwidth is expressed in cycles per second, or Hertz (Hz). ( ½ Mark for writing appropriate definition) ( ½ Mark for giving the unit of bandwidth) b) The first benefit of XML is that because you are writing your own markup language, 1 you are not restricted to a limited set of tags defined by proprietary vendors. Rather than waiting for standards bodies to adopt tag set enhancements (a process which can take quite some time), or for browser companies to adopt each other's standards (yeah right!), with XML, you can create your own set of tags at your own pace. (1 Mark for writing appropriate explanation) c) A firewall is a part of a computer system or network that is designed to block unautho 1 -rized access while permitting authorized communications. It is 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 for writing appropriate explanation) d) AUniform Resource Locator (URL) is used to specify, where an identified resource 1 is available in the network and the mechanism for retrieving it.AURL is also referred to as a Web address. ( 1 Mark for writing appropriate explanation)
  • 511.
    55 No. Answers Marks e)Suggest a cable layout of connections between the buildings. 4 Layout 1: Layout 2: Since the distance between Fazz Building and Jazz Building is quite short (1 Mark for any one of the two suggested layouts) e2) The most suitable place / block to house the server of this organisation would be Raj Building, as this block contains the maximum number of computers, thus decreasing the cabling cost for most of the computers as well as increasing the efficiency of the maximum computers in the network. ( 1 Mark for correct answer with suitable reason) e3) (i) Raj Building (ii) In both the layouts, a hub/switch each would be needed in all the buildings, to interconnect the group of cables from the different computers in each block ( ½ Mark for each correct answer) e4) The type of network that shall be formed to link the sale counters situated in various parts of the same city would be a MAN, because MAN (MetropolitanArea Networks) are the networks that link computer facilities within a city. (1 Mark for correct answer with suitable justification)
  • 512.
    56 No. Answers Marks f)Freeware, the name derived from words "free" and"software". It is a computer soft 1 ware that is available for use at no cost or for an optional fee. Freeware is generally proprietary software available at zero price, and is not free software. The author usu- ally restricts one or more rights to copy, distribute, and make derivative works of the software. Shareware is usually offered as a trial version with certain features only available after the license is purchased, or as a full version, but for a trial period. Once the trial period has passed the program may stop running until a license is purchased. Shareware is often offered without support, updates, or help menus, which only become available with the purchase of a license. The words "free trial" or "trial version" are indicative of shareware. (1 Mark for appropriate difference) g) ATrojan horse is a term used to describe malware that appears, to the user, to per 1 form a desirable function but, in fact, facilitates unauthorized access to the user's computer system A computer worm is a self-replicating computer program. It uses a network to send copies of itself to other nodes (computers on the network) and it may do so without any user intervention. (1 Mark for appropriate difference)