cbse marking scheme 2006 2011
TRANSCRIPT
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) Name the header file to which the following belong 1
(i) abs( ) (ii) isupper( )
(b) Illustrate the use of #define in C++ to define a macro. 2
(c) Rewrite the following program after removing the syntactical error(s), if
any. Underline each correction. 2
#include<iostream.h>
void main( )
{ struct STUDENT
{ char stu_name[20];
char stu_sex;
int stu_age=17;
} student;
gets(stu_name);
gets(stu_sex);
}
(d) Find the output of the following program : 3
#include<iostream.h>
#include<string.h>
class state
{ char *state_name;
int size;
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);
}
void display( ) {cout<<state_name<<endl;}
void Replace (state & a, state & b)
{ size = a.size + b.size;
delete state_name;
state_name = new char[size+l];
strcpy(state_name, a.state_name);
strcat(state_name, b.state_name);
}
};
void main( )
{ 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) Find the output of the following program : 2
#include<iostream.h>
void main( )
{ 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) Define Multilevel and Multiple inheritance in context of Object Oriented Programming.
Give suitable example to illustrate the same. 2
(b) Answer the questions (i) and (ii) after going through the following class :
class Interview
{ int month;
public:
Interview(int y) {month=y;} //Constructor 1
Interview(Interview&t); //Constructor 2
};
(i) Create an object, such that it invokes Constructor 1 1
(ii) Write complete definition for Constructor 2 1
(c) Define a class named ADMISSION in C++ with the following descriptions : 4
Private members :
AD_NO integer (Ranges 10 - 2000)
NAME Array of characters(String)
CLASS Character
FEES Float
Public Members :
• Function Read_Data( ) to read an object of ADMISSION type
• Function Display( ) to display the details of an object
• Function Draw-Nos( ) to choose 2 students randomly.
And display the details. Use random function to generate admission
nos. to match with AD_NO.
(d) Answer the questions (i) to (iii) based on the following code :
class stationary
{
char Type;
char Manufacturer[10];
public:
stationary( );
void Read_sta_details( );
void Disp_sta_details( );
};
class office : public stationary
{
267
int no_of_types;
float cost_of_sta;
public:
void Read_off_details( );
void Disp_off_details( );
};
class printer : private office
{
int no_of_users;
char delivery _date [10];
public:
void Read_pri_details( );
void Disp_pri_details( );
};
void main( )
{ 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 asarguments/parameters and assign the elements into a two dimensional array ofintegers in the following format
If the array is 1, 2, 3, 4, 5, 6 If the array is 1, 2, 3 3
The resultant 2 D array is given The resultant 2 D array is given
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) class queue 4
{ int data[10];
int front, rear;
public:
queue( ) {front = -1; rear=-1;}
voidadd(); // to add an element into the queue
void remove(); // to remove an element from the queue
void Delete(int ITEM); // To delete all elements which are equal
// to ITEM
};
Complete the class with all function definitions for a circular array Queue. Use
another queue to transfer data temporarily
(d) Write a function in C++ to perform Push operation on a dynamically allocated
stack containing real number. 3
(e) Write the equivalent infix expression for
a, b, AND, a, c, AND, OR 2
4. (a) void main()
{ char ch='A';
fstream fileout(“data.dat”,ios::out);
fileout<<ch;
int p = fileout.tellg();
cout<<p;
What is the output if the file content before the execution of the program is the
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
the file. 2
269
(c) Following is the structure of each record in a data file named
“COLONY.DAT”. 3
struct COLONY
{ char Colony_Code[10];
char Colony_Name[10];
int No_of_People;
};
Write a function in C++ to update the file with a new value of No_of_People. The valueof Colony_Code and No_of_People are read during the execution of the program.
5. (a) What is an Alternate 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 10years experience from the table DOCTOR.
(ii) Display the average salary of all doctors working in “ENT” department usingthe tables DOCTOR and SALARY. Salary = BASIC + ALLOWANCE
(iii) Display the minimum ALLOWANCE of female doctors,
(iv) Display the highest consultation fee among all male doctors,
(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) State and verify Distributive Law. 2
(b) Write the equivalent expression for the following Logical Circuit : 2
(c) Express P + Q’R in canonical SOP form. 1
(d) Reduce the following Boolean expression using K-Map.
F(P, Q, R, S) = ÿ (0, 3, 5, 6, 7, 11, 12, 15) 3
7. (a) Differentiate between Internet and Intranet. 1
(b) Expand the following terms
(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
Distance between various wings are given below
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) Suggest a suitable Topology for networking the computer of all wings 1
(ii) Name the wing where the Server to be installed. Justify your answer, 1
(iii) Suggest the placement of Hub/Switch in the network. 1
(iv) Mention an economic technology to provide internet accessibility to all
wings. 1
QUESTION PAPER CODE 91
1. (a) Name the header file to which the following belong : 1
(i) pow()
(ii) random()
(b) Illustrate the use of inline function in C++ with the help of an example. 2
(c) Rewrite the following program after removing the syntactical error(s), if any.
Underline each correction. 2
#include <idstream.h>
void main()
{ struct movie
{ char movie_name[20];
char movie_type;
int ticket_cost = 100;
272
}MOVIE;
gets(movie_name);
gets(movie_type);
}
(d) Find the output of the following program : 3
#include<iostream.h>
#include<string.h>
class student
{ char *name;
int l;
public:
student() { 1=0; name=new char[1+1]; }
student(char *s)
{ 1=strlen(s); name=new char[1+1];
strcpy (name,s);
}
void display() { cout<<name<<endl;}
void manipulate(student & a, student & b)
{ 1=a.1 + b.1;
delete name;
name=new char[l+l];
strcpy(name, a.name);
strcat(name, b.name);
}
};
void main()
{ 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) Find the output of the following program : 2
#include<iostream.h>
void main()
{ 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) Answer the questions (i) and (ii) after going through the following class :
class Exam
{ int year;
public:
Exam(int y) { year=y;} //Constructor 1
Exam(Exam & t); //Constructor 2
};
(i) Create an object, such that it invokes Constructor 1. 1
(ii) Write complete definition for Constructor 2. 1
(c) Define a class named HOUSING in C++ with the following descriptions : 4
Private members
REG_NO integer(Ranges 10 - 1000)
NAME Array of characters(String)
TYPE Character
COST Float
274
Public Members
• Function Read_Data() to read an object of HOUSING type
• Function Display() to display the details of an object
• Function Draw_Nos()to choose and display the details of 2 housesselected randomly from an array of 10 objects of type HOUSING. Userandom function to generate the registration nos. to match with REG_NOfrom the array.
(d) Answer the questions (i) to (iii) based on the following code :
class furniture
{
char Type;
char Model[10];
public:
furniture();
void Read_fur_details();
void Disp_fur_details();
};
class sofa : public furniture
{
int no_of_seats;
float cost_of_sofa;
public:
void Read_sofa_details();
void Disp_sofa_details();
};
class office : private sofa
{
int no_of_pieces;
char delivery_date[10];
public:
void Read_office_details();
void Disp_office_details();
};
void main()
{ office MyFumiture; }
275
(i) Mention the member names which are accessible by MyFumiture declared in
main() function. 1
(ii) What is the size of MyFumiture in bytes ? 1
(iii) Mention the names of functions accessible from the member function
Read_office_details() of class office. 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
following format : 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 elementoccupying 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 stackvoid 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) Write a function in C++ to perform Insert operation in dynamically allocated Queue
containing names of students. 3
(e) Write the equivalent infix expression for 2
10, 3, *, 7, 1, -, *, 23, +
276
4. (a) void main( )
{ char ch='A';
fstream fileout(“ data.dat”, ios::app);
fileout<<ch;
int p=fileout.tellg( );
cout<<p;
}
What is the output if the file content before the execution of the program is the string?
“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];
char Product_Description[10];
int Stock;
};
Write a function in C++ to update the file with a new value of Stock. The Stock andthe 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 SQL commands for thequestions (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 Indian Airlines 6500 10
MU499 Sahara 9400 5
AM501 Jet Airways 13450 8
IC899 Indian Airlines 8300 4
IC302 Indian Airlines 4300 10
IC799 Indian Airlines 10500 10
MC101 Deccan Airlines 3500 4
(i) Display FL_NO and NO_FLIGHTS from “KANPUR” to“BANGALORE” from the table FLIGHTS.
(ii) Arrange the contents of the table FLIGHTS in the ascending order ofFL_NO.
(iii) Display the FL_NO and fare to be paid for the flights from DELHI toMUMBAI using the tables FLIGHTS and FARES, where the fare to bepaid=FARE+FARE*TAX%/100.
(iv) Display the minimum fare “Indian Airlines” is offering from the tableFARES.
(v) SELECT FL_NO, NO_FLIGHTS, AIRLINES from FLIGHTS, FARESwhere STARTING=“DELHI” and FLIGHTS.FL_NO=FARES.FL_NO.
(vi) SELECT count(distinct ENDING) from FLIGHTS.
6. (a) State and verify Associative Law. 2
(b) Write the equivalent expression for the following logical circuit : 2
278
(c) Express P + Q'R in POS form. 1
(d) Reduce the following Boolean expression using K-Map : 3
F(P, Q, R, S) =
π
(0, 3, 5, 6, 7, 11, 12, 15)
7. (a) Name two transmission media for networking. 1
(b) Expand the following terms : 1
(i) XML
(ii) GSM
(iii) SMS
(iv) MAN
(c) Differentiate between Hackers and Crackers.
(d) INDIAN PUBLIC SCHOOL in Darjeeling is setting up the network between itsdifferent wings. There are 4 wings named as SENIOR(S), JUNIOR(J), ADMIN(A)and HOSTELCH).
Distance between various wings are given below :
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 10
Wing S 200
Wing J 100
Wing H 50
(i) Suggest a suitable Topology for networking the computer of all wings. 1
(ii) Name the wing where the Server is to be installed. Justify your answer. 1
(iii) Suggest the placement of Hub/Switch in the network. 1
(iv) Mention an economic technology to provide internet accessibility to all wings. 1
279
Marking Scheme --- Computer Science
General Instruction :
1. The answers given in the marking scheme are merely suggestive;
Examiners are requested to consider all alternative correct answers conveying thesimilar meaning.
2. All programming questions -have to be answered with respect to C++ language only.
3. In SQL related questions - both ways text i.e. character entries should be acceptable.
(For example: ‘Amar’ or “Amar”)
4. In SQL related questions - ignore semicolon / termination for queries.
5. In SQL related questions - ignore case sensitivity.
6. In C++ questions — Ignore case sensitivity for function names and variable names.
QUESTION PAPER CODE 91/1
EXPECTED ANSWERS/VALUE POINTS
1. (a) (i) math.h (ii) ctype.h
( ½ Marks for each correct Header File)
(b) #define is a preprocessor directive that is used to define a symbolic constant.The symbolic constant defined, replaces the word / statement wherever itappears in the program as a macro substitution.
Syntax : #define symbolic_name value
Example: #define Pi 3.14
#define WELCOME cout<<”Hello World !\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 withoutrectification)
Note: If student replaces gets by cin>> or cin.getline( )and does notmention <stdio.h> then full marks to be given if other errors arecorrected.
(d) DelhiMumbai
DelhiMumbaiNagpur
(3 full marks for identifying error in definition of the constructorstate() 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 (assuming R as Rem)
(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 least1 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 “NestedLoops”, but not exposed specifically to the concept of “Nested structures”.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 least1 mark in the entire Q. No. 1 i.e. from 1(a) to 1(f))
281
2. (a) In Multilevel inheritance, a class inherits it’s properties from another derivedclass transitively.
In Multiple inheritance , a derived class inherits from multiple base classes.
(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 helpof 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 ofInterview 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 nameand 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];
}
ORAny 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) For Column wise allocationAddress of A[I][J] = BA + W[ (J –LBC) x M + (I - LBR)]WhereBA = Base Address
W = Size of each element in bytes = 8 bytes (given)M = No. of rows in the 2D Array = 30 (given)Address of MAT[5][7] given is 1000.
Assumption 1 : LBR=LBC=0Therefore
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=1Therefore
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 sustitutionof 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 ;
elserear = (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 –1initial 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;
else if(front==9)
front=0;
else
front=front+1;
cout<<”\nDeleted item is : “<<item;
}
}
OR
Any other equivalent code
(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 voidDelete(int ITEM) , thus the benefit of doubt is given to the studentand 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 Infix Expressionscanned
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 (a AND b OR a AND c
a AND b OR a AND c
Ans: a AND 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 studentsare 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 outmode as the students generally associate tellg( ) with only ios::inmode)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
Any other equivalent code
(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
Any other equivalent code
( ½ 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 asAlternate key(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) Distributive Laws are :
(a) A (B + C) = A B + A C
(b) A + (B C) = (A + B) (A + C)
293
Verification of first distributive law using truth table:
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
Comparing Column Numbers 5 and 8, Distributive law is verified.
(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-wideusing a common set of communications protocols.
Intranet is an inter-connected network within one organization that uses Webtechnologies for the sharing of information internally.
(Full 1 Mark for correctly defining internet only as Intranet is notdirectly specified in the syllabus)
(b) (i) Code Divison Multiple Access
(ii) Uniform Resource Locator (Location) / Universal Resource Locator (Location)
(iii) Hype Text Transfer (Transmission) Protocol
(iv) Wide Area Network
( ½ mark for each term)
(c) Fault detection is easy.
Fault isolation is easy.
OR
Any other valid advantage.
(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) Wing A, because maximum number of computers are located at Wing A.(1 mark for the correct answer)OR( ½ mark if only Wing A is mentioned without justification)
(ii) Hub/Switch in all the wings.ORCorrect diagram depicting placement of Hub/Switch in all the wings.
(1 mark for correct placement)
(iv) Coaxial cable / Modem / LAN / TCP-IP / Dialup/ DSL/ Leased LineOR any other valid technology (any one).
Note: Optical fiber, Satellite link and Microwave NOT to beconsidered as valid answers.
(1 Mark for any valid technology)
QUESTION PAPER CODE 91
EXPECTED ANSWERS/VALUE POINTS
1. (a) (i) math.h / complex.h (ii) stdlib.h
(1/2 Marks for each correct Header File)
(b) —
Note: As the term inline function is not mentioned in the curriculum, benefit ofdoubt should be given to the students.
(Full 2 marks to be awarded to the students who have scored at least1 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) JackJillJackJillJohn
(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 asinsertion operator << expected in between First and Second)
297
(f) A constructor 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.
Destructor is used to destroy the objects and deallocate the memory resources
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 fordestructor)
2. (a) Students are exposed to the concept of pointers, but not exposed specifically
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 attemptedfor 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 ofConstructor 2)
OR
(1 mark for any valid statement in C++ working with t as anobject of Exam)
OR
(1 mark for writing the definition/explanation of the concept ofcopy 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 nameand 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 datamembers OR declaring a local object and entering the values of datamembers of this object )
(1 mark for proper definition of Display())
Note: As language of Third part of this question has ambiguity, it isrequired to be ignored. Moreover, if anyone has partially attemptedthe third part (i.e., Draw_nos function) and not attempted/not correctlyattempted Read/Display function, he/she should be given 2 Marksfor Third part taking into consideration the marks for this questionshould not exceed the max. marks allocated (i.e. 4 marks) to thisquestion 2 (c).
299
(d) (i) Read_office_detailsDisp_office_details.(1 mark for correct names)
(ii) 29 bytesOR33 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) For Row wise allocationAddress of A[I][J] = BA + W( (I-LBR) x N + (J-LBC))WhereBA = Base AddressW = Size of each element in bytes = 4 bytes (given)N = No. of columns in the 2D Array = 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 + 148BA = 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
[Push Operation]
(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)
[Pop Operation]
(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 fromthe stack)
Note: As language of Third part of this question has ambiguity withrespect to Stack Operation, it is required to be ignored. Moreover, ifanyone has partially attempted the third part (i.e. Delete function)and not attempted/not correctly attempted Push/Pop should be given2 Marks for Third part taking into consideration the marks for thisquestion 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 thevalue for Name)(1 mark for creating a Link with the previous Node)(1 mark for assigning new value of Rear.)
Note:
1. Ignore the struct and class implementation while awarding marksin this question
2. Equivalent code with Dynamic Array should also be consideredas correct solution
(e) 10*3*(7-1)+23
(Full 2 marks to be given to students who have correctly attemptedfor at least 1 mark in the entire Q. No. 3 (a) to 3 (e))
Note: As students are exposed to Conversion from INFIX to POSTFIXand Evaluation of POSTFIX only, he/she may not be able tocomprehend 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 forend 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);//ORout.seekp(-sizeof(P1),ios::cur);out.write((char*)&P1, sizeof(P1);
}}if (flag==0) cout<<”Product Code does not match”;//ORif (!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 forproduct code and stock)(1/2 Marks for correct loop, check of end of file and reading of anobject from the file)(1/2 Mark for correct comparison)(1/2 Mark for identifying and moving the file pointer to the correctposition)(1/2 Mark writing the modified/updated data on right position in thefile)
304
5. (a) DDL – Data Definition Language
DML – Data Manipulation Language
(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 Indian Airlines
AM501 1 Jet Airways
IC701 4 Indian Airlines
(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
RSPQ
0
4
12
8
1
5
13
9
7
15
11
3
6
14
16
2
Single II Pair II
Quad I
Pair I
Single I
RSPQ
0
4
12
8
1
5
13
9
7
15
11
3
6
14
16
2
Single I 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) Optical Fiber
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 Extensible Markup Language
(ii) GSM Global System for Mobile communication {ignore communication}
(iii) SMS Short Messaging Service {Message/Messaging both acceptable}
(iv) MAN Metropolitan Area Network
(1/2 Mark for each correct answer)
(No marks for partially correct answers)
(c) Hackers: Computer enthusiasts who enjoy learning about computer systemsand get into other system/network for gaining more knowledge or may findflaws in the system for rectification purposes.
Crackers: Malicious programmers who break into secure systems for stealingand corrupting/spoiling data.
(1/2 Mark for definition of each Hacker and Cracker)
OR
(Full 1 Mark for mentioning the difference)
308
(d) (i) Star Topology
OR
Bus Topology
(1 Mark for mentioning any one of the two topologies)
OR
(1 Mark for diagramatic representation of any of the above mentioned topologies)
(ii) Wing S
as it has the maximum number of computers
OR
Wing A
as it is placed in the Admin Wing (for security reasons)
(1/2 Mark for identification of the correct Wing)
(1/2 Mark for correct justification)
(iii) Inside all the four wings
(1 Mark for the correct answer)
(iv) Any one of the following:
Dialup, TCP/IP, DSL, Modem, Broadband, Cable, ISDN, Telephone
Line, Co-axial, Ethernet Cable, 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) Differentiate between a Logical Error and Syntax Error. Also give suitableexamples of each in C++. 2
(b) Name the header file(s) that shall be needed for successful compilation ofthe following C++ code : 1
void main( )
{
char Text[40];
strcpy(Text,”AISSCE”);
puts(Text);
}
(c) Rewrite the following program after removing the syntactical error(s),if any. Underline each correction. 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) Find the output of the following program : 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) Find the output of the following program : 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 fromOptions (i) to (iv) given below. Justify your answer. 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 incontext of Inheritance using C++. 2
(b) Answer the questions (i) and (ii) after going through the following class: 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) Name the specific features of class shown by Function 1 and Function2 in the above example.
(ii) How would Function 1 and Function 2 get executed ?
264
(c) Define a class Travel in C++ with the description given below : 4
Private Members :
T_Code of type string
No_of_Adults of type integer
No_of_Children of type integer
Distance of type integer
TotalFare of type float
Public Members :
• A constructor to assign initial values as follows :
T_Code with the word “NULL”
No_of_Adults as 0
No_of_Children as 0
Distance as 0
TotalFare as 0
• A function AssignFare( ) which calculates and assigns the valueof the data member TotalFare 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 inthe above table.
For example :
If Distance is 750, No_of_Adults = 3 and No_of_Children = 2
Then TotalFare should be calculated as
No_of_Adults * 300 + No_of_Children * 150
i.e. 3 * 300 + 2 * 150 = 1200
• A function EnterTraveK ) to input the values of the data membersT_Code, No_of_Adults, No_of_Children and Distance; andinvoke the AssignFare( ) function.
• A function ShowTraveK) which displays the content of all thedata members for a Travel.
(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) Identify the member functiion(s) that cannot be called directly from theobjects of class School from the following :
TEntry( )
SDisplay( )
SchEntry( )
(iii) Write name of all the member(s) accessible from member functions ofclass School.
(iv) If class School was derived privately from class Teacher and privatelyfrom class Student, then, name the member function(s) that could beaccessed through Objects of class School.
266
3. (a) Write a function in C++ which accepts an integer array and its size.asarguments and replaces elements having even values with its half and elementshaving odd values with twice its value. 4
Example : if an array of five elements initially contains the elements as3, 4, 5, 16, 9
then the function should rearrange the content of the array as6, 2, 10, 8, 18
(b) An array Arr[15][20] is stored in the memory along the row with each elementoccupying 4 bytes. Find out the Base Address and address of the elementArr[3][2], if the element Arr[5][2] is stored at the address 1500. 4
(c) Write a function in C++ to delete a node containing customer’s information,from a dynamically allocated Queue of Customers implemented withthe help of the following structure : 4
struct Customer
{
int CNo;
char CName[20];
Customer *Link;
};
(d) Write a function in C++ which accepts a 2D array of integers and its sizeas arguments and displays the elements of middle row and the elements ofmiddle column. 2[Assuming the 2D Array to be a square matrix with odd dimensioni.e. 3×3, 5×5, 7×7 etc...]Example, if the array content is3 5 47 6 92 1 8Output through the function should be :Middle Row : 7 6 9Middle Column : 5 6 1
(e) Evaluate the following postfix notation of expression : 215 3 2 + / 7 + 2 *
4. (a) Observe the program segment given below carefully, and answer the questionthat follows : 1class 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 ();
}
If the funption ModifyMarks() is supposed to modify Marks for the recordsin the file MARKS.DAT based on their status of the member Checked(containing value either V or ‘N’). Write C++ statements for the statement1 and statement 2, where, statement 1 is required to position the file writepointer to an appropriate place in the file and statement 2 is to perform thewrite operation with the modified record.
(b) Write a function in C++ to print the count of the word the as an independentword inatextfileSTORY.TXT. 2
For example, if the content of the file STORY.TXT is
There was a monkey in the zoo. The
monkey was very naughty.
Then the output of the program should be 2.
268
(c) Given a binary file SPORTS.DAT, containing records of the followingstructure type :
struct Sports
{
char Event[20];
char Participant[10][30];
};
Write a function in C++ that would read contents from the file SPORTS.DATand creates a file named ATHLETIC.DAT copying only those records fromSPORTS.DAT where the event name is “Athletics”. 3
5. (a) What is the importance of a Primary Key in a table ? Explain with a suitableexample. 2
(b) Consider the following tables Consignor and Consignee. Write SQLcommands for the statements (i) to (iv) and give outputs for SQL queries (v)to (viii). 6
TABLE : CONSIGNOR
CnorlD CnorName CnorAddress City
ND01 R Singhal 24, ABC Enclave New Delhi
ND02 Amit Kumar 123, Palm Avenue New Delhi
MU15 R Kohli 5/A, South Street Mumbai
MU50 S Kaur 27-K, Westend Mumbai
TABLE : CONSIGNEE
CneelD CnorlD CneeName CneeAddress CneeCity
MU05 ND01 Rahul Kishore 5, Park Avenue Mumbai
ND08 ND02 P Dhingra 16/J, Moore Enclave New Delhi
KO19 MU15 A P Roy 2A, Central Avenue Kolkata
MU32 ND02 S Mittal P 245, AB Colony Mumbai
ND48 MU50 B P Jain 13, Block D, A Vihar New Delhi
(i) To display the names of all Consignors from Mumbai.’
(ii) To display the CneelD, CnorName, CnorAddress, CneeName,CneeAddress for every Consignee.
(iii) To display consignee details in ascending order of CneeName.
(iv) To display number of consignors from each city,
269
(v) SELECT DISTINCT City FROM CONSIGNEE;
(vi) SELECT A.CnorName, B.CneeName
FROM Consignor A, Consignee B
WHERE A.CnorID = B.CnorlD AND B.CneeCity = ‘Mumbai’;
(vii) SELECT CneeName, CneeAddress
FROM Consignee
WHERE CneeCity NOT IN (‘Mumbai’, ‘Kolkata’);
(viii) SELECT CneelD, CneeName
FROM Consignee
WHERE CnorID=’MU15' OR CnorID=’ND01';
6. (a) State De Morgan’s Theorems and verify the same using truth table. 2
(b) Write the equivalent Canonical Product of Sum Expression for the followingSum of Product Expression
F(X, Y, Z) = Σ (0, 2, 4, 5) 2
(c) Write the equivalent Boolean expression for the following Logic Circuit. 2
(d) Reduce the following Boolean expression using K-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) Expand the following terms with respect to Networking : 2(i) XML(ii) WWW(iii) WLL(iv) TCP/IP
270
(c) Which of the following units measures the speed with which data can betransmitted from one node to another node of a network ? Also, give theexpansion of the suggested unit. 1
(i) KMph
(ii) Mbps
(iii) MGps
(d) “Hindustan Connecting World Association” is planning to start their offices infour major cities in India to provide regional IT infrastructure support in thefield of Education & Culture. The company has planned to set up their headoffice in New Delhi in three locations and have named their New Delhi officesas “Sales Office”, ”Head Office” and “Tech Office”. The company’s regionaloffices are located at ”Coimbatore”, “Kolkata” and “Ahmedabad”.A rough layout of the same is as follows :
Approximate distances between these offices as per network survey teamis as follows :
Place From Place To Distance
Head Office Sales Office 10 KM
Head Office Tech Office 70 Meter
Head Office Kolkata Office 1291 KM
Head Office Ahmedabad Office 790 KM
Head Office Coimbatore Office 1952 KM
271
In continuation of the above, the company experts have planned to installthe following number of computers in each of their offices :
Head Office 100
Sales Office 20
Tech Office 50
Kolkata Office 50
Ahmedabad Office 50
Coimbatore Office 50
(i) Suggest network type (out of LAN, MAN, WAN) for connecting eachof the following set of their offices :• Head Office and Tech Office• Head Office and Coimbatore Office
(ii) Which device will you suggest to be procured by the company forconnecting all the computers within each of, their offices out of thefollowing devices ?• Modem• Telephone• Switch/Hub
(iii) W hich of the following communication media, will you suggest to beprocured by the company for connecting their local offices in NewDelhi for very effective and fast communication ?• Ethernet Cable• Optical Fiber• Telephone Cable
(iv) Suggest a cable/wiring layout for connecting the company’s local officeslocated in New Delhi. Also,, suggest an effective method/technologyfor connecting the company’s regional offices at “Kolkata”,“Coimbatore” and “Ahmedabad”. 4
QUESTION PAPER CODE 91/1
1. (a) Differentiate between a Run Time Error and Syntax Error. Also give suitableexamples of each in C++. 2
(b) Name the header file(s) that shall be needed for successful compilation of thefollowing C++ code 1void main ( ){
char String [20];gets (String);strcat (String, “CBSE”);puts (String);
}
272
(c) Rewrite the following program after removing the syntactical error(s) if any.Underline each correction. 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) Find the output of the following program : 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) Find the output of the following program : 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) In the following C++ program what is the expected value of MyMarks fromOptions (i) to (iv) given below. Justify answer. 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) Differentiate between Constructor and Destructor function in context ofClasses and Objects using C++ 2
(b) Answer the questions (i) and (ii) after going through the following class 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) Name the specific features of class shown by Member Function 1 andMember Function 2 in the above example.
(ii) How would Member Function 1 and Member Function 2 get executed?
(c) Define a class Tour in C++ with the description given below : 3
Private Members :
TCode of type string
NoofAdults of type integer
NoofKids of type integer
Kilometres of type integer
TotalFare of type float
Public Members :
• A constructor to assign initial values as follows :
TCode with the word “NULL”
NoofAdults as 0
NoofKids as 0
Kilometres as 0
TotalFare as 0
• A function AssignFare ( ) which calculates and assigns the value ofthe data member TotalFare as follows
For each Adult
Fare(Rs) For Kilometres
500 >=1000
300 <1000&>=500
200 <500
For each Kid the above Fare will be 50% of the Fare mentioned in theabove tableFor example :
If Kilometres is 850, NoofAdults = 2 and NoofKids = 3
Then TotalFare 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 membersTCode, NoofAdults, NoofKids and Kilometres; and invoke theAssign Fare( ) function.
• A function ShowTour( ) which displays the content of all the datamembers for a Tour.
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) Identify the member function(s) that cannot be called directly from theobjects of class Institute from the following
TEntry( )
LDisplay()
IEntry()
276
(iii) Write name of all the member(s) accessible from member functions ofclass Institute.
(iv) If class Institute was derived privately from class Learner and privatelyfrom class Trainer, then, name the member function(s) that could beaccessed through Objects of class Institute.
3. (a) Write a function in C++ which accepts an integer array and its size asarguments and replaces elements having odd values with thrice its value andelements having even values with twice its value.
Example : if an array of five elements initially contains the elements as
3, 4, 5, 16, 9
then the function should rearrange the content of the array as
9, 8, 15, 32, 27 4
(b) An array Array[20][15] is stored in the memory along the column with eachelement occupying 8 bytes. Find out the Base Address and address of theelement Array[2][3] if the element Array [4] [5] is stored at the address1000. 4
(c) Write a function in C++ to delete a node containing Book’s information,from a dynamically allocated Stack of Books implemented with the help ofthe following structure. 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 asarguments and displays the elements which lie on diagonals. 2
[Assuming the 2D Array to be a square matrix with odd dimension
i.e. 3×3, 5×5, 7×7 etc.]
Example, if the array content is
5 4 3
6 7 8
1 2 9
Output through the function should be :
Diagonal One : 5 7 9
Diagonal Two : 3 7 1
277
(e) Evaluate the following postfix notation of expression : 2
25 8 3 - / 6 * 10 +
4. (a) Observe the program segment given below carefully, and answer the question
that follows: 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 2Record + + ;}File.close();
}
If the function AllocateMarks () is supposed to Allocate Marks for the recordsin 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 appropriateplace in the file and statement 2 is to perform the write operation with themodified record.
278
(b) Write afunction in C++ to print the count of the word is as anindependent word in at text file DIALOGUE.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) Given a binary file GAME.DAT, containing records of the following structuretype 3
struct Game
{
char GameName [20];
char Participant [10] [30];
};
Write a function in C++ that would read contents from the file GAME.DATand creates a file named BASKET.DAT copying only those records fromGAME.DAT where the game name is “Basket Ball”
5. (a) Differentiate between primary key and alternate key. 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 R Jain 2, ABC Appts New Delhi
MU02 H Sinha 12, Newtown Mumbai
MU15 S Jha 27/A, Park Street Mumbai
ND50 T Prasad 122-K, SDA New Delhi
TABLE : RECIPIENT
RecID SenderlD RecName RecAddress RecCiry
KO05 ND01 R Bajpayee 5, Central Avenue Kolkata
ND08 MU02 S Mahajan 116, A Vihar New Delhi
MU19 ND01 H Singh 2A, Andheri East Mumbai
MU32 MU15 P K Swamy B5, C S Terminus Mumbai
ND48 ND50 S Tripathi 13, B1 D, Mayur Vihar New Delhi
279
(i) To display the names of all Senders from Mumbai
(ii) To display the RecID), SenderName, SenderAddress, RecName,RecAddress for every Recipient
(iii) To display Recipient details in ascending order of RecName
(iv) To display number of Recipients from each city
(v) SELECT DISTINCT SenderCity FROM Sender;
(vi) SELECT A. SenderName, B.RecName
FROM Sender A, Recipient B
WHERE A. SenderlD = B.SenderlD AND B.RecCity = ‘Mumbai’;
(vii) SELECT RecName, RecAddress
FROM Recipient
WHERE RecCity NOT IN (‘Mumbai’, ‘Kolkata’);
(viii) SELECT RecID, RecName
FROM Recipient
WHERE SenderID=’MU02' ORSenderID=’ND50';
6. (a) State Distributive law and verify the same using truth table. 2
(b) Write the equivalent Canonical Sum of Product expression for the followingProduct of Sum Expression 2
F(X,Y,Z) = π (1,3,6,7)
(c) Write the equivalent Boolean Expression for the following Logic Circuit. 2
(d) Reduce the following Boolean expression using K-Map 2
F(U,V,W,Z) = Σ (0, 1, 2, 3, 4, 10, 11)
7. (a) What is the significance of Cyber law ? 1
(b) Expand the following terms with respect to Networking : 2
(i) CDMA (iii) FTP
(ii) WLL (iv) HTML
280
(c) Which of the following unit measures the speed with which data can betransmitted from one node to another node of a network? Also, give theexpansion of the suggested unit. 1
(i) Mbps
(ii) KMph
(iii) MGps
(d) “Bhartiya Connectivity Association” is planning to spread their offices in fourmajor cities in India to provide regional IT infrastructure support in the fieldof Education & Culture. The company has planned to setup their head officein New Delhi in three locations and have named their New Delhi offices as“Front Office”, “Back Office” and “Work Office”. The company has threemore regional offices as “South Office”, “East Office” and “West Office”located in other three major cities of India. A rough layout of the same is asfollows : 4
Approximate distances between these offices as per network survey team isas follows:
Place From Place To Distance
BackOffice Front Office 10KM
Back Office Work Office 70 Meter
Back Office East Office 1291 KM
BackOffice West Office 790 KM
Back Office South Office 1952 KM
281
In continuation of the above, the company experts have planned to install thefollowing number of computers in each of their offices :
Back Office 100
Front Office 20
Work Office 50
East Office 50
West Office 50
South Office 50
(i) Suggest network type (out of LAN, MAN, WAN) for connecting eachof the following set of their offices :
• Back Office and Work Office
• Back Office and South Office
(ii) Which device you will suggest to be procured by the company forconnecting all the computers with in each of their offices out of thefollowing devices?
• Switch/Hub
• Modem
• Telephone
(iii) Which of the following communication medium, you will suggest to beprocured by the company for connecting their local offices in NewDelhi for very effective and fast communication?
• Telephone Cable
• Optical Fiber
• Ethernet Cable
(iv) Suggest a cable/wiring layout for connecting the company’s local officeslocated in New Delhi. Also, suggest an effective method/technologyfor connecting the company’s regional offices-”East Office”, “WestOffice” and “South Office” with offices located in New Delhi.
282
Marking Scheme — Computer Science
Important Note
� The answers given in the marking scheme are SUGGESTIVE. Examiners are requested toaward marks for all alternative correct Solutions/Answers conveying the similar meaning
� All programming questions have to be answered with respect to C++ Language only
� In C++, ignore case sensitivity for identifiers (Variable/Functions/Structures/Class Names)
� In SQL related questions – both ways of text/character entries should be acceptable for Example:“AMAR” and ‘amar’ both are correct.
� In SQL related questions – semicolon should be ignored for terminating the SQL statements InSQL related questions, ignore case sensitivity.
QUESTION PAPER CODE 91
EXPECTED ANSWERS/VALUE POINTS
1. (a) Logical Error:Error occurred due to incorrect logic applied by the programmer.
Syntax Error:Error occurred due to not following the proper grammar/syntax of the languageORError occurred due to violating rules of the programming language
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 SyntaxError)(½ Mark for each correct example of Logical Error and Syntax Error)OR(Full 2 Marks for correct examples demonstrating the differencebetween Logical Error and Syntax Error)Note: Only 1 Mark to be awarded if Explanation is given withoutsupporting 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 ismentioned
(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 suggestingcorrection)
(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 studentspecifying Variable C not declared OR mentioning that theprogram will not RUN due to incorrect syntax should beawarded 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 ofoutput
· ½ 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 Access Specifier Derived Class
Protected Private Private
Protected Protected
Public Protected
Private Private Not Accessible
Protected Not Accessible
Public Not Accessible
(1 mark each for correct explanation of Private and Protectedmembers)
Note: If the contents of the above table is explained correctly in anyformat (with or without example) full 2 marks are to be awarded.
(b) (i) Function 1: Constructor/ Default Constructor
Function 2: Destructor
(½ Marks for each correct answer)
(ii) Function 1 is executed or invoked automatically when an object ofclass Science is created.
Function 2 is invoked automatically when the scope of an object ofclass Science comes to an end.
OR
Example:
{
Science s1;//Constructor is invoked
} // the destructor is invoked
(½ Mark for each correct answer through explanation ORexample)
(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 calculatingTotalFare in AssignFare( ))(½ Mark for correct EnterTravel( ) with proper invocation ofAssignFare( ))(½ Mark for displaying all data Members including TotalFareinside ShowTravel( ))
286
(d) (i) Multiple Inheritance
(1 Mark for correct answer)
(ii) NoneORAll the functions can be called.
(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;
elseNUM[i]=2*NUM[i];
}}
ORvoid 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
ORAssuming 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, forrow major properly, for calculating Base Address)(1 Mark for calculating correct Base Address)(1 Mark for writing correct formula/correct substituted values, forrow 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 Underflow\n”;
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;
}
}
ORvoid DELETE(Customer *&Front,Customer *&Rear){
if(!Front)cout<<”\n Queue Underflow\n”;
else{
Customer *Temp;Temp=Front;cout<<Front->Cno<<”:”<<Front->Cname
<<”Deleted”<<endl;//To be ignoredFront=Front->Link;delete Temp;if (Front==NULL)
Rear=NULL; }}
Note: If Front and Rear are declared as Global variables thenparameters are not needed in the above function.(½ Mark for correct function header)(½ Mark for declaring Front and Rear as members OR passing themas 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
Any other correct equivalent function definition
(½ Mark for correct function header)(½ Mark for correct loop)(½ Mark for checking/printing middle row elements)(½ Mark for checking/printing middle column elements)
(e) Evaluation of the given postfix expression is explained below
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
Any other method of evaluating the postfix expression is shown.
(½ Mark for each operation correctly evaluated)(Only 1 Mark is to be awarded if correct answer is given withoutsteps)
290
4. (a) Statement 1:File.seekg(-1*sizeof(L),ios::cur);
ORFile.seekg(Rec*sizeof(L));
ORFile.seekp(-1*sizeof(L),ios::cur);
ORFile.seekp(Rec*sizeof(L));
ORAny equivalent correct method of calculating size of the record in place ofsizeof operator.
Statement 2:File.write((char *) &L,sizeof(L));
ORAny equivalent correct method of calculating size of the record in place ofsizeof operator.(½ Mark for each correct statement)
(b) //Function to count the word in STORY.TXT filevoid 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();
}ORvoid 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
ORvoid 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();
}
ORvoid 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/record uniquely.
Example:Rollnumber in the table STUDENTOR
293
AccessionNumber in the table LIBRARYOREmpNumber in the table EMPLOYEEORPanNumber in the table INCOMETAXORMemberNumber in the table MEMBERORAccNumber in the table BANKORAny other suitable example
(1 Mark for correct definition/explanation of Primary Key)(1 Mark for suitable example)
(b) (i) S E L E C T C n o r N a m e F R O M C O N S I G N O R W H E R ECity=’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;
ORSELECT 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 GroupBy City;
ORSELECT City,Count(*) FROM CONSIGNOR Group ByCity;
(½ 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 tableCONSIGNEE)
(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 ifpart (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’sTheorem 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 00 4 12 8
C+D' 0 0 01 5 13 9
C'+D' 0 0 13 7 15 11
C'+D 0 0 12 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 reducingto the correct minimal form)
7. (a) Cyber law encompasses a wide variety of political and legal issues relatedto the Internet and other communications technology, including intellectualproperty, privacy, freedom of expression, and jurisdiction.ORRestricting unauthorized access to user accounts. Promoting, coordinatingand controlling e-business.(1 Mark for any correct definition/explanation)
(b) (i) XML eXtensible MarkUp Language(ii) WWW World Wide Web(iii) WLL Wireless in Local Loop(iv) TCP/IP Transmission Control Protocol/Internet Protocol(½ Mark for each correct expansion)
(c) (ii) MbpsMega bits per second
(½ Mark for correct identification)(½ Mark for correct expansion)
(d) (i) · Head Office and Tech 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) · Optical fiber
(1 Mark for the correct device)
297
(iv) Optical Fiber/Star TopologyWireless
OR
Optical Fiber/Bus Topology
Wireless
(½ Mark for the correct layout)
(½ Mark for the any equivalent correct technology)
QUESTION PAPER CODE 91/1
EXPECTED ANSWERS/VALUE POINTS
1. (a) Run Time Error : Error occurring in a program during its execution. Programexecution halts when such an error is encountered.
Example:
int A,B,C;
cin>>A>>B;
C=A/B;//Runtime error if value of B is zero.
Syntax Error: Error occurred due to wrong syntax of language detected bythe compiler during compilation.
Example:
cout>>”A C++ Program”;
298
(½ Mark for each correct explanation of Runtime Error and SyntaxError)
(½ Mark for each correct example of Runtime Error and Syntax Error)
OR
(Full 2 Marks for correct examples demonstrating the differencebetween Runtime Error and Syntax Error)
OR
(Only 1 Mark to be awarded if Explanation with out supportingexamples)
(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 suggestingcorrection)
(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 studentspecifying Variable I not declared OR mentioning that theprogram will not RUN due to incorrect syntax should beawarded 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.
· Constructor functions are called automatically at the time of creation ofthe object
· Constructors can be overloaded
· Constructor functions are defined in public.
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 theobject gets over
· Destructor can not be overloaded
· Destructor function is defined in public.
(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) Function 1: Constructor OR Default Constructor
Function 2: Destructor
(½ Marks for each correct answer)
(ii) Function 1 is executed or invoked automatically when an object ofclass Maths is created.
Function 2 is invoked automatically when the scope of an object ofclass Maths comes to an end.
300
OR
Example:{
Maths s1; //Constructor is invoked
} //Destructor is invoked
(½ Mark for each correct answer through explanation ORexample)NOTE: If the error in declaration of the destructor is specifiedthen 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 ofAssignFare())
(½ Mark for displaying all data Members including TotalFare insideShowTour())
(d) (i) Multiple Inheritance
(1 Mark for correct answer)
(ii) None
OR
All the above functions can be called.
(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) Address of Array[i][j] along the column =
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 of Array[4][5] = Base Address + 8 [ (4 – 0) +(5 – 0) * 20]
1000 = Base Address + 8 [104]
Base Address = 1000 – 8 x 104
= 1000 – 832
= 168
Address of Array[2][3] = 168 + 8 [ (2 – 0) + (3 – 0) x 20]
= 168 + 8 x 62
= 168 + 496
= 664
OR
303
Address of Array[i][j] along the column =
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 of Array[4][5] = Base Address + 8 [ (4 – 1) +(5 –1) * 20]
1000 = Base Address + 8 [83]
Base Address = 1000 – 8 x 83
= 1000 – 664
= 336
Address of Array[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 forcalculating Base Address)(1 Mark for calculating correct Base Address)(1 Mark for writing correct formula/ correct substituted values forcalculating 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”;
}
ORvoid 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
Any other correct equivalent function definition
(½ 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
Any other method of correctly evaluating the postfix expression is shown.
(2 Marks is to be given for correct answer)
OR
(½ Mark for each operation correctly evaluated)
306
4. (a) Statement 1:
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 ofsizeof operator.
Statement 2:
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 ofsizeof operator.
(½ 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
ORvoid 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
Any other correct definition
(½ 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(); //ignorefout.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) All candidate keys, which are not the primary key of the table are called thealternate keys.
OR
Primary Key: An attribute/ column used to identify each record in a table
Alternate Key: All such attributes/columns, which can act as a primary keybut are not the primary key in a table.
(2 Mark for any valid difference/relation between Primary Key andAlternate 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 RecNameND08 S MahajanND48 S Tripathi
(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) isanswered correctly.
6. (a) If X,Y,Z are Boolean Variables 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 10 4 12 8
W'Z 11 5 13 9
WZ 1 13 7 15 11
WZ' 1 12 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) Cyber law encompasses a wide variety of political and legal issues related tothe Internet and other communications technology, including intellectualproperty, privacy, freedom of expression, and jurisdiction.
OR
Cyber law helps prevent Cyber Crime, Hacking, Data theft, Software Piracyand protects rights of Cyber Users.
(1 Mark for any correct significance / explanation)
W.X’
Y'.Z
W.X’+Y'.Z
311
(b) (i) Code Division Multiple Access
(ii) Wireless Local Loop
(iii) File Transfer Protocol
(iv) Hyper Text Markup Language
(½ 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 – LANBack Office and South Office – WAN(½ Mark for each correct answer)
(ii) Switch/Hub(1 Mark for correct answer)
(iii) Optical Fiber(1 Mark for correct answer)
(iv)
OR
Any other suitable layout / topology drawn or explained.
Optical Fiber/Star Topology
OR
Optical Fiber/Bus Topology
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) What is the difference between #define and const? Explain with suitable 2
example.
(b) Name the header files that shall be needed for the following code 1
void main ( )
{
char String [ ] = “Peace”;
cout<<setw (20) << String;
}
(c) Rewrite the following program after removing the syntactical error(s) if
any. Underline each correction. 2
#include < iostream.h >
void main ( )
{
First = 10, Second = 20;
Jumpto (First; Second);
Jumpto (Second);
}
void Jumpto (int N1, int N2=20)
{
N1 = N1 + N2;
cout<<N1>>N2;
}
(d) Find the output of the following program: 3
#include<iostream.h>
#include<ctype.h>
309
void main ( )
{
char Text [ ] = “Mind@Work!”;
for (int I = 0; Text (I)! = ‘\0’; 1++)
{
if (!isalpha (Text[I]))
Text [I] = ‘*’;
else if (isupper (Text[I]))
Text [I] = Text [I] + 1 ;
else
Text (I) = Text [I+ 1];
}
cout<<Text;
}
(e) Find the output of the following program: 2
#include<iostream.h>
void main ( )
{
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) In the following program, find the correct possible output(s) from the options: 2
#include<stdlib.h>
#include<iostream.h>
void main ( )
{
randomize ( ) ;
char City [ ] [10] = {“DEL”, “CHN”, “KOL”, “BOM”, “BNG”};
int Fly;
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
Object Oriented Programming using a suitable example illustrating each. 2
(b) Answer the questions (i) and (ii) after going through the following
program 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
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) Define a class Garments in C++ with the following descriptions: 4
Private Members:
GCode of type string
GType of type string
GSize of type integer
GFabric of type string
GPrice of type float
A function 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%.
Public Members:
A constructor to assign initial values of GCode, GType and GFabric
with the word “NOT ALLOTTED” and GSize and GPrice with 0
A function Input ( ) to input the values of the data members GCode,
GType, GSize and GFabric and invoke the Assign ( ) function.
A function Display ( ) which displays the content of all the data members
for a Garment.
(d) Answer the questions (i) to (iv) based on the following code: 4
class Dolls
{
char DCode[5] ;
protected:
float Price;
312
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 ( ) ;
} ;
(i) Which type of Inheritance is shown in the above example?
(ii) How many bytes will be required by an object of the class
ElectronicDolls? .
(iii) Write name of all the data members accessible from member functions
of the class SoftDolls
(iv) Write name of all the member functions accessible by an object of the
class ElectronicDolls.
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
elements initially contains the elements as
4, 2, 5, 1, 6, 7, 8, 12, 10
313
then the function should rearrange the array as
10, 12, 8, 7, 6, 1, 5, 2, 4 4
(b) An array Arr[40][10] is stored in the memory along the column with each
element occupying 4 bytes. Find out the address of the location Arr[3][6]
if the location Arr[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
Assume the following definition of THENODE for the same.
struct THENODE
{
char Name[20] ;
THENODE *Link;
} ;
(d) Write a function in C++ to print the product of each column of a two
dimensional integer array passed as the argument of the function. 2
Explain: if the two dimensional array contains
Then the output should appear as :
Product of Column 1 = 24
Product of Column 2 = 30
Product of Column 3 = 240
(e) Evaluate the following postfix notation of expression (Show status of Stack
after execution of each operation) : 2
4, 10, 5, +, *, 15, 3, /, –
4. (a) Observe the program segment given below carefully, and answer the question
that follows: 1
class Applicant
{
long AId; //Applicant’s Id
314
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 ( ) ;
}
Write the Statement1 to position the File Pointer at the beginning of the Record for
which the Applicant’s ld matches with the argument passed, and Statement2 towrite 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) Given a binary file PHONE.DAT, containing records of the following
structure type 3
315
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 whichare having AreaCode as “DEL” from PHONE.DAT to PHONBACK.DAT.
5. (a) Differentiate between Candidate Key and Primary Key in context of RDBMS 2(b) Consider the following tables Product and Client. Write SQL commands for the
statement (i) to (iv) and give outputs for SQL queries (v) to (viii) 6
TABLE: PRODUCT
TABLE: CLIENT
316
(i) To display the details of those Clients whose City is Delhi
(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
and Price from table Product, with their corresponding matching P_ID
(iv) To increase the Price of all Products by 10
(v) SELECT DISTINCT Address FROM Client;
(vi) SELECT Manufacturer, MAX(Price), Min(Price), Count(*)
FROM Product GROUP BY Manufacturer;
(vii) SELECT ClientName, ManufacturerName
FROM Product, Client
WHERE Client.Prod_ld=Product.P_ld;
(viii) SELECT ProductName, Price *4
FROM Product
6. (a) State and verify De Morgan’s law in Boolean Algebra 2
(b) Draw a Logical Circuit Diagram for the following Boolean Expression
X’. (Y’ + Z) 1
(c) Convert the following Boolean expression into its equivalent Canonical
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) Expand the following terms with respect to Networking: 2
(i) MODEM
(ii) WLL
(iii) FTP
(iv) TCP/IP
(c) How is Coaxial cable different from Optical Fibre? 1
(d) “Bias Methodologies” is planning to expand their network in India, starting
with three cities in India to build infrastructure for research and development
317
of their chemical products. The company has planned to setup their main
office in Pondicherry - at three different locations and have named their offices
as “Back Office”, “Research Lab” and “Development Unit”. The company
has one more Research office namely “Corporate Office” in “Mumbai”. A
rough layout of the same is as follows : 4
Approximate distances between these offices is as follows:
In continuation of the above, the company experts have planned to install the
following number of computers in each of their offices:
(i) Suggest the kind of network required (out of LAN, MAN, WAN)
for connecting each of the following office units:
� Research Lab and Back Office
� Research Lab and Development Unit
(ii) Which one of the following device will you suggest for connecting
all the computers with in each of their office units?
318
� Switch/Hub
� Modem
� Telephone
(iii) Which of the following communication medium, you will suggest
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) Suggest a cable/wiring layout for connecting the company’s local
office units located in Pondicherry. Also, suggest an effective
method/technology for connecting the company’s office unit
located in Mumbai.
QUESTION PAPER CODE 91
1. (a) What is the purpose of using a typedef command in C++. Explain with
suitable example. 2
(b) Name the header files that shall be needed for the following code: 1
void main ( )
{
char Word [ ] =”Exam”;
cout<<setw(20)<<Word;
}
(c) Rewrite the following program after removing the syntax error(s), if any.
Underline each correction. 2
#include <iostream.h>
void main ( )
{
One = 10, Two = 20;
Callme (One;Two) ;
Callme (Two) ;
}
void Callme (int Arg1, int Arg2=20)
{
319
Arg1 = Arg1 + Arg2;
cout<<Arg1>> Arg2;
}
(d) Find the output of the following program : 3
#include<iostream.h>
#include<ctype.h>
void main ( )
{
char Mystring[ ] =“What@OUTPUT!” ;
for(int I = 0; Mystring [I] ! =’ \0'; I++)
{
if (!isalpha (Mystring[I]))
Mystring [I] = ‘*’;
else if (isupper (Mystring[I]))
Mystring [I] = Mystring[I] +1;
else
Mystring [I] = Mystring [I+1];
}
cout<<Mystring;
}
(e) Find the output of the following program : 2
#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;
}
}
(f) In the following program, find the correct possible output(s) from the options: 2
#include<stdlib.h>
#include<iostream.h>
void main ( )
{
320
randomize() ;
char Area [ ] [10] = {‘‘NORTH”, ‘‘SOUTH”, “EAST”, “WEST”} ;
int ToGo;
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) Differentiate between private and protected visibility modes in context of
Object Oriented Programming giving a suitable example illustrating each. 2
(b) Answer the questions (i) and (ii) after going through the following program: 2
#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
321
<<“@”<<Price<<endl;
}
};
void main ( )
{
Retail R; // Function 1
R. Show ( ) ;. // Function 2
}
(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) Define a class Clothing in C++ with the following descriptions: 4
Private Members:
Code of type string
Type of type string
Size of type integer
Material of type string
Price of type float
A function Calc_Price( ) which calculates and assigns the value of Price
as follows:
For the value of Material as “COTTON” :
Type Price (Rs.)
TROUSER 1500
SHIRT 1200
For Material other than “COTTON” the above mentioned Price
gets reduced by 25%.
Public Members:
A constructor to assign initial values of Code, Type and Material with the
word “NOT ASSIGNED” and Size and Price with 0.
A function 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
class Toys
{
char TCode [5] ;
protected:
float Price;
void Assign (float);
public:
Toys( ) ;
void TEntry ( ) ; ,
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) Which type of Inheritance is shown in the above example?
(ii) How many bytes will be required by an object of the class SoftToys ?
(iii) Write name of all the data members accessible from member functions
of the class SoftToys.
(iv) Write name of all the member functions, which are accessible from an
object of the class ElectronicToys.
323
3. (a) Write a function in C++, which accepts an integer array and its size as arguments
and swaps the elements of every even location with its following odd location. 4
Example: if an array of nine elements initially contains the elements as
2, 4, 1, 6, 5, 7, 9, 23, 10
then the function should rearrange the array as
4, 2, 6, 1, 7, 5, 23, 9, 10
(b) An array Arr[50] [100] is stored in the memory along the row with each element
occupying 2 bytes. Find out the address of the location Arr[20][50], if the location
Arr[10] [25] is stored at the address 10000. 4
(c) Write a function in C++ to Delete an element from a dynamically allocated Queue
where each node contains a real number as data.
Assume the following definition of MYNODE for the same.
struct MYNODE 4
{
float NUM;
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: if the two dimensional array contains
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) Evaluate the following postfix notation of expression (Show status of Stack
after execution of each operation) : 2
5, 20, 15, –, *, 25, 2, *, +
324
4. (a) Observe the program segment given below carefully, and answer the question
that follows:
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) ) )
{
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 ( ) ;
}
Write the Statement 1 to position the File Pointer at the beginning of the Record
for which the Candidate’s Id matches with the argument passed, and Statement
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
in a text file “ARTICLE.TXT”. 2
(c) Given a binary file TELEPHON.DAT, containing records of the following
class Directory:
class Directory
{
char Name[20] ;
char Address [30] ;
char AreaCode[5];
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
having AreaCode as “123” from TELEPHON.DAT toTELEBACK.DAT. 3
5. (a) Differentiate between Candidate Key and Alternate Key in context of
RDBMS. 2
(b) Consider the following tables Item and Customer. Write SQL commands
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 (Both values included)
(iii) To display the CustomerName, City from table Customer and ItemName
and Price from table Item, with their corresponding matching I-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
WHERE Item.Item_Id=Customer.Item.I_Id
(viii) SELECT ItemName, Price * 100
FROM Item WHERE Manufacturer =’ABC’; .
6. (a) State any verify Absorption law in Boolean Algebra. 2
(b) Draw a Logical Circuit Diagram for the following Boolean Expression : 1
A . (B + C’)
(c) Convert the following Boolean expression into its equivalent Canonical
Product of Sum Form (POS) : 2
A. B’ . C + A’. B . C + A’. B . C’
(d) Reduce the following Boolean expression using K - Map: 3
F (A, B, C, D) = ∑ (0, l, 2, 4, 5, 8, 9, 10, 11)
7. (a) What is a Modem? 1
(b) Expand the following terms with respect to Networking: 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
Chennai at three different locations and have named their offices as “Production
Unit”, “Finance Unit” and “Media Unit”. The company has its corporate unit
in Delhi.
A rough layout of the same is as follows:
Approximate distances between these Units is as follows:
328
In continuation of the above, the company experts have planned to install the
following number of computers in each of their office units:
(i) Suggest the kind of network required (out of LAN, MAN, WAN) for
connecting each of the following office units:
� Production Unit and Media Unit
� Production Unit and Finance Unit
(ii) Which one of the following devices will you suggest for connecting all
the computers within each of their office units?
� Switch/Hub
� Modem
� Telephone
(iii) Which of the following communication media, will you suggest to be
procured by the company for connecting their local office units in Chennai
for very effective (High Speed) communication?
� Telephone Cable
� Optical Fiber
� Ethernet Cable
(iv) Suggest a cable/wiring layout for connecting the company’s local office
units located in Chennai. Also, suggest an effective method/technology
for connecting the company’s office unit located in Delhi. 4
329
Marking Scheme — Computer Science
General Instructions :
1. The answers given in the marking scheme are SUGGESTIVE, Examiners are requested to
award marks for all alternative correct Solutions / Answers conveying the similar meaning
2. All programming questions have to be answered with respect to. C++ Language only.
3. In C++, ignore case sensitivity for identifiers (Variable/Functions/Structures/Class Names).
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 - semicolon should be ignored for terminating the SQL statements
6. In SQL related questions, ignore case sensitivity.
QUESTION PAPER CODE 91/1
EXPECTED ANSWERS
1. (a) What is the difference between #define and const? Explain with suitable
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)
value to a variable. Any attempt in modifying the value assigned to such a variable is
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 #defineand 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) Rewrite the following program after removing the syntactical error(s) if any.
Underline each correction. 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 suggestingcorrection)
(d) Find the output of the following program: 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) Find the output of the following program: 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) In the following program, find the correct possible output(s) from the options: 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) Differentiate between public and private visibility modes in context of Object
Oriented Programming using a suitable example illustrating each. 2
Ans: public visibility mode:
Members of a class declared under this visibility are accessible inside the
class (in member functions of the class) as well as by the Objects of that class
(in any non member function of the program, prototyped / defined after the
class declaration).
private visibility mode:
Members of a class declared under this visibility are accessible only inside the
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 suitableexample)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) Answer the questions (i) and (ii) after going through the following program 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: If the constructor is defined as a public member, the following output shall be
generated:
Electronic-Calculator:10@225
(1 Mark for correct answer)OR(½ Mark each for the String and Numeric values)
(c) Define,a class Garments in C++ with the following descriptions: 4
Private Members:
GCode of type string
GType of type string
GSize of type integer
GFabric of type string
GPrice of type float
A function 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%.
Public Members:
A constructor to assign initial values of GCode, GType and GFabric
with the word “NOT ALLOTTED” and GSize and GPrice with 0
A function Input ( ) to input the values of the data members GCode,
GType, GSize and GFabricl and invoke the Assign ( ) function.
A function Display ( ) which displays the content of all the data members
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 if Assign( ) is not invoked properly inside Input( ) function
(d) Answer the questions (i) to (iv) based on the following code: 4class 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) Which type of Inheritance is shown in the above example?Ans: Hierarchical Inheritance
ORSingle Level Inheritance
(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) Write name of all the data members accessible from member functions ofthe class SoftDolls
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 classElectronicDolls.
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 asparameters and rearranges the array in reverse. Example: if an array of nineelements initially contains the elements as
4, 2, 5, 1, 6, 7, 8, 12, 10then the function should rearrange the array as
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 swappingDeduct ½ Mark if reversed values are stored in another array
(b) An array Arr[40][10] is stored in the memory along the column with each
element occupying 4 bytes. Find out the address of the location Arr[3][6]
if the location Arr[30][10] is stored at the address 9000 4
Ans:
Address of Array[i][j] along the column =
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
Base Address = 9000 - 4 x 430
= 9000 -1720
= 7280
Address of Array[3][6] = 7280 + 4 * (3 + 6 * 40)
= 7280 + 4 * 243
= 7280 + 972
= 8252
OR
Address of Array[i][j] along the column =
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)
Base Address = 9000 - 4 * 389
= 9000 -1556
= 7444
Address of Array[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
Address of Array[i][j] along the column =
Address of Array[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 of Array[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 allocatedQueue where each node contains a name (of type string) as data. 4
Assume the following definition of THENODE for the same.
struct THENODE{
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)(½ Mark for new allocation for temporary pointer)(½ Mark for assigning OR entering the value of NAME on temporarypointer)(½ Mark for assigning NULL to 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 whenQUEUE is not Empty)(½ Mark for reassigning Rear with Temp when the QUEUE is not Empty)
(d) Write a function in C++ to print the product of each column of a two
dimensional integer array passed as the argument of the function. 2
Explain: if the two dimensional array contains
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) Evaluate the following postfix notation of expression (Show status of Stack
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
Any other method of evaluating correctly the postfix expression is showing
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) Observe the program segment given below carefully, and answer the question
that follows: 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 ( ) ;
}
Write the Statement1 to position the File Pointer at the beginning of the Record
for which the Applicant’s ld matches with the argument passed, and Statement2
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
Any equivalent correct method
Statement 2:
File.write((char*) &A, sizeof (A));
OR
File.write((char*)&A, sizeof(Applicant));
OR
Any equivalent correct method using A or C as object
(½ Mark for each correct Statement)
Note:
(Full 1 Mark to be given for mentioning error in code for undeclared symbolsC and c in the File.read(...))
(b) Write a function in C++ to count the number of lowercase alphabetspresent 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) Given a binary file PHONE.DAT, containing records of the followingstructure type 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 recordswhich are having AreaCode as “DEL” from PHONE.DAT toPHONBACK.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: Candidate Key: All such attributes/columns, which can uniquely identify eachrow/record in a table
Primary Key: An attribute/column among the Candidate Keys which is usedto uniquely identify each row/record in a table
(2 Marks for any valid difference/relation between Candidate Key and PrimaryKey)
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 SQL commands for thestatement (i) to (iv) and give outputs for SQL queries (v) to (viii) 6
TABLE: PRODUCT
349
TABLE: CLIENT
(i) To display the details of those Clients whose City is Delhi
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 to100 (Both values included)
Ans: SELECT * FROM ProductWHERE Price >=50 AND Price <=100;
OR
SELECT * FROM Product
WHERE Price BETWEEN 50 AND 100;
(½ Mark for correct SELECT)(½ Mark for correct WHERE clause)
(iii) To display the ClientName, City from Table Client, and ProductNameand Price from table Product, with their corresponding Matching P_ID
Ans: SELECT ClientName, City, ProductName, Price, Client.P_IDFROM Client, ProductWHERE 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 DISTINCT Address FROM Client
Ans: DISTINCT CityBangaloreDelhi
350
Mumbai
(½ Mark for correct output)
OR
(½ Mark for mentioning Address is not a Column in the Table Client ORmentioning ERROR)
(vi) SELECT Manufacturer, 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
Total Health ABC
Live life XYZ
Pretty Woman XYZ
Dreams LAK
(½ Mark for correct output)
OR
(½ Mark for mentioning ManufactureName and Prod_ld are not valid Columnin the respective Tables)
(viii) SELECT ProductName, Price * 4Ans: Product Name Price * 4
Talcom Powder 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 Boolean Algebra 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 and Verified
(1 Mark for stating anyone of the De Morgan’s Law)
(1 Mark for verifying anyone of the De Morgan’s Law)
(b) Draw a Logical Circuit Diagram for the following Boolean Expression 1
X’ . (y’ + Z)
Ans:
(1 Marks for Drawing Logic Circuit Diagram for all )
(c) Convert the following Boolean expression into its equivalent Canonical Sum
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 anetwork.
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) Expand the following terms with respect to Networking: 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) Transfer Control Protocol/Internet Protocol(½ Mark for each correct expansion)
353
(c) How is Coaxial cable different from Optical Fibre? 1
Ans: Coaxial Cable: Comparatively Slow, Economic, convenient to lay down, usedin Bus topology of networksOptical Fibre: Very fast, expensive, reliable, no interference(1 Mark for mentioning anyone valid difference)OR(½ Mark for anyone characteristic each of Coaxial Cable or OpticalFibre)
(d) “Bias Methodologies” is planning to expand their network in India, startingwith three cities in India to build infrastructure for research and developmentof their chemical products. The company has planned to setup their mainoffice in Pondicherry - at three different locations and have named their officesas “Back Office”, “Research Lab” and “Development Unit”. The companyhas one more Research office namely “Corporate Office” in “Mumbai”. Arough layout of the same is as follows : 4
Approximate distances between these offices is as follows:
In continuation of the above, the company experts p.aye planned to install the
following number of computers in each of their offices:
354
(i) Suggest the kind of network required (out of LAN, MAN, WAN) forconnecting each of the following office units:� Research Lab and Back Office� Research Lab and Development Unit
Ans: Research Lab and Back Office - LANResearch Lab and Development Unit - MAN(½ Mark for each answer)
(ii) Which one of the following device will you suggest for connecting allthe computers within each of their office units?� Switch/Hub� Modem� Telephone
Ans: Switch I Hub
(1 Mark for mentioning correct option)
(iii) Which of the following communication medium, you will suggest to beprocured by the company for connecting their local office units inPondicherry for very effective (High Speed) communication?� Telephone Cable� Optical Fiber� Ethernet Cable
Ans: Optical Fibre
(1 Mark for mentioning correct option)
(iv) Suggest a cable/wiring layout for connecting the company's local officeunits located in Pondicherry. Also, suggest an effective method/technology for connecting the company's office unit located in Mumbai.
Ans: Local office units at Pondicherry to be connected using LAN / MAN / starTopology / Tree Topology
Mumbai Office to be connected using Satellite/WAN
(½ Mark for mentioning valid connectivity or topology or diagram forlocal office in Pondicherry)(½ Mark. for mentioning valid connectivity or topology or diagram forMumbai office)
355
MARKING SCHEME
QUESTION PAPER CODE 91
EXPECTED ANSWERS
1. (a) What is the purpose of using a typedef command in C++. Explain with
suitable example. 2
Ans: Typedef:
This keyword allows creating synonyms or aliases for previously defined data
types
The general form of typedef is
typedef old_name new_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: 1void 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) Rewrite the following program after removing the syntax error(s), if any.Underline each correction. 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 suggestingcorrection)
(d) Find the output of the following program :#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) Find the output of the following program :#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 missing Ampersand (&) in each line of output
� ½ Mark to be deducted if endl is not considered in the output
(f) In the following program, find the correct possible output(s) from the options:#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) Differentiate between private and protected visibility modes in context ofObject Oriented Programming giving a suitable example illustrating each.
Ans: Private Visibility Mode Protected Visibility Mode
The members in private visibility The members in protected visibilitymodes are not accessible to modes are not accessible to objectsobjects as well as derived classes 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) Answer the questions (i) and (ii) after going through the following program:#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) Define a class Clothing in C++ with the following descriptions:
Private Members:
360
Code of type string
Type of type string
Size of type integer
Material of type string
Price of type float
A function Calc_Price( ) which calculates and assigns the value of Price
as follows:
For the value of Material as “COTTON” :
Type Price (Rs.)
TROUSER 1500
SHIRT 1200
For Material other than “COTTON” the above mentioned Price
gets reduced by 25%.
Public Members:
A constructor to assign initial values of Code, Type and Material with the
word “NOT ASSIGNED” and Size and Price with 0.
A function 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)(½ Mark for correct definition of function Calc_price())(½ Mark for constructor)(1 Mark for calculation of correct Price for each condition)(½ Mark for correct Enter() with proper invocation of Calc_Price())(½ Mark for displaying all data Members in function Show())
(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) Which type of inheritance is shown in the above example?
Ans: Hierarchical InheritanceORSingle Level Inheritance
(1 Mark to be given for mentioning any of the above mentioned type ofinheritance)
(ii) How many bytes will be required by an object of the class softToys?Ans:
33(1 Mark for correct answer)
(iii) Write name of all the data member(s) accessible from member functionsof 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) Write name of all the member functions, which are accessible from anobject of the class ElectronicToys.
Ans:Member Functions: TEntry ( ) , TDisplay ( ) , ETEntry ( ) , ETDisplay ( )
(1 Mark for correct answer)
363
NOTE:
� Constructors Toys() & ElectronicToys(), it mentioned 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 arguments
and swaps the elements of every even location with its following odd location. 4
Example: if an array of nine elements initially contains the elements as
2, 4, 1, 6, 5, 7, 9, 23, 10
then the function should rearrange the array as
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 array Arr[50] [100] is stored in the memory along the row with each element
occupying 2 bytes. Find out the address of the location Arr[20][50], if the location
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 formulawith correct values and calculate Base Address)
(1 Mark for writing correct formula/correct substituted values, for rowmajor properly, for calculating Address of Arr[20][50])
(1 Mark for calculating correct Address of Arr[20][50])
(c) Write a function in C++ to Delete an element from a dynamically allocated Queuewhere each node contains a real number as data.
Assume the following definition of MYNODE for the same.
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 Underflow\n”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 Underflow\n”;
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 arenot needed in the above function.
(½ Mark for correct function header)(½ Mark for declaring Front and Rear as members OR passing them asarguments 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: if the two dimensional array contains
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) Evaluate the following postfix notation of expression (Show status of Stack
after execution of each operation) :
5, 20, 15, –, *, 25, 2, *, +
367
Ans: Evaluation of the given postfix expression is explained below
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) Observe the program segment given below carefully, and answer the questionthat follows: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 ( ) ;
}
Write the Statement 1 to position the File Pointer at the beginning of the Record
for which the Candidate’s Id matches with the argument passed, and Statement
2 to write the updated Record at that position.
Ans:
Statement 1:File.seekp(Record*sizeof(C));
ORFile.seekp(-l*sizeof(C),ios::cur);
ORFile.seekg (Record*sizeof(C));
ORFile.seekg(-l*sizeof(C),ios::cur);
ORAny equivalent correct method qf calculating size of the
record in place of sizeof operator.
Statement 2:File.write((char*)&C, sizeof(C));
ORFile.write((char*)&C,sizeof(Candidate));
(½ Mark for each correct statement)
(b) Write a function in C++ to count the number of uppercase alphabets present
in a text file “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() ;
}
ORvoid 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)
(½ Mark for initialization and increment of the counter(variable))
(c) Given a binary file TELEPHON.DAT, containing records of the following
class Directory: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 recordshaving AreaCode as “123” from TELEPHON.DAT toTELEBACK.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
Any other equivalent code
(½ 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 ofRDBMS.
Ans: Candidate Key: It is the one that is capable of becoming primary key i.e., acolumn or set of columns that identifies a row uniquely in the relation.
Alternate Key: A candidate key that is not selected as a primary key is calledan Alternate Key.
371
(1 Mark each for correct definition/explanation of Candidate Key and
Alternate Key)
OR
(Full 2 Marks for illustrating the concept of Candidate and Alternate key with
appropriate example)
(b) Consider the following -tables Item and Customer. Write SQL commands
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 (Both values included)
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) To display the CustomerName, City from table Customer and ItemName
and Price from table item with their corresponding matching I_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 ( * )
Personal Computer 37000 3
Laptop 57000 2
(½ Mark for correct output - ignore the order of rows in the output & ColumnHeaders)
373
(vii) SELECT CustomerName, Manufacturer FROM Item, CustomerWHERE Item.Item_Id=Customer.Item.I_Id;
Ans: CustomerName Manufacturer
N Roy PQRH Singh XYZR Pandey COMPC Sharma PQRK Agarwal ABC
(½ Mark for correct output - ignore the order of rows in the output & ColumnHeaders)OR(½ Mark for mentioning syntax error or error as the column Item_ld is notpresent)
(viii) SELECT ItemName, Price*100 FROM Item WHERE Manufacturer ='ABC';
Ans:ItemName Price*100
Personal Computer 3500000
Laptop 5500000
(½ Mark for correct output - ignore the order of rows in the output &Column Headers)
6. (a) State any verify Absorption law in Boolean- 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 the Absorption Law)
(b) Draw a Logical Circuit Diagram for the following Boolean Expression :
A . (B + C’)
Ans:
(1 mark for the correct circuit diagram)
(c) Convert the following Boolean expression into its equivalent Canonical
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) Reduce the following Boolean expression using K - 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: Modem is a Modulation Demodulation device that converts analog signal to
digital signal and vice versa.
(1 Mark for any correct definition/explanation)
(b) Expand the following terms with respect to Networking :
(i) PPP (ii) GSM (iii) XML (iv) HTTP
Ans: (i) Point To Point Protocol
(ii) Global System for Mobile Communication
(iii) eXtensible MarkUp Language
(iv) Hyper Text Transfer 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
malicious intentions, where as Crackers are the one’s who get into someone’s
code or computer with malicious intentions.
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
Chennai at three different locations and have named their offices as “Production
Unit”, “Finance Unit” and “Media Unit”. The company has its corporate unit
in Delhi.
A rough layout of the same is as follows:
Approximate distances between these Units is as follows:
In continuation of the above, the company experts have planned to install the
following number of computers in each of their office units:
378
(i) Suggest the kind of network required (out of LAN, MAN, WAN) forconnecting each of the following office units:� Production Unit and Media Unit� Production Unit and Finance Unit
Ans:� Production Unit and Media Unit : MAN� Production Unit and Finance Unit : LAN(½ Mark for mention of each - MAN and LAN correctly)
(ii) Which one of the following device will you suggest for connecting allthe computers within each of their office units?
� Switch/Hub� Modem� Telephone
Ans:� Switch/Hub(1 Mark for the correct device)
(iii) Which of the following communication media, will you suggest to beprocured by the company for connecting their local offices in Chennaifor very effective (High Speed) communication?
� Ethernet cable� Optical Fiber� Telephone cable
Ans:� Optical Fiber(1 Mark for the correct media)
(iv) Suggest a cable/wiring layout for connecting the company's local officeunits located in Chennai. Also, suggest an effective method/technologyfor connecting the company's office unit located in Delhi.
Ans:
Optical Fiber/Star Topology
Wireless/Satellite Link/leased Line
(½ 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
example in C++ to illustrate both. 2
(b) Write the names of the header files to which the following belong: 1
(i) puts( )
(ii) sin( )
(c) Rewrite the following program after removing the syntactical errors (if any).
Underline each correction. 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) Find the output of the following program : 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) Find the output of the following program : 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) Study the following program and select the possible output from it : 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) Which member function out of Function 1, Function 2, Function 3 and Function
4 shown in the above definition of class WORK is called automatically, when
the scope of an object gets over? Is it known as Constructor OR Destructor
OR Overloaded Function OR Copy Constructor?
(ii) WORK W ; //Statement 1
WORK Y (W) ; //Statement 2
Which member function out of Function 1, Function 2, Function 3 and Function
4 shown in the above definition of class WORK will be called on execution of
statement written as statement 2 ? What is this function specifically known as
out of Destructor or Copy Constructor or Default Constructor?
(c) Define a class RESORT in C++ with following description: 4
314
Private Members
� 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
Public Members
� Getinfo ( ) //A function to enter the content Rno, Name,
//Charges and Days
� Dispinfo ( ) //A function to display Rno, Name, Charges,
//Days and Amount (Amount to be displayed by
//calling function COMPUTE ( ) )
(d) Answer the questions (i) to (iv) based on the following: 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) Which type of Inheritance is shown in the above example?
(ii) Write names of all the member functions accessible from Show( ) function of
class Training.
(iii) Write name of all the members accessible through an object of class Training.
(iv) Is the function Output( ) accessible inside the function SiteOut( ) ? Justify
your answer.
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: Assume the following definition of structure Game
struct Game
{
long PNo; //Player Number
char PName [20] ;
long Points;
} ;
Sample content of the array (before sorting)
PNo PName Points
103 Ritika Kapur 3001
104 John Philip 2819
101 Razia Abbas 3451
105 Tarun Kumar 2971
316
Sample content of the array (after sorting)
PNo PName Points
101 Razia Abbas 3451
103 Ri tika Kapur 3001
105 Tarun Kumar 2971
104 John Philip 2819
(b) An array S[40][30] is stored in the memory along the column with 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
allocated Queue containing nodes of the following given structure: 4
struct Node
{
int PId ; //Product Id
char Pname [20] ;
NODE *Next ;
} ;
(d) Define a function SWAPCOL ( ) in C++ to swap (interchange) the first column
elements with the last column elements, for a two dimensional integer array
passed as the argument of the function. 3
Example: If the two dimensional array contains
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
showing stack contents for the conversion: 2
X–Y /(Z + U) * V
4. (a) Observe the program segment given below carefully and fill in the blanks
marked as Line 1 and Line 2 using fstream functions for performing the re-
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’ in a text file “MEMO.TXT” 2
Example:
If the content of the file “MEMO.TXT” is as follows:
I will do it, if you
request me to do it.
It would have been done much earlier.
The function COUNT_DO ( ) will disDla
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
status is ‘A’ (i.e. Active) from a binary file “USER.DAT”. Assuming the binary
file “USER.DAT” is containing objects of class USER, which is defined as
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 candidatekeys in a table. 2
(b) Consider the following tables GARMENT and FABRIC. Write SQLcommands 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) To display the details of all the GARMENTs, which have READYDA
TE in between 08-DEC-07 and 16-JUN-08(inclusive of both the
dates).
(iii) To display the average PRICE of all the GARMENTs, which are made
up of FABRIC with FCODE as F03.
(iv) To display FABRIC wise highest and lowest price of GARMENTs
from GARMENT table. (Display FCODE of each GARMENT along
with highest and lowest price)
(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) Write the equivalent Boolean Expression for the following Logic Circuit: 2
(c) Write the POS form of a Boolean function H, which is represented in a truth
table as follows: 1
321
(d) Reduce the following Boolean Expression using K-Map : 3F(P, Q, R, S) = Σ(1, 2, 3, 5,6, 7, 9, 11, 12, 13, 15)
7. (a) What is difference between Star Topology and Bus Topology of network? 1
(b) Expand the following abbreviations: 1
(i) GSM
(ii) CDMA
(c) What is protocol? Which protocol is used to search information from internetusing an internet browser? 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 in Ana Nagar ofSouth India with its center admission office in Kolkata. The university has 3major blocks comprising of Office Block, Science Block and CommerceBlock in the 5 KM area Campus.
As a network expert, you need to suggest the network plan as per (El) to(E4) to the authorities keeping in mind the distance and other given parameters.
Expected Wire distances between various locations:
Office Block to Science Block 90 m
Office Block to Commerce Block 80 m
Science Block to Commerce Block 15 m
Kolkata Admission office to Ana Nagar Campus 2450 km
Expected number of Computers to be installed’ at various locations in the
University are as follows:
Office Block 10
Science Block 140
Commerce Block 30
Kolkata Admission office 8
322
(E1) Suggest the authorities, the cable layout amongst various blocks inside
university campus for connecting the blocks. 1
(E2) Suggest the most suitable place (i.e. block) to house the server of this
university with a suitable reason. 1
(E3) Suggest an efficient device from the following to be installed in each of the
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 between Admission Office located in Kolkata and the campus
located in Ana Nagar from the following options: 1
� Telephone line
� Fixed-Line Dial-up connection
� Co-axial Cable Network
� GSM
� Leased line
� Satellite Connection
QUESTION PAPER CODE 91
1. (a) What is the difference between Actual Parameter and Formal Parameter?
Give an example in C++ to illustrate both types of parameters. 2
(b) Write the names of the header files to which the following belong: 1
(i) setw( )
(ii) sqrt( )
(c) Rewrite the following program after removing the syntactical errors (if any).
Underline each correction. 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) Find the output of the following program: 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) Find the output of the following program: 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) Study the following program and select the possible output from it : 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) What is function overloading? Give an example in C++ to illustrate function
overloading. 2
(b) Answer the questions (i) and (ii) after going through the following class: 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) Which member function out of Function 1, Function 2, Function 3 and Function
4 shown in the above definition of class Job is called automatically, when the
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
Which member function out of Function 1, Function 2, Function 3 and Function
4 shown in the above definition of class Job will be called on execution of
statement written as Line 2 ? What is this function specifically known as out of
Destructor or Copy Constructor or Default Constructor?
(c) Define a class HOTEL in C++ with the following description: 4
Private Members:
� 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( ) //A function to calculate and return Amount as NOD*Tariff
and if the value of NOD*Tariff is more than 10000 then as
1.05*NOD*Tariff
Public Members
� Checkin ( ) / / A function to enter the content Rno, Name,
/ / Tariff and NOD
� Checkout( ) / / A function to display Rno, Name, Tariff,
/ /NOD and Amount (Amount to be displayed by
/ /calling function CALC( ))
(d) Answer the questions (i) to (iv)based on the following: 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) Which type of Inheritance is shown in the above example?
(ii) Write names of all the member functions accessible from OutCourse
function of class Course.
(iii) Write name of all the members accessible througb an object of class
Course.
(iv) Is the function InRegular( ) accessible inside the function InDistance( )?
Justify your answer.
3. (a) Write a function SORTSCORE( ) in C++ to sort an array of structure Examinee
in descending order of Score using Bubble Sort. 3
Note: Assume the following definition of structure Examinee
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: If the two dimensional array contains
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
showing stack contents for the conversion: 2
A + B * (C – D) / E
4. (a) Observe the program segment given below carefully and fill the blanks marked.
as Line 1 and Line 2 using fstream functions for performing the required task. 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’
in a text file “NOTES.TXT”. 2
331
Example:
If the content of the file “NOTES.TXT” is as follows:
It is very important to know that
smoking is injurious to health.
Let us take initiative to stop it.
The function COUNT_TO( ) will display the following message:
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,
which is defined as follows: 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) To display the details of all the dresses which have LAUNCHDATE in
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) To display materialwise highest and lowest price of dresses from DRESS
table. (Display MCODE of each dress along with highest and lowest
price)
333
(v) SELECT SUM(PRICE) FROM DRESS WHERE MCODE=‘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) State and verify absorption law using truth table. 2
(b) Write the equivalent Boolean Expression for the following Logic Circuit: 2
(c) Write the POS form of a Boolean function G, which is represented in a truth
table as follows: 1
(d) Reduce the following Boolean Expression using K-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 and WAN? 1
(b) Expand the following abbreviations: 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
Parampur of Central India with its center admission office in Delhi. The university
has 3 major buildings comprising of Admin Building, Academic Building and
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.
Expected Wire distances between various locations:
Research Building to Admin Building 90m
Research Building to Academic Building 80m
Academic Building to Admin Building 15m
Delhi Admission Office to Parampur Campus 1450 km
Expected number of computers to be installed at various locations in the
university are as follows:
335
Research Building 20
Academic Building 150
Admin Building 35
Delhi Admission Office 5
(E1) Suggest to the authorities, the cable layout amongst various buildings
inside the university campus for connecting the buildings. 1
(E2) Suggest the most suitable place (i.e. building) to house the server of this
organisation, with a suitable reason. 1
(E3) Suggest an efficient device from the following to be installed in each of
the buildings to connect all the computers : 1
(i) GATEWAY
(ii) MODEM
(iii) SWITCH
(E4) Suggest the most suitable (very high speed) service to provide data
connectivity between Admission Building located in Delhi and the
campus located in Par am pur from the following options: 1
� Telephone line
� Fixed-Line Dial-up connection
� Co-axial Cable Network
� GSM
� Leased line
� Satellite Connection
336
Marking Scheme — Computer Science
General Instructions :
1. The answers given in the marking scheme are SUGGESTIVE, Examiners are requested to
award marks for all alternative correct Solutions / Answers conveying the similar meaning
2. All programming questions have to be answered with respect to. C++ Language only.
3. In C++, ignore case sensitivity for identifiers
(Variable/Functions/Structures/Class Names)
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. In SQL related questions - semicolon should be ignored for terminating the SQL statements
7. In SQL related questions, ignore case sensitivity.
QUESTION PAPER CODE 91/1
EXPECTED ANSWERS
1. (a) What is the difference between call by value and call by reference? Give an
example in C++ to illustrate both. 2
Ans Call by value is used to create a temporary copy of the data coming from the
actual parameter into the formal parameter. The changes done in the function
in formal parameter are not reflected back in the calling environment. It does
not use ‘&’ 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
the calling environment. It uses ‘&’ 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
(½ Mark for each correct explanation of Call by Value and Call by Reference)
(½ 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 by Value and Call by Reference)
OR
(Only 1 Mark to be awarded if Explanation without supporting examples)
Note: Output is optional
(b) Write the names of the header files to which the following belong: 1
(i) puts ( ) (ii) sin ( )
338
Ans (i) stdio.h (ii) math. h
(½ Mark for writing each correct header file)
(c) Rewrite the following program after removing the syntactical errors (if any).
Underline each correction. 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;)
(½ Mark for writing: after public and; after E.List())
(½ Mark for writing E.Joining ( ); correctly)
Note: ½ mark for identifying any two errors without valid correction and 1
mark for identifying all five errors without valid correction
(d) Find the output of the following program: 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) Find the output of the following program : 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) Study the following program and select the possible output from it : 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’s data value of the same class. In the example below the values of data
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) Which member function out of Function 1, Function 2, Function 3 and Function
4 shown in the above definition of class WORK is called automatically, when
the scope of an object gets over? Is it known as Constructor OR Destructor
OR Overloaded Function OR Copy Constructor?
Ans Function 1
Destructor.
(½ Mark for naming Function 1 correctly)
(½ Mark for naming it as Destructor,
(ii) WORK W; // Statement 1
WORK Y(W); // Statement 2
Which member function out of Function 1, Function 2, Function 3 and Function
4 shown in the above definition of class WORK will be called on execution of
statement written as statement 2 ? What is this function specifically known as
out of Destructor or Copy Constructor or Default Constructor?
Ans Function 4
Copy Constructor.
(½ Mark for naming Function 4 correctly)
(½ Mark for naming it as Copy Constructor)
(c) Define a class RESORT in C++ with following description: 4
Private Members
� 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
Public Members
� Getinfo ( ) //A function to enter the content Rno, Name,
//Charges and Days
345
� Dispinfo ( ) //A function to display Rno, Name, Charges,
//Days and Amount (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
COMPUTEO function)
(1 Mark for correct definition of Getinfo( ))
NOTE: Deduct ½ Mark if COMPUTE( ) is not invoked properly inside
Dispinfo( ) function
(d) Answer the questions (i) to (iv) based on the following: 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) Which type of Inheritance is shown in the above example?
Ans Multiple Inheritance
(1 Mark for mentioning correct inheritance type)
ii) Write names of all the member functions accessible from Show( ) function of
class Training.
Ans Register( )
Siteln( ). SiteOut( ).
Input( ), Output( )
(1 Mark for correct answer)
Note: No marks to be awarded for any other alternative answer
iii) Write name of all the members accessible through an object of class Training.
Ans Register( ), Show( ),
Input( ), Output( )
(1 Mark for correct answer)
Note: No marks to be awarded for any other alternative answer
iv) Is the function Output( ) accessible inside the function SiteOut( )? Justify your
answer.
Ans No, function Output( ) is not accessible inside the function SiteOut( ), 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 NOT ACCESSIBLE correctly)
( ½ Mark for correct justification)
OR
(1 Mark if YES is supported with valid justification that the function InRegular( )
348
is accessible inside the function InDistance( ) ONLY for an object of the derived class OR in
context of Inheritance)
NOTE: No mark to be awarded if only YES 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: Assume the following definition of structure Game
struct Game
{
long PNo; //Player Number
char PName [20] ;
long Points;
} ;
Sample content of the array (before sorting)
PNo PName Points
103 Ritika Kapur 3001
104 John Philip 2819
101 Razia Abbas 3451
105 Tarun Kumar 2971
Sample content of the array (after sorting)
PNo PName Points
101 Razia Abbas 3451
103 Ri tika Kapur 3001
105 Tarun Kumar 2971
104 John Philip 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
Any other correct equivalent function definition
( ½ 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 if Temp is not declared with correct data type
(b) An array S[40][30] is stored in the memory along the column with 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
(1 Mark for writing correct formula (for column major) OR substituting formula
with correct values for calculating correct Base Address)
(1 Mark for calculating correct Basg Address)
351
(1 Mark for writing correct formula/correct substituted values, for column
major properly, for calculating Address 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
allocated Queue containing nodes of the following given structure: 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 NULL to Temp->Next)
(½ Mark for checking Empty Queue)
(½ Mark for assigning Front with Temp in case of empty queue)
(½ Mark for assigning Rear ->Next with Temp when queue is not empty)
(½ Mark for assigning Rear with Temp)
(d) Define a function SWAPCOL ( ) in C++ to swap (interchange) the first column
elements with the last column elements, for a two dimensional integer array
passed as the argument of the function. 3
Example: If the two dimensional array contains
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
Any other correct equivalent function definition.
(1 Mark for correct function header)
(1 Mark for correct loop)
(1 Mark for swapping the first column with last column correctly)
(e) Convert the following infix expression to its equivalent postfix expression
showing stack contents for the conversion: 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 equivalentpostfix expression showing the Stack Status.
(½ Mark for correctly converting expression up to each operator
(1 Mark only to be given for writing correct answer without showing theStack Status)
4. (a) Observe the program segment given below carefully and fill in the blanksmarked as Line 1 and Line 2 using fstream functions for performing the re-
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 Statement 1:
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
Any equivalent correct method
Statement 2:
File.write((char*)&S, sizeof(S));
OR
File.write((char*)&S, sizeof(Stock));
OR
Any equivalent correct method
(½ Mark for each correct Statement)
(b) Write a function COUNT_DO( ) in C++ to count the presence of a word
‘do’ in a text file “MEMO.TXT” 2
358
Example:
If the content of the file “MEMO.TXT” is as follows:
I will do it, if you
request me to do it.
It would have been done much earlier.
The function COUNT_DO ( ) will display the following message:
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
Any other correct function definition
(½ 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 the Text Message)
(c) Write a function in C++ to read and display the detail of all the users whose
status is ‘A’ (i.e. Active) from a binary file “USER.DAT”. Assuming the binary
file “USER.DAT” is containing objects of class USER, which is defined as
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.DAT correctly)
(½ 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’)
(½ Mark for displaying the matching record)
362
5. (a) What are candidate keys in a table? Give a suitable example of candidatekeys in a table. 2
Ans A table may have more than one such attribute/group of attribute that identifies
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)
OR
(2 Marks for illustrating Candidate Key with/without showing it as a part of
a Table)
(b) Consider the following tables GARMENT and FABRIC. Write SQLcommands 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) To display GCODE and DESCRIPTION of each GARMENT in descending
order of GCODE
Ans SELECT GeODE, DESCRIPTION FROM GARMENT
ORDER BY GCODE DESC;
(1 Mark for correct query)
(½ Mark for partially correct answer)
(ii) To display the details of all the GARMENTs, which have READYDA TE in
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 display the average PRICE of all the GARMENTs, which are made up of
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
GARMENT table. (Display FCODE of each GARMENT along with highest
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) SELECT DESCRIPTION, TYPE FROM GARMENT, FABRIC WHERE
GARMENT.FCODE = FABRIC.FCODE AND 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) Write the equivalent Boolean Expression for the following Logic Circuit: 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
table as follows: 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) Reduce the following Boolean Expression using K-Map : 3F(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)
(1 Mark for writing final expression in reduced/minimal form)
Note: Deduct ½ mark if wrong variable names are used
7. (a) What is difference between Star Topology and Bus Topology of network? 1
Ans Bus Topology: It is characterised by common transmission medium shared by
all the connected hosts, managed by dedicated nodes. It offers simultaneous
flow of data and control.
Star Topology: It is characterised by central switching node (communication
controller) and unique path (point to point link) for each host. It is easy to add
and remove additional hosts by upgrading the centralised node
(1 Mark for correct difference, either Textual or Diagrammatical)
OR
( ½ Mark for correct Textual/Diagrammatical explanation of either Bus or
Star Topology
(b) Expand the following abbreviations: 1
(i) GSM
(ii) CDMA
Ans (i) Global System for Mobile Communication
(ii) Code Division Multiple Access
( ½ 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 internetusing an internet browser? 1
Ans A protocol is the set of rules for governing communication between two
communication devices. It also infers documentation, negotiations and
establishment of rules.
Protocol used to search information from internet using an internet browser is :
TCP/IP OR HTTP
(½ Mark for explaining protocol correctly)
(½ Mark for TCP/IP or HTTP)
(d) Name two switching techniques used to transfer data between two terminals(computers ). 1
Ans Message Switching and Packet Switching
OR
Circuit Switching and Message Switching
OR
Circuit Switching and Packet Switching
(½ Mark for first switching technique)
(½ Mark for second switching technique)
(e) Freshminds University of India is starting its first campus in Ana Nagar ofSouth India with its center admission office in Kolkata. The university has 3major blocks comprising of Office Block, Science Block and CommerceBlock in the 5 KM area Campus.
As a network expert, you need to suggest the network plan as per (El) to(E4) to the authorities keeping in mind the distance and other given parameters.
368
Expected Wire distances between various locations:
Office Block to Science Block 90 m
Office Block to Commerce Block 80 m
Science Block to Commerce Block 15 m
Kolkata Admission office to Ana Nagar Campus 2450 km
Expected number of Computers to be installed’ at various locations in the
University are as follows:
Office Block 10
Science Block 140
Commerce Block 30
Kolkata Admission office 8
(E1) Suggest the authorities, the cable layout amongst various blocks inside
university campus for connecting the blocks. 1
Ans
(1 Mark for mentioning any valid connectivity or topology or diagram
connecting various blocks inside university campus)
(E2) Suggest the most suitable place (i.e. block) to house the server of this
university with a suitable reason. 1
Ans Science Block as it contains maximum number of computere.
(½ Mark for mentioning the block)
(½ Mark for correct reason)
Note: 1 mark if Commerce Block is written with valid justification eg.
Minimum wiring needed
(E3) Suggest an efficient device from the following to be installed in each of the
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 between Admission Office located in Kolkata and the campus
located in Ana Nagar from the following options: 1
� Telephone line
� Fixed-Line Dial-up connection
� Co-axial Cable Network
� GSM
� Leased line
� Satellite Connection
Ans Satellite Connection
OR
Leased line
(1 Mark for correct service name)
QUESTION PAPER CODE 91
EXPECTED ANSWERS
1. (a) What is the difference between Actual Parameter and Formal Parameter?
Give an example in C++ to illustrate both types of parameters. 2
Ans A parameter used in the function call is known as Actual Parameter. It is used
to send the data to function.
A parameter used in the function definition is known as Formal Parameter, 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) Write the names of the header files to which the following belong: 1
(i) setw( )
(ii) sqrt( )
Ans (i) iomanip.h (ii) math.h
(½ Mark for writing each correct header file)
(c) Rewrite the following program after removing the syntactical errors (if any).
Underline each correction. 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 () ;
}
(½ Mark for writing both include as #include)
(½ Mark for removing = 1001 from int StudentId = 1001;)
(½ Mark for writing: after public)
(½ Mark for writing MS. Register ( ) ; correctly)
Note: ½ mark for identifying any two errors without valid correction and
1 mark for identifying all five errors without valid correction
372
(d) Find the output of the following program: 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 ½ Mark if any/all ‘*’ missing
Deduct ½ Mark if endl is not considered at the right positions
(e) Find the output of the following program: 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) Study the following program and select the possible output from it : 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) What is function overloading? Give an example in C++ to illustrate function
overloading. 2
Ans Function overloading is an example of polymorphism, where the functions
having same name with different set of parameters perform different operations.
OR
When a function is having more than one definition and differentiable by the
number/type of parameters is known as function overloading
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
}
(1 Mark for correct definition or explanation of Function Overloading)
(1 Mark for a valid example of Function Overloading)
(b) Answer the questions (i) and (ii) after going through the following class: 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) Which member function out of Function 1, Function 2, Function 3 and Function
4 shown in the above definition of class Job is called automatically, when the
scope of an object gets over? Is it known as Constructor OR Destructor OR
Overloaded Function OR Copy Constructor?
376
Ans Function 1.
Destructor.
( ½ Mark for mentioning the correct function)
( ½ Mark for identifying it as Destructor)
(ii) Job P ; //Line 1
Job Q(P) ; //Line 2
Which member function out of Function 1, Function 2, Function 3 and Function
4 shown in the above definition of class Job will be called on execution of
statement written as Line 2 ? What is this function specifically known as out of
Destructor or Copy Constructor or Default Constructor?
Ans Function 4.
Copy Constructor.
( ½ Mark for mentioning the correct function)
( ½ Mark for identifying it as Copy constructor)
(c) Define a class HOTEL in C++ with the following description: 4
Private Members:
� 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( ) //A function to calculate and return Amount as NOD*Tariff
and if the value of NOD*Tariff is more than 10000 then as
1.05*NOD*Tariff
Public Members
� Checkin ( ) / / A function to enter the content Rno, Name,
/ / Tariff and NOD
� Checkout( ) / / A function to display Rno, Name, Tariff,
/ /NOD and Amount (Amount to be displayed by
/ /calling function CALC( ))
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 ½ Mark if CALC() is not invoked properly inside Checkout( )
function
(d) Answer the questions (i) to (iv)based on the following: 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) Which type of Inheritance is shown in the above example?
Ans Multiple Inheritance
(1 Mark for mentioning correct type of inheritance)
(ii) Write names of all the member functions accessible from OutCourse function
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) Write name of all the .:members accessible througb an object of class Course.
Ans InCourse( ), OutCourse( ),
InRegular( ), OutRegular( )
(1 Mark for correct answer)
Note: No marks to be awarded for any other alternative answer
(iv) Is the function InRegular( ) accessible inside the function InDistance( )? Justify
your answer.
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
independent classes.
(½ Mark for mentioning NOT ACCESSIBLE correctly)
(½ Mark for correct justification)
OR
(1 Mark if YES is supported with valid justification that the function
InRegular( ) is accessible inside the function InDistance(} ONL Y for an object
of the derived class OR in context of Inheritance}
NOTE: No mark to be awarded if only YES is written without any justification.
3. (a) Write a function SORTSCORE( ) in C++ to sort an array of structure Examinee
in descending order of Score using Bubble Sort. 3
380
Note: Assume the following definition of structure Examinee
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
Any other correct equivalent function definition
( ½ 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 if Temp 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
(1 Mark for writing correct formula (for column major) OR substituting formula
with correct values for calculating correct Base Address)
(1 Mark for calculating correct Base Address)
(1 Mark for writing correct formula (for column major) OR substituting formula
with correct values for calculating Address of T[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 to Temp)
(½ Mark for displaying the deleted Node detail(s))
(1 Mark for reassigning Front with Front->Link)
( ½ Mark for deleting Temp)
( ½ 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: If the two dimensional array contains
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
Any otiler correct equivalent function definition
(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
showing stack contents for the conversion: 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
postfix expression showing the Stack Status.
(½ 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 the blanks marked.
as Line 1 and Line 2 using fstream functions for performing the required task. 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 Statement 1:
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
Any equivalent correct method
Statement 2:
File.write((char*)&L, sizeof(L));
OR
File.write((char*)&L, sizeof(Library));
OR
Any equivalent correct method
(½ Mark for each correct Statement)
(b) Write a function COUNT_TO( ) in C++ to count the presence of a word ‘to’
in a text file “NOTES.TXT”. 2
Example:
If the content of the file “NOTES.TXT” is as follows:
It is very important to know that
smoking is injurious to health.
Let us take initiative to stop it.
The function COUNT_TO( ) will display the following message:
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
Any other correct function definition performing the desired operation
(½ Mark for opening NOTES. TXT correctly)
(½ Mark for reading each word (Whichever method adopted) from the file)
(½ Mark for comparing the word with ‘to’ and incrementing counter)
(½ Mark for displaying the number of ‘to’ with/without the Text Message)
(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,
which is defined as follows: 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.DAT correctly)
(½ Mark for reading each record from CLUB.DAT)
(½ Mark for correct loop / checking end of file)
(1 Mark for comparing value returned by WhatType( ) with ‘L’ , ‘M’)
(½ Mark for displaying the matching record)
5. (a) What is the purpose of a key in a table? Give an example of a key in a table. 2
Ans An attribute/group of attributes in a table that identifies each tuple uniquely is
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
(1 Mark for writing correct definition/purpose of any valid 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 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) To display the details of all the dresses which have LAUNCHDATE in between
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) To display the average PRICE of all the dresses which are made up of material
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, MATERIAL WHERE
DRESS.DCODE = MATERIAL.MCODE AND DRESS.PRICE>=l250;
396
Ans DESCRIPTION TYPE
(NO OUTPUT)
(½ Mark for the above)
OR
(½ Mark for attempting the question)
(vii) SELECT MAX(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) State and verify absorption law using truth table. 2
Ans Absorption Law : 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 the Absorption Laws)
(1 Mark for verifying the law using Truth Table)
397
(b) Write the equivalent Boolean Expression for the following Logic Circuit: 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
table as follows: 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) Reduce the following Boolean Expression using K-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)
(1 Mark for writing tinalexpression in reduced/minimal form)
Note: Deduct ½ mark if wrong variable names are used
7. (a) What is the difference between LAN and WAN? 1
Ans LAN (Local Area 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
interconnected using a LAN.
WAN (Wide Area Network)
It is used to connect systems with no limitation of geographical area. It is used
to serve many locations distributed over a large geographical area.
A system of overnight teller machines used by a banking organisation covering
the North of India is an example of a WAN. Internet is also an example of the
same.
399
(1 Mark for correct difference, either Textual or Diagrammatical)
OR
( ½ Mark each for correct Textual/Diagrammatical explanation of LAN or WAN)
(b) Expand the following abbreviations: 1
(i) HTTP
(ii) ARPANET
Ans (i) Hyper Text Transfer Protocol
(ii) Advanced Research Projects Agency Network
(½ Mark for correct expansion of HTTP)
(½ Mark for correct expansion of ARPANET)
(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
establishment of rules.
Protocol used to copy a file fromlto a remotely located server is FTP (File
Transfer Protocol)
(½ Mark for explaining protocol correctly)
(½ Mark for FTP)
(d) Name two switching techniques used to transfer data between two terminals
(computers). 1
Ans Message Switching and Packet Switching
OR
Circuit Switching and Message Switching
OR
Circuit Switching and Packet Switching
(½ Mark for naming first switching technique)
(½ Mark for naming second switching technique)
(e) Eduminds University of India is starting its first campus in a small town Parampur
of Central India with its center admission office in Delhi. The university has 3
400
major buildings comprising of Admin Building, Academic Building and 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.
Expected Wire distances between various locations:
Research Building to Admin Building 90m
Research Building to Academic Building 80m
Academic Building to Admin Building 15m
Delhi Admission Office to Parampur Campus 1450 km
Expected number of computers to be installed at various locations in the
university are as follows:
Research Building 20
Academic Building 150
Admin Building 35
Delhi Admission Office 5
(E1) Suggest to the authorities, the cable layout amongst various buildings
inside the university campus for connecting the buildings. 1
Ans
401
(1 Mark for mentioning any valid connectivity or topology or diagram
connecting various buildings inside university campus)
(E2) Suggest the most suitable place (i.e. building) to house the server of this
organisation, with a suitable reason. 1
Ans Academic Building as it contains maximum number of computers.
( ½ Mark for mentioning the building)
( ½ Mark for correct reason)
Note: 1 mark if any suitable place/building is suggested with valid justification
(E3) Suggest an efficient device from the following to be installed in each of
the buildings to connect all the computers : 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 between Admission Building located in Delhi and the
campus located in Par am pur from the following options: 1
� Telephone line
� Fixed-Line Dial-up connection
� Co-axial Cable Network
� GSM
� Leased line
� Satellite Connection
Ans Satellite Con nection
OR
Leased line
(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) Which C++ header file(s) will be essentially required to be included to run/
execute the following C++ code? 1
void main( )
{
int Eno=123, char Ename[ ]=”Rehan Swamp”;
cout<<setw(5)<<Eno<<setw(25)<<EName<<endl;
}
(c) Rewrite the following c++ program code after removing the syntax error(s)
(if any). Underline each correction. 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) Find the output of the following program : 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) Find the output of the following program : 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) The following code is from a game, which generates a set of 4 random numbers.
Yallav is playing this game, help him to identify the correct option(s) out of the
four choices given below as the possible set of such numbers generated from
the 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++to illustrate the same. . 2
(b) Answer the questions (i) and (ii) after going through the following class: 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) What is Function 3 specifically referred as ? When do you think, Function 3will be invoked/called?
(c) Define a class ITEM in C++ with following description: 4
Private Members
� Code of type integer (Item Code)
� Iname of type string (Item Name)
� Price of type float (Price of each item)
� Qty of type integer (Quantity of item in stock)
� Offer of type float (Offer percentage on the item)
� A member function GetOffer() to calculate Offer percentage as per the
following rule:
If Qty<=50 Offer is 0
If 50<Qty<=100 Offer is 5
If Qty>100 Offer is 10
Public Members
� A function GetStock() to allow user to enter values for Code, Iname,
Price, Qty and call function GetOffer() to calculate the offer
� A function ShowItem() to allow user to view the content of all the data
members
(d) Answer the questions (i) to (iv) based on the following: 4class Chairperson
{
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) Which type of inheritance out of the following is specifically is illustrated in
the above C++ code?
309
(a) Single Level Inheritance
(b) Multi Level Inheritance
(c) Multiple Inheritance
(ii) Write the names of data members, which are accessible by objects of class
type Company.
(iii) Write the names of all member functions, which are accessible by objects of
class type Company.
(iv) Write the names of all members, which are accessible from member functions
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
divisible by 7 and multiply other-array elements by 3. 3
Sample Input Data of the array
Content of the array after Calling CHANGE() function
(b) An array P[50][60] is stored in the memory along the column with each of the
element occupying 2 bytes, find out the memory location for the element P[10]
[20], if the Base Address of the array is 6800. 3
(c) Write a complete program in c++ to implement a dynamically allocated Stack
containing names of Countries. 4
(d) Write a function int SKIPSUM(int A[ ] [3], int N,int M) in C++ to find and
return the sum of elements from all alternate elements of a two-dimensional
array starting from A[0][0]. 2
Hint:
If the following is the content of the array
310
The function SKIPSUM() should add elements A[0][0], A[0][2], A[1][l],
A[2][0] and A[2][2].
(e) Evaluate the following postfix notation of expression: 2(Show status of Stack after each operation)
False, True, NOT, OR, True, False, AND, OR
4. (a) Observe the program segment given below carefully and fill the blanks mar-
ked as Statement 1 and Statement 2 using tellg() and seekp() functions for
performing the required task. 1
#include <fstream.h>
class Client
{
long Cno; char Name[20], Email[30] ;
public:
//Function to allow user to enter the Cno, Name,
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
text file “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” from a binary file “FLIGHT.DAT”. Assuming the
binary file is containing the objects of the following class. 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
example of Candidate Keys from a table containing some meaningful data. 2
(b) Consider the following tables STORE and SUPPLIERS
and answer (bl) and (b2) parts of this question:
Table: STORE
313
Table: SUPPLIERS
(b1) Write SQL commands for the following statements: 4
(i) To display details of all the items in the Store table in ascending order of
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) To display Minimum Rate of items for each Supplier individually as per
Scode from the table Store.
(b2) Give the output of the following SQL queries: 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.Scode AND ItemNo=2006;
(iv) SELECT MAX(LastBuy) FROM Store;
6. (a) Verify the following algebraically. 2
(A’+B’).(A +B)=A’.B+A.B’
(b) Write the equivalent Boolean Expression for the following Logic circuit: 2
314
(c) Write the POS form of a Boolean function H, which is represented in a truth
table as follows: 1
(d) Reduce the following Boolean Expression using K-Map : 3
F (U, V, W, Z) = Σ (3, 5, 7, 10, 11, 13, 15)
7. (a) What was the role of ARPANET in the Computer Network? 1
(b) Which of the following is not an unit for data transfer rate? 1
(i) bps
(ii) abps
(iii) gbps
(iv) kbps
(c) What is the difference between Trojan Horse and Virus in terms of computers? 1
(d) What term we use for a software/hardware device, which is used to block,
unauthorized access while permitting authorized communications. This term is
also used for a device or set of devices configured to permit, deny, encrypt,
decrypt, or proxy all (in and out) computer traffic between different security
domains based upon a set of rules and other criteria. 1
(e) “Learn Together” is an educational NGO. It is setting up its new campus at
Jabalpur for its webbased activities. The campus has 4 compounds as shown
in the diagram below: 4
315
Center to center distances between various Compounds as per architectural
drawings (in Metre) is as follows :
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) Suggest the placement of the following devices with justification :
316
(i) Repeater
(ii) Hub/Switch
(e4) The NGO is planning to connect its International office situated in
Mumbai, which out of the following wired communication link, you will
suggest for a very high speed connectivity?
(i) Telephone Analog Line
(ii) Optical Fiber
(iii) Ethernet Cable
(f) Write the full forms of the following: 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) Which C++ header file(s) will be essentially required to be included to run/
execute the following C++ code: 1
void main()
{
int Rno=24; char Name[] =”Amen Singhania”;
cout<<setw(lO)<<Rno<<setw(20)<<Name<<endl;
}
(c) Rewrite the following C++ program code after removing the syntax error(s)
(if any). Underline each correction. 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) Find the output of the following program: 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. the output of the following program: 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) The following code is from a game, which generates a set of 4 random numbers.Praful is playing this game, help him to identify the correct option(s) out of thefour choices given below as the possible set of such numbers generated fromthe 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,
give an example in C++ to illustrate both. 2
(b) Answer the questions (i) and (ii) after going through the following class: 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) Define a class STOCK in C++ with following description: 4
Private Members
� 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)
� Discount of type float (Discount percentage on the item)
� A member function FindDisc() to calculate discount as per the following
rule:
If Qty<=50 Discount is 0
If 50<Qty<=100 Discount is 5
If Qty>100 Discount is 10
Public Members
� A function Buy() to allow user to enter values for ICode, Item, Price,
Qty and call function FindDisc() to calculate the Discount.
322
� A function ShowAll( ) 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 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) Which type of inheritance out of the following is illustrated in the above
C++ code?
(a) Single Level Inheritance
(b) Multi Level Inheritance
(c) Multiple Inheritance
(ii) Write the names of data members, which are accessible by objects of
class type ShowRoom.
(iii) Write the names of all member functions which are accessible by objects
of class type ShowRoom.
(iv) Write the names of all members, which are accessible from member
functions of class Factory.
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
divisible by 5 and multiply other array elements by 2. 3
Sample Input Data of the array
Content of the array after calling REASSIGNO function
324
(b) An array T[90][100] is stored in the memory along the column with each of
the elements occupying 4 bytes. Find out the memory location for the element
T[10][40], if the Base Address of the array is 7200. 3
(c) Write a complete program in C++ to implement a dynamically allocated
Queue containing names of Cities. 4
(d) Write a function int ALTERSUM (int B[ ] [5], int N, int M in C++ to find
and return the sum of elements from all alternate elements of a two-dimensio-
nal array starting from B[0][0]. 2
Hint:
If the following is the content of the array
The function should add elements B[0][0], B[0][2], B[l][l], B[2][0] and
B[2][2].
(e) Evaluate the following postfix notation of expression: 2
(Show status of Stack after each operation)
True, False, NOT, OR, False, True, OR, AND
4. (a) Observe the program segment given below carefully and fill the blanks mar-
ked as Statement 1 and Statement 2 using tellg() and seekp() functions for
performing the required task. 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) mobilenumber
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 needsto be changed
cin>>Cnoc;
while (F.read((char*)& C,sizeof(C)))
{
if (Choc==C.GetCno())
{
C.Modify ();
//Statement 1
int Pos=_____________//To find the currentposition 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
destination is “Delhi” . from a binary file “TRAIN.DAT”. Assuming the binary
file is containing the objects of the following class. 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) What do you understand by Primary Key? Give a suitable example of Primary
Key from a table containing some meaningful data. 2
(b) Consider the following tables STOCK and DEALERS and answer (b1) and
(b2) parts of this question:
Table: STOCK
327
Table: DEALERS
(b1) Write SQL commands for the following statements: 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 display the details of those items whose dealer code (Dcode)
is 102 or Quantity in Stock (Qty) is more than 100 from the
table Stock.
(iv) To display Maximum UnitPrice of items for each dealer individually
as per Dcode from the table Stock.
(b2) Give the output of the following SQL queries: 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.Dcode AND ItemNo=5004;
(iv) SELECT MIN(StockDate) FROM Stock;
6. (a) Verify the following algebraically : 2
X’.Y + X.Y’ = (X’+Y’).(X+Y)
(b) Write the equivalent Boolean Expression for the following Logic Circuit: 2
328
(c) Write the SOP form of a Boolean function G, which is represented in a truth
table as follows: 1
(d) Reduce the following Boolean Expression using K-Map : 3
F(A,B,C,D)= Σ(3,4,5,6,7,13,15)
7. (a) What was the role of ARPANET in the Computer Network? 1
(b) Which of the following is not a unit for data transfer rate? 1
(i) mbps
(ii) kbps
(iii) sbps
(iv) gbps
(c) What is the difference between Virus and Worms in the computers? 1
(d) What term do we use for a software/hardware device, which is used to block
unauthorized access while permitting authorized communications? This term
is also used for a device or set of devices configured to permit, deny, encrypt,
decrypt, or proxy all (in and out) computer traffic between different security
domains based upon a set of rules and other criteria. 1
(e) “Vidya for All” is an educational NGO. It is setting up its new campus at
Jaipur for its web-based activities. The campus has four buildings as shown in
the diagram below: 4
329
Center to center distances between various buildings as per architectural
drawings (in meters) is as follows:
Expected Number of Computers in each Building is as follows:
(el) Suggest a cable layout of connections between the buildings.
(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) Suggest the placement of the following devices with justification:
(i) Repeater
(ii) Hub/Switch
330
(e4) The NGO is planning to connect its International office situated in Delhi.
Which out of the following wired communication links, will you suggest
for a very high speed connectivity ?
(i) Telephone Analog Line
(ii) Optical Fiber
(iii) Ethernet Cable
(f) Write the full forms of the following: 1
(f1) FTP
(f2) FSF
(g) Name any two common Web browsers. 1
331
Marking Scheme — Computer Science
General Instructions :
1. The answers given in the marking scheme are SUGGESTIVE, Examiners are requested to
award marks for all alternative correct Solutions / Answers conveying the similar meaning
2. All programming questions have to be answered with respect to C++ Language only.
3. In C++, ignore case sensitivity for identifiers
(Variable/Functions/Structures/Class Names)
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. In SQL related questions - semicolon should be ignored for terminating the SQL statements
7. In SQL related questions, ignore case sensitivity.
QUESTION PAPER CODE 91/1
EXPECTED ANSWERS
1. (a) What is the difference between automatic type conversion and type casting?
Also, give a suitable C++ code to illustrate both. 2
Ans. Automatic Type Conversion: it is an implicit process of conversion of a data
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 of Automatic Type Conversion andType Casting)
(½ Mark for each correct example of Automatic Type Conversion and TypeCasting)
OR
(Full 2 Marks for correct example(s) demonstrating the meaning of / differencebetween Automatic Type Conversion and Type Casting)
OR
(Only 1 Mack to be awarded if Explanation without supporting examples)
Note: Output is optional
(b) Which C++ header file(s) will be essentially required to be included to run/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) Rewrite the following c++ program code after removing the syntax error(s)
(if any). Underline each correction. 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) Find the output of the following program : 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) Find the output of the following program : 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) The following code is from a game, which generates a set of 4 random numbers.
Yallav is playing this game, help him to identify the correct option(s) out of the
four choices given below as the possible set of such numbers generated from
the 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:
Justification is as follows:
I POINT Number
Minimum Maximum
1 5 15 19
2 4 15 18
3 3 15 17
4 2 15 16
The only option that satisfies these values is option (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++to illustrate the same. 2
Ans. The process of using an -operator or a function in different ways for different
set of inputs given is known- as polymorphism. Function overloading is- an
example of polymorphism, where the functions having same name with different
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) Answer the questions (i) and (ii) after going through the following class: 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
Function Overloading
OR
Constructor Overloading
(1 Mark for naming the concept correctly)
(ii) What is Function 3 specifically referred as ? When do you think, Function 3will be invoked/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) Define a class ITEM in C++ with following description: 4
Private Members
� Code of type integer (Item Code)
� Iname of type string (Item Name)
� Price of type float (Price of each item)
341
� Qty of type integer (Quantity of item in stock)
� Offer of type float (Offer percentage on the item)
� A member function GetOffer() to calculate Offer percentage as per the
following rule:
If Qty<=50 Offer is 0
If 50<Qty<=100 Offer is 5
If Qty>100 Offer is 10
Public Members
� A function GetStock() to allow user to enter values for Code, Iname,
Price, Qty and call function GetOffer() to calculate the offer
� A function ShowItem() to allow user to view the content of all the data
members
Ans. class ITEM
{
int Code;
char Iname [20] ;
float Price;
int Qty;
float Offer;
void GetOffer() ;
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;
};
void ITEM: : 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) Answer the questions (i) to (iv) based on the following: 4
class Chairperson
{
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) Which type of inheritance out of the following is specifically is illustrated in
the above C++ code?
(a) Single Level Inheritance
(b) Multi Level Inheritance
(c) Multiple Inheritance
Ans. (c) Multiple Inheritance
(1 Mark for writing correct inheritance type)
(ii) Write the names of data members, which are accessible by objects of class
type Company.
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) Write the names of all members, which are accessible from member functions
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
divisible by 7 and multiply other-array elements by 3. 3
Sample Input Data of the array
Content of the array after Calling 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
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 7)
(½ Mark for correct else OR correct checking of non divisibility of array elements by 7)
(½ Mark for each correct assignment)
(b) An array P[50] [60] is stored in the memory along the column with each of the
element occupying 2 bytes, find out the memory location for the element P[10]
[20], if the Base Address 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 complete program in c++ to implement a dynamically allocated Stack
containing names of Countries. 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(int A[ ] [3], int N,int M) in C++ to find and
return the sum of elements from all alternate elements of a two-dimensional
array starting from A[0][0]. 2
Hint:
If the following is the content of the array
350
The function SKIPSUM() should add elements A[0][0], A[0][2], A[1][l],
A[2][0] and A[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
Any other correct equivalent function definition
(½ 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) Evaluate the following postfix notation of expression: 2
(Show status of Stack after each operation)
False, True, NOT, OR, True, False, AND, OR
Ans. Element Scanned 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) Observe the program segment given below carefully and fill the blanks mar-
ked as Statement 1 and Statement 2 using tellg() and seekp() functions for
performing the required task. 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. Statement 1:
F. tellg ();
Statement 2:
F. seekp(Pos-sizeof(C)) ;
OR
F.seekp(-sizeof(C), ios::cur);
OR
Any equivalent correct method
(½ Mark for each correct statement)
(b) Write a function in C++ to count the words “this” and “these” present in a
text file “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
Any other correct function definition
(½ 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” from a binary file “FLIGHT.DAT”. Assuming the
binary file is containing the objects of the following class. 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
Any other correct function definition
(½ 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
example of Candidate Keys from a table containing some meaningful data. 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) Write SQL commands for the following statements: 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) To display Minimum Rate of items for each Supplier individually as per Scode
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) Give the output of the following SQL queries: 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) Verify the following algebraically. 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
Any other valid algebraic verification
(2 Marks for verifying LHS = RHS OR RHS = LHS )
365
(b) Write the equivalent Boolean Expression for the following Logic circuit: 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
table as follows: 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) Reduce the following Boolean Expression using K-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 11
5113 9
W’ Z1
31
7115
111
W Z’ 2 6 14110
OR
W’Z’ W’Z WZ WZ’
U’V’ 0 11
3 2
U’V 41
51
7 6
U V 121
13115 14
U V’ 8 9111
110
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)
(½ Mark for writing final expression in reduced/minimal form)
7. (a) What was the role of ARPANET in the Computer Network? 1
Ans. The first computer network was jointly designed by The Advanced-Research
Projects Agency (ARPA) and Department of Defence (DoD) of United States
in 1969 and was called ARPANET. It was an experimental project, which
connected a few computers from some of the reputed universities of USA
and DoD. ARPANET allowed access to computer resource sharing projects.
This ARPANET was handed over to Defence Communication Agency (DCA)
for further development.
(1 Mark for mentioning that ARPANET was the first computer network)
OR
(½ Mark if only the expansion of ARPANET is mentioned)
367
(b) Which of the following is not an unit for data transfer rate? 1
(i) bps
(ii) abps
(iii) gbps
(iv) kbps
Ans. (ii)abps
(1 Mark for writing correct option)
(c) What is the difference between Trojan Horse and Virus in terms of computers? 1
Ans. TROJAN HORSE: “Malware” computer programs presented as useful orharmless in order to induce the user to install and run them.
VIRUS: Virus is a malicious program that damages data and files and causesharm to computer system.
(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,unauthorized access while permitting authorized communications. This term isalso used for a device or set of devices configured to permit, deny, encrypt,decrypt, or proxy all (in and out) computer traffic between different securitydomains based upon a set of rules and other criteria. 1
Ans. Firewall
(1 Mark for writing £orrect term)
(e) “Learn Together” is an educational NGO. It is setting up its new campus atJabalpur for its webbased activities. The campus has 4 compounds as shownin the diagram below: 4
368
Center to center distances between various Compounds as per architectural
drawings (in Metre) is as follows :
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. Training Compound as it contains maximum number of computers.
(½ Mark for mentioning the correct compound)
(½ Mark for correct justification)
OR
(1 Mark for any other location with a valid justification)
(e3) Suggest the placement of the following devices with justification : 1
(i) Repeater
(ii) Hub/Switch
Ans. (i) A Repeater should be placed when the distance between any two con-
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
Any diagrammatic representation with valid justification
(½ Mark for each correct placement of Devices with valid justifications)
(e4) The NGO is planning to connect its International office situated in Mumbai,
which out of the following wired communication link, you will suggest for
a very high speed connectivity? 1
(1 Mark for mentioning any valid connectivity or topology or diagram
connecting various compounds inside the campus)
370
(i) Telephone Analog Line
(ii) Optical Fiber
(iii) Ethernet Cable
Ans. (ii) Optical Fiber
(1 Mark for correct option /answer)
(f) Write the full forms of the following: 1
(f1) GNU
(f2) XML
Ans (f1) GNU’s not Unix
(f2) eXtensible Markup Language
(½ Mark for each full form)
(g) Write one advantage of each for Open Source Software and ProprietarySoftware. 1
Ans. An Open Source Software is freely and liberally licensed because of whichusers have right to study, change. and improve its design and source code.
A Proprietary Software has a copyright owner, who can restrict the user'scontrol over the software, its modification, or restrictions in publishing ofmodified or unmodified versions.
(½ Mark for writing correct advantage / definition for Open Source Software)
(½ Mark for writing correct advantage / definition for Proprietary Software)
QUESTION PAPER CODE 91
EXPECTED ANSWERS
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. Itdoes not make the changes In actual parameter If the changes are done Informal parameters.
Call by reference: The formal parameter Is an alias of actual parameter. Thechanges made In the formal parameter are reflected In actual parameter. It ispreceded 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) Which C++ header file(s) will be essentially required to be included to run/
execute the following C++ 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) Rewrite the following C++ program code after removing the syntax error(s)
(if any). Underline each correction. 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( ) orcin
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) Find the output of the following program: 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. the output of the following program: 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) The following code is from a game, which generates a set of 4 random numbers.Praful is playing this game, help him to identify the correct option(s) out of thefour choices given below as the possible set of such numbers generated from
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:
Justification is as follows:
377
I POINT Number
Minimum Maximum
1 5 25 29
2 4 25 28
3 3 25 27
4 2 25 26
The only option that satisfies these values is option (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,
give an example in C++ to illustrate both. 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
functions together in a single unit.
Data Hidina: Keeping the data in private/protected visibility mode of the class
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();
};
(½ Mark for each correct explanation of Data Encapsulation and Data Hiding)
(½ 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) Answer the questions (i) and (ii) after going through the following class: 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
Constructor Overloading
OR
Function Overloading
(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) Define a class STOCK in C++ with following description: 4
Private Members
� 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)
� Discount of type float (Discount percentage on the item)
� A member function FindDisc() to calculate discount as per the following
rule:
If Qty<=50 Discount is 0
If 50<Qty<=100 Discount is 5
If Qty>100 Discount is 10
Public Members
� A function Buy() to allow user to enter values for ICode, Item, Price,
Qty and call function FindDisc() to calculate the Discount.
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) Answer the questions (i) to (iv) based on the following: 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) Which type of inheritance out of the following is illustrated in the above C++
code?
(a) Single Level Inheritance
(b) Multi Level Inheritance
(c) Multiple Inheritance
Ans. (b) Multilevel Inheritance
(1 Mark for mentioning correct option)
383
(ii) Write the names of data members, which are accessible by objects of classtype ShowRoom.
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 ofclass 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) Write the names of all members, which are accessible from member functionsof 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 integersand its size as parameters and divide all those array elements by 5 which aredivisible by 5 and multiply other array elements by 2. 3
Sample Input Data of the array
Content of the array after calling REASSIGNO function
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 elements occupying 4 bytes. Find out the memory location for the element
T[10][40], if the Base Address 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
Queue containing names of Cities. 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 functionsfor 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 int ALTERSUM (int B[ ] [5], int N, int M in C++ to find
and return the sum of elements from all alternate elements of a two-dimensio-
nal array starting from B[0][0]. 2
Hint: If the following is the content of the array:
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-
mensional Arrays, but keeping in view of the Sample given for 3x3 array
the solution is acceptable.
(½ Mark for correct loops)
(1 Mark for finding Sum of alternate cells)
(½ Mark for returning the Sum)
(e) Evaluate the following postfix notation of expression: 2
(Show status of Stack after each operation)
392
True, False, NOT, OR, False, True, OR, AND
Ans. Element Scanned 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) Observe the program segment given below carefully and fill the blanks mar-
ked as Statement 1 and Statement 2 using tellg() and seekp() functions for
performing the required task. 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) mobilenumber 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 needsto be changed cin>>Cnoc;
while (F.read((char*)& C,sizeof(C)))
{
if (Choc==C.GetCno())
{
C.Modify ();
//Statement 1
int Pos=_____________//To find the currentposition 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-other correct function definition
(½ 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
destination is “Delhi” . from a binary file “TRAIN.DAT”. Assuming the binary
file is containing the objects of the following class. 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
Any other correct function definition
(½ 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) What do you understand by Primary Key? Give a suitable example of Primary
Key from a table containing some meaningful data. 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
PRIMARYKEY
400
Table: DEALERS
(b1) Write SQL commands for the following statements: 4
(i) To display details of all Items in the Stock table in ascending order ofStockDate.
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 tablewhose 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) To display the details of those items whose dealer code (Dcode) is 102or 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) To display Maximum UnitPrice of items for each dealer individually as
per Dcode from the table Stock.
Ans. SELECT Dcode, MAX (UnitPrice) FROM STOCK GROUP BY Dcode;
OR
Any other query that will give an equivalent output
(1 Mark for correct query)
(½ Mark for partially correct answer)
(b2) Give the output of the following SQL queries: 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.Dcode AND 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) Verify the following algebraically : 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) Write the equivalent Boolean Expression for the following Logic Circuit: 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 SOP form of a Boolean function G, which is represented in a truth
table as follows: 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) Reduce the following Boolean Expression using K-Map : 3
F (A,B,C,D) = Σ (3,4,5,6, 7,13,15)
Ans. A’B’ A’B AB AB’
C’ D’ 01
4 12 8
C’ D 11
5113 9
C D1
31
7113 11
C D 21
6 14 10
OR
C’D’ C’D CD CD’
A’B’ 0 11
3 2
A’B1
41
51
71
6
A B 121
13115 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 of ARPANET in the Computer Network? 1
Ans. The first computer network was jointly designed by The Advanced Research
Projects Agency (ARPA) and Department of Defence (DoD) of United States
in 1969 and was called ARPANET. It was an experimental project, which
connected a few computers from some of the reputed universities of USA
and DoD. ARPANET allowed access to computer resource sharing projects.
This ARPANET was handed over to Defence Communication Agency (DCA)
for further development.
(1 Mark for mentioning that ARPANET was the first computer network)
OR
(½ Mark if only the expansion of ARPANET is mentioned)
(b) Which of the following is not a unit for data transfer rate? 1
(i) mbps
(ii) kbps
(iii) sbps
(iv) gbps
Ans. (iii) sbps
(1 Mark for the correct option/answer)
(c) What is the difference between Virus and Worms in the computers? 1
Ans. Virus: Virus is a malicious program that damages data and files and causes
harm to computer system.
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) What term do we use for a software/hardware device, which is used to block
unauthorized access while permitting authorized communications? This term
is also used for a device or set of devices configured to permit, deny, encrypt,
decrypt, or proxy all (in and out) computer traffic between different security
domains based upon a set of rules and other criteria. 1
Ans. Firewall
(1 Mark for writing correct term)
(e) “Vidya for All” is an educational NGO. It is setting up its new campus at
Jaipur for its web-based activities. The campus has four buildings as shown in
the diagram below: 4
Center to center distances between various buildings as per architectural
drawings (in meters) is as follows:
Expected Number of Computers in each Building is as follows:
406
(el) Suggest a cable layout of connections between the buildings.
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. Training Building as it contains maximum number of computers.
(½ Mark for mentioning the building)
(½ Mark for correct justification)
OR
(1 Mark for any other location with a valid justification)
(e3) Suggest the placement of the following devices with justification:
(i) Repeater
(ii) Hub/Switch
Ans. (i) A Repeater should be placed when the distance between any
two connecting buildings exceeds 70 m.
407
(ii) Every building will need one Hub / Switch, to send signals to allof the workstations connected to it
OR
Any diagrammatic representation with valid justification
(½ Mark for correct placement of Repeater with justification)
(½ Mark for correct placement of Hub/Switch with justification)
(e4) The NGO is planning to connect its International office situated in Delhi.Which out of the following wired communication links, will you suggestfor a very high speed connectivity ?
(i) Telephone Analog Line
(ii) Optical Fiber
(iii) Ethernet Cable
Ans. (ii) Optical Fibre
(1 Mark for correct Option / Answer)
(f) Write the full forms of the following: 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. Internet explorer
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 Local Variable and Global Variable?
Also, give a suitable C++ code to illustrate both. 2
(b) Write the names of the header files, which is/are essentially required to run/execute the following C++ code:
void main ( )
{
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) Rewrite the following program after removing the syntactical errors (if any).Underline each correction. 2
#include[iostream.h]
315
typedef char Text(80) ;
void main ( )
{
Text T= "Indian";
int Count=strlen(T) ;
cout<<T<<'has'<<Count<< 'characters' <<end1;
}
(d) Find the output of the following program: 3
#inc1ude<iostream.h>
void ChangeArray(int Number, int ARR[ ], int Size)
{
for (int L =0; L<Size; L++)
if (L<Number)
ARR [L] +=L;
e1se
ARR [L] *=L;
}
void Show (int ARR [ ], int Size)
{
for (int L=0; L<Size; L++)
(L%2!=0) ?cout<<ARR[L] <<"#": cout<<ARR[L]<<end1 ;
}
void main ( )
{
int Array [ ] = {30, 20, 40, 10, 60, 50};
ChangeArray (3, Array, 6) ;
Show (Array, 6) ;
}
316
(e) Find the output of the following program: 2
#include<iostream.h>
void main ( )
{
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>
void main ( )
{
randomize ( ) ;
int Guess, 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) Differentiate between members, which are present within the private visibility
mode with those which are present within the public visibility modes. 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
illustrated by the function [I] to [IV]. 2
#include<iostream.h>
void Print ( ) // Function [I]
{
for (int K=1 ; K<=60 ; K++) cout<< "-" ;
cout<<end1 ;
}
void Print (int N) // Function [II]
{
for (int K=1 ; K<=N ; L++) cout<<"*" ;
cout<<end1 ;
}
void Print (int A, 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;
}
void main ( )
{
int U=9, V=4, W=3;
char C='@' ;
Print (C,V) ;
Print (U,W) ;
}
(c) Define a class Candidate in C++ with following description: 4
Private Members
� 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
� A member function AssignRem( ) to assign Remarks as per the Scoreobtained by a candidate. Score range and the respective Remarks areshown as follows:
Score Remarks
>=50 Selected
less than 50 Not selected
Public Members
� A function ENTER ( ) to allow user to enter values for RNo, Name,Score & call function AssignRem( ) to assign the remarks.
� A function DISPLAY ( ) to allow user to view the content of all the datamembers.
319
(d) Answer the questions (i) to (iv) based on the following: 4
class Strident
(
int Rno;
char Name [20] ;
float Marks;
protected:
void Result( ) ;
public:
Student( ) ;
void Register( ); void Display( ) ;
} ;
class Faculty
{
long FCode;
char FName[20];
protected:
float Pay;
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) Write the names of the all data members, which is/are accessible from
member function Commence of class Course.
(iii) Write the names of member functions, which are accessible from objects
of class Course.
(iv) Write the name of all the members, which are accessible from objects
of class Faculty.
3 (a) Write a Get1From2 ( ) function in C++ to transfer the content from two
arrays FIRST[ ] and SECOND[ ] to array ALL[ ]. The even places (0, 2, 4,
...) of array ALL[ ] should get the content from the array FIRST[ ] and odd
places (1, 3, 5, ) of the array ALL[] 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
The ALL[ ] array should contain
30, 10, 60, 50, 90, 80
(b) An array P[20] [50] is stored in the memory along the column with each of itselement occupying 4 bytes, find out the 1ocation of P[15][10], if P[0][0] is
stored at 5200. 3
(c) Write a function in C++ to perform Insert: operation on a dynamically allocated
Queue containing Passenger details as given in the following definition of
NODE. 4
321
struct NODE
{
long Pno; //passenger Number
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) Evaluate the following postfix notation of expression: 2
50, 60, + , 20, 10, -, *
4. (a) Observe the program segment given below carefully and fill the blanks marked
as Statement 1 and Statement 2 using seekg( ), seekp( ), tellp( ) and tellg( )
functions for performing the required task. 1
#include<fstream.h>
class PRODUCT
{
int Pno; char Pname[20); int Qty;
public :
void ModifyQty( ) ;
// The function is to modify quantity of a PRODUCT
} ;
void PRODUCT: :ModifyQty ( )
{
fstream File ;
Fil.open ("PRODUCT.DAT", ios::binary |ios : : in| ios: :out) ;
int MPno;
322
cout<<"Product No to modify quantity : "; cin>>MPNo;
While (Fil.read ((char*) this, sizeof (PRODUCT))
{
if (MPno == Pno)
{
Cout<<"Present Quantity:"<<Qty<<end1 ;
cout<<"Changed Quantity:";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 atext file "DIARY. TXT". 2
If the file "DIARY.TXT" content is as follows:
My first book was Me and My
family. It gave me chance to be
known to the world.
The output of the function should be
Count of Me/My in file : 4
(c) Write a function in C++ to search for a laptop from a binary file "LAPTOP.DAT"
containing the objects of class LAPTOP (as defined below). The user should
enter the Model No and the function should search and
display the details of the laptop. 3
class LAPTOP
{
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-tional algebra? 2
Consider the following tables WORKER and PAYYLEVEL and answer(b) and (c) parts of this question: 4
Table: WORKER
ECODE NAME DESIG PLEVEL DOJ DOB
11 Radhe Shyam 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 Ameen Ahmed 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) Write SQL commands for the following statements:
(i) To display the details of all WORKERs in descending order of DOB.
(ii) To display NAME and DE;SIG of those WORKERs, whose PLEVEL
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) To add a new row with the following:
19, 'Daya Kishore', 'Operator', 'P003', '19-Jun-2008', '11-Jun-1984'
(c) Give the output of the following SQL queries: 2
(i) SELECT COUNT (PLEVEL), PLEVEL FROM WORKER GROUP
BY PLEVEL;
(ii) SELECT MAX (DOB), MIN (DOJ) FROM WORKER;
(iii) SELECT Name, Pay FROM WORKER W, PAYLEVEL P
WHERE W. PLEVEL = S. PLEVEL AND P.ECODE<13 ;
(iv) SELECT PLEVEL, PAY+ALLOWANCE FROM PAYLEVEL
WHERE PLEVEL= 'P003' ;
6 (a) Verify the following using Truth Table. 2
U. (U' +V) = (U + V)
(b) Write the equivalent Boolean Expression for the following logic Circuit. 2
(c) Write the POS form of a Boolean function F, which is represented in a truth
table as follows: 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) Reduce the following Boolean Expression using K-Map: 3
F(P, Q, R, S) = Σ (0,1,2,4,5,6,8, 12)
7. (a) Differentiate between packet switching and message switching technique innetwork communication. 1
(b) Differentiate between BUS and STAR topology of networks. 1
(c) What is VoIP? 1
(d) Out of the following, identify client side script (s) and server side script(s). 1
(a) ASP (b) Javascript
(c) VBScript (d) JSP
(e) Quick learn University is setting up its Academic blocks at Prayag Nagar and
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 to Technology Block 80m
Law Block to HR Center 105m
Business Block to Technology Block 30m
Business Block to HR Center 35m
Technology Block to HR Center 15m
Number of Computers in each of the Blocks/Centre is follows:
Law Block 15
Technology Block 40
HR Center 115
Business Block 25
(e1 ) Suggest the most suitable place (i.e. Block/Center) to install the server of this
university with a suitable reason.
(e2) Suggest an ideal layout for connecting these blocks/centers for a wired con-
nectivity.
(e3) Which device you will suggest to be placed/installed in each of these blocks/
center to efficiently connect all the computers with in these blocks/center.
(e4) The university is planning to connect its admission office in the closest big city,
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) Which of the following will come under Cyber Crime? 1
(i) Theft of a brand new sealed pack Laptop
(ii) Access to a bank account for getting unauthorized Money Transaction
(iii) Modification in a company data with unauthorized access
(iv) Photocopying a printed report
(g) Compare open source software and proprietary software. 1
327
COMPUTER SCIENCE
QUESTION PAPER CODE 91
1. (a) What is the difference between Type Casting and Automatic Type conversion?
Also, give a suitable C++ code to illustrate both. 2
(b) Write the names of the header files, which is/are essentially required to run/
execute the following c++ code: 1
void main ( )
{
char CH,Text[ ] ="+ve Attitude";
for (int I=0 ; Text[I] ! ='\0' ;I++)
if (Text[I]== ' ')
cout<<end1;
else
{
CH=toupper (Text [I]) ;
cout<<CH;
}
}
(c) Rewrite the following program after removing the syntactical errors (if any).
Underline each correction. 2
include<iostream.h>
typedef char [80] String;
void main ( )
{
String S= "Peace";
int L=strlen(S) ;
cout<<S<< 'has'<<L<< 'characters'<<end1;
}
328
(d) Find the output of the following program: 3
#include <iostream.h>
void SwitchOver(int A [ ], int N, int Split)
{
for (int K=0 ; K<N; K++)
if (K<Split)
A(K]+ =K;
else
A [K]*=K;
}
void Display (int A [ ], int N)
{
for (int K=0 ; K<N ; K++)
(K%2==0)? cout<<A[K]<<"%":cout<<A(K]<<end1;
}
void main ( )
{
int H[ ]= {30,40,50,20,10,5};
SwitchOver (H, 6, 3);
Display (H, 6);
}
(e) Find the output of the following program: 2
#include<iostream.h>
void main ( )
{
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
outputs from the suggested Output Options (i) to (iv). Also, write the minimum
and maximum values, which can be assigned to the variable MyNum. 2
#include<iostream.h>
#include <stdlib.h>
void main ( )
{
randomize ( ) ;
int MyNum, 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) Differentiate between Constructor and Destructor function with respect to
Object Oriented Programming. 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
illustrated by the function [I] to [IV] 2
#include<iostream.h>
void Line ( ) //Function [I]
{
for (int L=1;L<=80;L++) cout<<"-";
cout<<end1;
}
void Line (int N) //Function[II]
{
for (int L=l;L<=N;L++) Cout<<"*";
cout<<endl;
}
void Line (char C, int N) //Function [III]
{
for (int L=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;
}
void main ( )
331
{
int A=9, B=4, C=3;
char K= '#' ;
Line (K,B);
Line (A,C);
}
(c) Define a class Applicant in C++ with following description: 4
Private Members
� A data member ANo (Admission Number) of type long
� A data member Name of type string
� A data member Agg (Aggregate Marks) of type float
� A data member Grade of type char
� A member function GradeMe() to find the Grade as per the Aggregate
Marks obtained by a student. Equivalent Aggregate Marks range and
the respective Grades are shown as follows:
Aggregate Marks Grade
>=80 A
less than 80 and >=65 B
less than 65 and >=50 C
less than 50 D
Public Members
� A function ENTER() to allow user to enter values for ANo, Name, Agg
& call function GradeMe() to find the Grade.
� A function_RESULT( ) 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 Student
{
332
int Rollno:
char SName[20];
float Marksl;
protected:
void Result ( ) ;
public:
Student ( ) ;
void Enroll ( ) ;void Display ( ) ;
} ;
class Teacher
{
long TCode;
char TName [20];
protected:
float Salary;
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) Write the names of all the data members, which is/are accessible from member
function Commence of class Course
(iii) Write the names of all the-members, which are accessible from objects of
class Teacher.
(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,...) of ALL[] and Even [] array
should contain the values from even positions (0, 2, 4,…..) of ALL []. 3
Example
If the ALL[] array contains
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 itselements occupying 8 bytes. Find out the location of G[10][15], if G[0][0] is
stored at 4200. 3
(c) Write a function in C++ to perform Delete operation on a dynamically allocated
Queue containing Members details as given in the following definition of NODE: 4
struct NODE
{
long Mno //Member Number
char Mname[20]; //Member Name
NODE *Link;
};
334
(d) Write a DSUMO function in C++ to find sum of Diagonal Elements from a
NxN Matrix. 2
(Assuming that the N is a odd number)
(e) Evaluate the following postfix notation of expression: 2
True, False, NOT, AND, True, True, AND,OR
4. (a) Observe the program segment given below carefully and fill the blanks marked
as Statement 1 and Statement 2 using seekg( ), seekp( ) tellp( ) and tellg( )
functions for performing the required task. 1
#include <fstream.h>
class ITEM
{
int Ino;char Iname[20]; float Price;
public:
void ModifyPrice() ;//The function is to modify
price of a particular ITEM
} ;
void item: :ModiyPrice()
{
fstream File;
File.open ("ITEM.DAT", ios::binary | ios::in | ios: :out) || ;
int CIno;
cout<<"Item No to modify price:";cin>>CIno;
while (file.read ((char*) this, sizeof (ITEM)))
{
if (CIno==Ino)
{
cout<<"Present Price:"<<Price<<end1;
cout<<"Changed price:"; 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 atext file "STORY. TXT". 2
If the file "STORY. TXT" content is as follows:
He is playing in the ground. She is
Playing with her dolls.
The output of the function should beCount of He/She in file: 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 definedbelow). The user should enter the Model No and the function should searchdisplay the details of the camera. 3
class CAMERA
{
long ModelNo;
float MegaPixel;
int Zoom;
char Details[120];
public:
void Enter ( ) {cin>>ModelNo>>MegaPixel>>Zoom;gets(Details);}
void Display ( )
{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 Abdul Ahmad 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 Nazar Ameen GM S02 11-Aug-2006 03-Mar-1984
108 Priyam Sen CEO S01 29-Dec-2004 19-Jan-1982
Table: SALGRADE
SGRADE SALARY HRA
S0l 56000 18000
S02 32000 12000
S03 24000 8000
(b) Write SQL commands for the following statements: 4
(i) To display the details of all EMPLOYEEs, in descending order of DOJ
(ii) To display NAME and DE51G of those EMPLOYEEs, whoseSALGRADE 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) To add a new row with the following:
109, 'Harish Roy', 'HEAD-IT', 'S02', '09-Sep-2007, '21-Apr-1983'
(c) Give :the output of the following SQL queries: 2
(i) SELECT COUNT (SGRADE), SGRADE FROM EMPLOYEE
GROUP BY SGRADE;
(ii) SELECT MIN(DOB), MAX (DOJ) FROM EMPLOYEE;
337
(iii) SELECT NAME , SALARY FROM EMPLOYEE E, SALGRADE
S WHERE E.SGRADE= S.SGRADE AND E.ECODE<103;
(iv) SELECT SGRADE, SALARY+HRA ET:)M SALGRADE WHERE
SGRADE='S02';
6 (a) Yerify the following using Truth Table: 2
X+Y. Z=(X+Y).(X+Z)
(b) Write the equivalent Boolean Expression for the following Logic Circuit: 2
(c) Write the SOP 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 1 1
1 0 0 0
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, 7, 8, 10)
7. (a) In networking, what-is WAN? How is it different from LAN? 1
(b) Differentiate between XML and HTML. 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 its Academic schools at Sunder Nagar
and planning to set up a network. The university has 3 academic schools and
one administration center as shown in the diagram below: 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 to Admin Center 115m
Business School to Technology School 40m
Business School to. Admin Center 45m
Technology School to Admin Center 25m
Number of Computers in each of the Schools/Center is follows:
Law School 25
Technology School 50
Admin Center 125
Business School 35
339
(i) Suggest the most suitable place (i.e. School/Center) to install the
server of this university with a suitable reason.
(ii) Suggest an ideal layout for connecting these schools/ center for a
wired connectivity.
(iii) Which device will you suggest to be placed/installed in each of these
schools / center to efficiently connect all the computers within these
schools / center?
(iv) The university is planning to connect its admission office in the closest
big city, which is more than 350 km from the university. Which type of
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. The answers given in the marking scheme are SUGGESTIVE, Examiners are requested to
award marks for all alternative correct Solutions / Answers conveying the similar meaning
2. All programming questions have to be answered with respect to C++ Language only.
3. In C++, ignore case sensitivity for identifiers
(Variable/Functions/Structures/Class Names)
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. In SQL related questions - semicolon should be ignored for terminating the SQL statements
7. In SQL related questions, ignore case sensitivity.
QUESTION PAPER CODE 91/1
EXPECTED ANSWERS
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
used within that function/scope.
Global Variables: Global variables are those variables which are not declared
within any function or scope. So, these variables can be accessed by any
function of the program.
Example
#include<iostream.h>
#include<conio.h.>
int G; // Global variable declared
341
void Fun ( )
{
int L = 25; // Local variable of function Fun ( ) assigned value 25
G=5; // Global Variable 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
}
void main ( )
{
Fun ( ) ; // Function call
G = G + 5; // Global variable is incremented by 5
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) Write the names of the header files, which is/are essentially required to run/execute the following C++ code:
void main ( )
{
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) Rewrite the following program after removing the syntactical errors (if any).Underline each correction. 2
#include[iostream.h]
typedef char Text(80) ;
void main ( )
{
Text T= "Indian";
int Count=strlen(T) ;
cout<<T<<'has'<<Count<< 'characters' <<end1;
}
Ans #include<iostream.h>
#include<string.h>
typedef char Text [80];
void main ( )
{
Text T= "Indian";
int Count=str1en(T);
cout<<T<< "has" <<Count<< "cbaracters"<<end1 ;
343
}
(½ Mark for writing # include<iostream.h>
(½ Mark for writing # include<string.h>
(½ Mark for writing typedef char Text(80];
(½ Mark for writing "has" and "characters")
(d) Find the output of the following program: 3
#inc1ude<iostream.h>
void ChangeArray(int Number, int ARR[ ], int Size)
{
for (int L =0; L<Size; L++)
if (L<Number)
ARR [L] +=L;
e1se
ARR [L] *=L;
}
void Show (int ARR [ ], int Size)
{
for (int L=0; L<Size; L++)
(L%2!=0) ?cout<<ARR[L] <<"#": cout<<ARR[L]<<end1 ;
}
void main ( )
{
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) Find the output of the following program: 2
#include<iostream.h>
void main ( )
{
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
(½ for writing each line of output correctly)
Note:
Deduct ½ Mark if any/all special characters are missing
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>
void main ( )
{
randomize ( ) ;
int Guess, 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
Highest value 53
(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) Differentiate between members, which are present within the private visibility
mode with those which are present within the public visibility modes. 2
Ans Private members of a class are accessible only to the member functions of the
same class.
Public members of a class are accessible to the member functions of the same
class as well as member functions of its derived class(es) and also to an object
of the class.
Example:
class Base
{
int N;
public:
void Assign ()
{
N=10;
}
};
class Derived: public Base
{
int X;
public:
void DisplayBase()
{
cout<<N; //Not Accessible
Assign ( ) ; //Accessible
}
} ;
void main ( )
347
{
Base B;
B.Assign( ) ; //Accessible
}
(1 Mark for correct explanation OR example illustrating non accessibility of
Private Members inside Derived class)
(1 Marie for correct explanation OR example illustrating accessibility of Public
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
illustrated by the function [I] to [IV]. 2
#include<iostream.h>
void Print ( ) // Function [I]
{
for (int K=1 ; K<=60 ; K++) cout<< "-" ;
cout<<end1 ;
}
void Print (int N) // Function [II]
{
for (int K=1 ; K<=N ; L++) cout<<"*" ;
cout<<end1 ;
}
void Print (int A, 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;
}
void main ( )
{
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
Function Overloading
(½ Mark for writing each correct line of output)
(1 Mark for writing the feature name correctly)
(c) Define a class Candidate in C++ with following description: 4
Private Members
� 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
� A member function AssignRem( ) to assign Remarks as per the Scoreobtained by a candidate. Score range and the respective Remarks areshown as follows:
Score Remarks
>=50 Selected
less than 50 Not selected
Public Members
� A function ENTER ( ) to allow user to enter values for RNo, Name,Score & call function AssignRem( ) to assign the remarks.
� A function DISPLAY ( ) to allow user to view the content of all the datamembers.
Ans class Candidate
{
long RNo;
char Name[20];
float Score;
char Remarks[20];
void AssignRem( ) ;
public:
void Enter( );
void Display( );
} ;
void Candidate: :AssignRem( )
{
if (Score>=50)
strcpy (Remarks,"Selected") ;
else
strcpy(Remarks,"Not Selected") ;
}
350
void Candidate: : Enter ( )
{
cin>>RNo ;
gets (Name) ; cin>>Score;
AssignRem( ) ;
}
void Candidate: :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) Answer the questions (i) to (iv) based on the following:
class Strident
(
int Rno;
char Name [20] ;
float Marks;
351
protected:
void Result( ) ;
public:
Student( ) ;
void Register( ); void Display( ) ;
} ;
class Faculty
{
long FCode;
char FName[20];
protected:
float Pay;
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 Multiple Inheritance
(1 Mark for correct answer)
(ii) Write the names of the all data members, which is/are accessible from
member function Commence of class Course.
Ans CCode, CourseName, StartDate, EndDate, Pay
(1 Mark for correct answer)
Note:
No marks to be awarded for any other alternative answer
(iii) Write the names of member functions, which are accessible from objects
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
of class Faculty.
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 array ALL[ ]. The even places (0, 2, 4,
...) of array ALL[ ] should get the content from the array FIRST[ ] and odd
places (1, 3, 5, ) of the array ALL[] 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
The ALL[ ] array should contain
30, 10, 60, 50, 90, 80
Ans void Get1From2 (int ALL[],int FIRST[],int SECOND[],
int N,int M)
{
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
void Get1From2(int ALL[],int FIRST[],int SECOND[],
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) An array P[20] [50] is stored in the memory along the column with each of itselement occupying 4 bytes, find out the 1ocation of P[15][10], if P[0][0] isstored at 5200. 3
Ans Assuminq LBR=LBC=0
B=5200
W=4 bytes
Number of Rows(N)=20
Number of Columns(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 substitutingformula 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) Write a function in C++ to perform Insert: operation on a dynamically allocated
Queue containing Passenger details as given in the following definition of
NODE. 4
struct NODE
{
long Pno; //passenger Number
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(int A[] [100], int N, int M)
{
int SUMC;
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) Evaluate the following postfix notation of expression: 2
50, 60, + , 20, 10, -, *
Ans Element Scanned 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) Observe the program segment given below carefully and fill the blanks marked
as Statement 1 and Statement 2 using seekg( ), seekp( ), tellp( ) and tellg( )
functions for performing the required task. 1
#include<fstream.h>
class PRODUCT
{
int Pno; char Pname[20); int Qty;
public :
:
void ModifyQty( ) ;
// The function is to modify quantity of a PRODUCT
} ;
void PRODUCT: :ModifyQty ( )
{
fstream File ;
Fil.open ("PRODUCT.DAT", ios::binary |ios : : in| ios: :out) ;
int MPno;
cout<<"Product No to modify quantity : "; cin>>MPNo;
While (Fil.read ((char*) this, sizeof (PRODUCT))
358
{
if (MPno == Pno)
{
Cout<<"Present Quantity:"<<Qty<<end1 ;
cout<<"Changed Quantity:";cin>>Qty ;
int Position = _______________; //Statement 1
_________________________; // Statement 2
Fil.write ((char*) this, sizeof (PRODUCT)) ;
//Re-writing the record
}
}
Fil.close ( ) ;
}
Ans Option 1
Statement 1: File. tellp ( ) ;
OR File.tellg ( ) ;
Statement 2: 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
Statement 1: File.tellp ( ) - sizeof (PRODUCT) ;
OR File.tellg ( ) - sizeof (PRODUCT) ;
Statement 2: 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 atext file "DIARY. TXT". 2
If the file "DIARY.TXT" content is as follows:
My first book was Me and My
family. It gave me chance to be
known to the world.
The output of the function should be
Count of Me/My in file : 4
Ans void COUNT ( )
{
ifstream Fil ("DIARY. TXT") ;
char STR [10] ;
int count = 0 ;
while (!Fil.eof ( ))
{
Fil>>STR;
if (strcmp (STR, "Me")==0 | | strcmp (STR, "My") ==0)
count++;
}
Cout<<"Count of Me/My in file : "<<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" containing the objects of class LAPTOP (as defined below).
The user should enter the Model No and the function should search and
display the details of the laptop. 3
class LAPTOP
{
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( )
{
LAPTOP L;
long modelnum;
cin>>modelnum;
ifstream fin;
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
void Search (long modelnum)
{
LAPTOP L;
ifstream fin;
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-tional algebra? 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
R1 and R2. The cardinality of R is product of cardinality of R1 and cardinality
of R2.
Example:
Relation: R1
Roll No Student Name Class
1 Akash XII
4 Debakar X
10 Rishi XI
Relation: R2
Teacher Code Teacher Name
102 Ms Rinee
309 Mr Tanmoy
Resultant: R = R1 × R2
Col1 Col2 Col3 Col4 Col5
1 Akash XII 102 Ms Rinee
1 Akash XII 309 Mr Tanmoy
4 Debakar X 102 Ms Rinee
4 Debakar X 309 Mr Tanmoy
10 Rishi XI 102 Ms Rinee
10 Rishi XI 309 Mr Tanmoy
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
sum of cardinality of R1 and cardinality of R2.
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
Column 1 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 PAYYLEVEL and answer(b) and (c) parts of this question: 4
Table: WORKER
ECODE NAME DESIG PLEVEL DOJ DOB
11 Radhe Shyam 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 Ameen Ahmed 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) Write SQL commands for the following statements:
(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) To display NAME and DE;SIG of those WORKERs, whose PLEVEL
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) To add a new row with the following:
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) Give the output of the following SQL queries: 2
(i) SELECT COUNT (PLEVEL), PLEVEL FROM WORKER GROUP
BY PLEVEL;
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. PLEVEL AND P.ECODE<13 ;
Name Pay
Radhe Shyam 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) Verify the following using Truth Table. 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
conveying the same meaning)
(b) Write the equivalent Boolean Expression for the following logic Circuit. 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
table as follows: 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) Reduce the following Boolean Expression using K-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) Differentiate between packet switching and message switching technique innetwork communication. 1
Ans Packet switching: In packet switching, a fixed size of data packet that can betransmitted across the network is specified and then the data packets are sentthrough switching stations to the final destination. All the packets are stored inthe main memory instead of disk. As a result accessing time of packets isreduced.
Message switching: The source computer sends data (message) to theswitching station, which stores data in a buffer. It then looks for a free link toanother switching station and sends data to that station. This process continuesuntil data is delivered to the destination computer. This type of switchingtechnique is also known as "store and forward" switching.
(½ Marks for written OR diagrammatic explanation of correct PacketSwitching)
(½ Marks for written OR diagrammatic explanation of correct MessageSwitching)
(b) Differentiate between BUS and STAR topology of networks. 1
Ans Bus Topology Star Topology
� Slower as compared to star � Expensive as compared to Bus
topologies of network topology
369
� Breakage of wire at any point � Long wire length
disturbs the entire network
(½ 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 Voice over Internet Protocol (Voice over IP, VoIP) is communication protocols
and transmission technologies for delivery of voice communications andmultimedia sessions over Internet Protocol (IP) networks, such as the Internet.
Also, we can say, VoIP are IP telephony, Internet telephony and broadbandtelephony.
(1 Mark for explaining VoIP)
Note: 1 Mark for writing full form of VoIP
(d) Out of the following, identify client side script (s) and server side script(s). 1
(a) ASP (b) Javascript
(c) VBScript (d) JSP
Ans Java script & VB script are client side scripts
JSP & ASP are server side scripts
(½ Mark for writing correct Client Side Scripts)
(½ Mark for writing correct Server Side Scripts)
(e) Quick learn University is setting up its Academic blocks at Prayag Nagar and
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 to Technology Block 80m
Law Block to HR Center 105m
Business Block to Technology Block 30m
Business Block to HR Center 35m
Technology Block to HR Center 15m
Number of Computers in each of the Blocks/Centre is follows:
Law Block 15
Technology Block 40
HR Center 115
Business Block 25
(e1 ) Suggest the most suitable place (i.e. Block/Center) to install the server of this
university with a suitable reason.
Ans HR center:
Reason as it has the maximum number of computers
OR
Business Block
Reason as it is closest to all other Centers (minimum cable length required)
(½ 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. Option 1:
Option 2:
(1 Mark for mentioning any valid connectivity or topology or diagram
connecting various compounds inside the campus)
(e3) Which device you will suggest to be placed/installed in each of these blocks/center to efficiently connect all the computers with in these blocks/center.
Ans Switch
(1 Mark for mentioning correct device)
Note:
(1 mark to be awarded if Switch / Hub is mentioned)
372
(e4) The university is planning to connect its admission office in the closest big city,which is more than 250 km from university, which type of network out ofLAN, 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) Which of the following will come under Cyber Crime? 1
(i) Theft of a brand new sealed pack Laptop
(ii) Access to a bank account for getting unauthorized Money Transaction
(iii) Modification in a company data with unauthorized access
(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 sourcecode (the form of the program when a programmer writes a program in aparticular programming language) is available to the general public for useand/or modification from its original design free of charge.
Proprietary software is software that is owned by an individual or a company(usually the one that developed it). There are almost always major restrictionson 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
EXPECTED ANSWERS
1. (a) What is the difference between Type Casting and Automatic Type conversion?
Also, give a suitable C++ code to illustrate both.
Ans Automatic Type Conversion: It is an implicit process of conversion of a data
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
int A=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 to run/
execute the following c++ code:
void main ( )
{
char CH,Text[ ] ="+ve Attitude";
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) Rewrite the following program after removing the syntactical errors (if any).
Underline each correction. 2
include<iostream.h>
typedef char [80] String;
void main ( )
{
String S= "Peace";
int L=strlen(S) ;
cout<<S<< 'has'<<L<< 'characters'<<end1;
}
Ans #include<string.h>
#include<iostream.h>
typedef char String [80];
void main ( )
{
String S = "Peace";
int L= 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) Find the output of the following program: 3
#include<iostream.h>
void SwitchOver(int A [ ], int N, int Split)
{
for (int K=0 ; K<N; K++)
if (K<Split)
A(K]+ =K;
else
A [K]*=K;
}
void Display (int A [ ], int N)
{
for (int K=0 ; K<N ; K++)
(K%2==0)? cout<<A[K]<<"%":cout<<A(K]<<end1;
}
void main ( )
{
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 ½ Mark if any/all '% t missing
Deduct ½ Mark if endl is not considered at the right positions
(e) Find the output of the following program: 2
#include<iostream.h>
void main ( )
{
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
outputs from the suggested Output Options (i) to (iv). Also, write the minimum
and maximum values, which can be assigned to the variable MyNum. 2
#include<iostream.h>
#include <stdlib.h>
void main ( )
{
randomize ( ) ;
int MyNum, 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*
Minimum value 20
Maximum value 24
(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) Differentiate between Constructor and Destructor function with respect to
Object Oriented Programming. 2
Ans Constructor Destructor
It is a special member function of class It is a special member function of class
with the following unique features: with the following unique features:
� 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.
� It is defined in public visibility mode � It is defined in public visibility mode
� It is automatically called and � It is automatically called and
executed at the time of executed when scope of an object
creation/declaration of the object gets over
� Constructor can be overloaded. � Moreover, destructor functions can
NOT be overloaded.
class Trial class Item
} {
int a,b; public:
public: Item ( )
Trial ( ) {a=0;b=0;}//Constructor {cout<<"Item Manufactured.."<<endl}
void Disp ( ) void Working ( )
{ {cout<<"Item is Working"<<endl;}
cout<<a<<b<<endl; ~Item( )//Destructor
} {cout<<"Item destroyed..."«end1}
} ; } ;
void main ( ) void main ( )
{ {
Trial T; //Constructor invoked Item I;
T . Disp ( ) ; I . Working ( ) ;
379
} for (int C=0; C<2; C++)
{
Item J;
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
illustrated by the function [I] to [IV] 2
#include<iostream.h>
void Line ( ) //Function [I]
{
for (int L=1;L<=80;L++) cout<<"-";
cout<<end1;
}
void Line (int N) //Function[II]
{
for (int L=l;L<=N;L++) Cout<<"*";
cout<<endl;
}
void Line (char C, int N) //Function [III]
{
for (int L=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;
}
void main ( )
{
int A=9, B=4, C=3;
char K= '#' ;
Line (K,B);
Line (A,C);
}
Ans ####
91827
Polymorphism OR Function Overloading
(½ Mark for writing each correct line of output)
(1 Mark for writing the feature. name correctly)
(c) Define a class Applicant in C++ with following description: 4
Private Members
� A data member ANo (Admission Number) of type long
� A data member Name of type string
� A data member Agg (Aggregate Marks) of type float
� A data member Grade of type char
� A member function GradeMe() to find the Grade as per the Aggregate
Marks obtained by a student. Equivalent Aggregate Marks range and
the respective Grades are shown as follows:
381
Aggregate Marks Grade
>=80 A
less than 80 and >=65 B
less than 65 and >=50 C
less than 50 D
Public Members
� A function ENTER() to allow user to enter values for ANo, Name, Agg
& call function GradeMe() to find the Grade.
� A function_RESULT( ) to allow user to view the content of all the data
members.
Ans class Applicant
{
long ANo;
char Name [20] ;
float Agg;
char Grade;
void Grademe ( ) ;
public:
void Enter ( ) ;
void Result ( ) ;
} ;
void Applicant: :GradeMe( )
{
if (Agg>=80)
Grade=' A' ;
else if(Agg>=65)
Grade=' B' ;
382
else if(Agg>=50)
Grade=' C' ;
else
Grade=' D' ;
}
void Applicant: :Enter ( )
{
cin>>ANo;
gets (Name) ;
cin>>Agg;
GradeMe() ;
}
void Applicant: :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) Answer the questions (i) to (iv) based on the following: 4
class Student
{
int Rollno:
char SName[20];
float Marksl;
protected:
void Result ( ) ;
public:
Student ( ) ;
void Enroll ( ) ;void Display ( ) ;
} ;
class Teacher
{
long TCode;
char TName [20];
protected:
float Salary;
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
Constructor functions to be ignored
ii) Write the names of all the data members, which is/are accessible from member
function Commence of class Course
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
class Teacher.
Ans Enter( ), Show( )
385
(1 Mark for correct answer)
Note:
No marks to be awarded for a partially correct answer
Constructor functions to be ignored
iv) Which type of Inheritance is illustrated in the above C++ code?
Ans Multiple Inheritance
(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,...) of ALL[] and Even [] array
should contain the values from even positions (0, 2, 4,…..) of ALL []. 3
Example
If the ALL[] array contains
12, 34, 56, 67, 89, 90
The Odd[] array should contain
34, 67, 90
And the Even [] array should contain
12,56,89
Ans voil Get2From1 (int All [],int Even [], int Odd [], int Size)
{
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 itselements occupying 8 bytes. Find out the location of G[10][15], if G[0][0] isstored at 4200. 3
Ans Assuming LBR=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
showing any formula/calculation.
(c) Write a function in C++ to perform Delete operation on a dynamically allocated
Queue containing Members details as given in the following definition of NODE: 4
struct NODE
{
long Mno //Member Number
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;
delete Temp;
if (Front==NULL) Rear=NULL;
}
else
cout<<"Underflow ! Queue is empty. .";
}
(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) Write a DSUMO function in C++ to find sum of Diagonal Elements from a
NxN Matrix. 2
(Assuming that the N is a odd number)
Ans void DSUM (int A [ ] [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] ;
}
389
cout<< " Sum of Diagonal Elements = "<<SUMR + SUML –
A[N/2] [N/2] ;
}
OR
void DSUM (int A[] [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<< "Sum of Right Diagonal Elements = "<<SUMR<<end1;
cout<< "Sum of Left Diagonal Elements = "<<SUML<<end1;
}
OR
void DSUM (int A[] [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) Evaluate the following postfix notation of expression: 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
Final Result: TRUE
(½ Mark for evaluating each operator correctly)
OR
(½ Mark only for writing TRUE as the final answer without showing
any calculation/Stack)
4. (a) Observe the program segment given below carefully and fill the blanks marked
as Statement 1 and Statement 2 using seekg( ), seekp( ) tellp( ) and tellg( )
functions for performing the required task. 1
391
#include <fstream.h>
class ITEM
{
int Ino;char Iname[20]; float Price;
public:
void ModifyPrice() ;//The function is to modify
price of a particular ITEM
} ;
void item: :ModiyPrice()
{
fstream File;
File.open ("ITEM.DAT", ios::binary | ios::in | ios: :out) || ;
int CIno;
cout<<"Item No to modify price:";cin>>CIno;
while (file.read ((char*) this, sizeof (ITEM)))
{
if (CIno==Ino)
{
cout<<"Present Price:"<<Price<<end1;
cout<<"Changed price:"; 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));
Ogtion 2
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
text file "STORY. TXT". 2
If the file "STORY. TXT" content is as follows:
He is playing in the ground. She is
Playing with her dolls.
The output of the function should be
Count of He/She in file: 2
Ans void COUNT ( )
{
ifstream Fil ("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<<"Count of He/She in file : "<<count<<end1;
Fil.close( ); //Ignore
}
OR
Any other correct function definition performing the desired operation
(½ 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: Ignore case sensitivity for He/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 definedbelow). The user should enter the Model No and the function should searchdisplay the details of the camera. 3
class CAMERA
{
long ModelNo;
float MegaPixel;
int Zoom;
char Details[120];
public:
void Enter ( ) {cin>>ModelNo>>MegaPixel>>Zoom;gets(Details);}
void Display ( )
{cout<<ModelNo<<MegaPixel<<Zoom<<Details<<endl;}
long GetModelNo ( ) {return ModelNo;}
};
394
Ans void Search ( )
{
CAMERA C;
long modelnum;
cin>>modelnum;
ifstream fin;
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
void Search (long modelnum)
{
CAMERA C;
ifstream fin;
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 Projection for selecting the columns of table
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 Abdul Ahmad 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 Nazar Ameen GM S02 11-Aug-2006 03-Mar-1984
108 Priyam Sen CEO S01 29-Dec-2004 19-Jan-1982
396
Table: SALGRADE
SGRADE SALARY HRA
S0l 56000 18000
S02 32000 12000
S03 24000 8000
(b) Write SQL commands for the following statements:
(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) To display NAME and DE51G of those EMPLOYEEs, whose 5ALGRADEis 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 inbetween'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) To add a new row with the following:
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 :the output of the following SQL queries: 2
(i) SELECT COUNT (SGRADE),SGRADE FROM EMPLOYEE GROUP
BY SGRADE;
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.SGRADE AND E.ECODE<103;
Ans Name Salary
Abdul Ahmad 24000
Ravi Chander 32000
(½ Mark for correct output)
(iv) SELECT SGRADE, SALARY+HRA ET:)M SALGRADE WHERE SGRADE=
'S02';
Ans SGRADE SALARY+HRA
S02 44000
(½ Mark for correct output)
6 (a) Yerify the following using Truth Table: 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) Write the equivalent Boolean Expression for the following Logic Circuit: 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 SOP 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 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) Reduce the following Boolean Expression using K-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
A B
A B' 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,
although it might be confined within the bounds of a state or country. A WAN
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
connected together, usually within the same building or campus.
(½ Marks for writing WAN correctly)
(½ Marks for writing LAN correctly)
401
(b) Differentiate between XML and HTML. 1
Ans The Extensible Markup Language (XML) was initially visualized as a language
for defining new document formats for the World Wide Web. XML is 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
structure of text-based information in a document by denoting certain text as
headings, paragraphs, lists, and to supplement that text with interactive forms,
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 facilitateparticipatory information sharing, interoperability, user-centered design,and collaboration on the World Wide Web. Web 2.0 is also used for
social networking. Example: Social Networking Sites, Blogs, Facebook,Video Sharing Sites, Video Conferencing Applications etc.
(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 & ASP are server side scripts
(½ Mark for writing correct 'Client Side Scripts)
( ½ Mark for writing correct Server Side Scripts)
(e) Great Studies University is setting up its Academic schools at Sunder Nagar
and planning to set up a network. The university has 3 academic schools and
one administration center as shown in the diagram below: 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 to Admin Center 115m
Business School to Technology School 40m
Business School to. Admin Center 45m
Technology School to Admin Center 25m
Number of Computers in each of the Schools/Center is follows:
Law School 25
Technology School 50
Admin Center 125
Business School 35
403
(i) Suggest the most suitable place (i.e. School/Center) to install the server of this
university with a suitable reason. 1
Ans Option 1 :
Admin center as it has the most number of computers
Option 2.
Business School as it will require minimum cable length to connect other blocks
(½ 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 Option 1:
Option 2:
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 /
center to efficiently connect all the computers within these schools / center? 1
Ans Switch
(1 Mark for mentioning correct device)
NOTE: Award 1 full mark if Hub/Switch is mentioned.
(iv) The university is planning to connect its admission office in the closest big city,
which is more than 350 km from the university. Which type of network out of
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/or modification from its original design free of charge.
Proprietary software is software that is owned by an individual or a company
(usually the one that developed it). There are almost always major restrictions
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
visits a Web site with cookie capabilities, its server sends certain information
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) Static Allocation of Objects 2 (1) 3 (1) 5 (2)
c) Dynamic Allocation 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 Boolean Algebra & 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 SourceConcepts
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-2010TIME : 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 Marks1 Review of C++ covered in Class XI 122 Object Oriented Programming in C++ 123 Data Structure & Pointers 144 Data File Handling in C++ 065 Databases and SQL 086 Boolean Algebra 087 Communication and Open Source Concepts 10
Total 70
B. Weightage to different forms of questions
S.No Forms of Questions Marks for No. of Totaleach question Questions Marks
1 Very Short Answer questions (VSA) 01 09 09
2 Short answer questions - Type I (SA I) 02 13 26
3 Short answer questions - Type II (SA II) 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 marks1 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, givea 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, whatwill 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, givea 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 getinvoked/called?
ii) In Object Oriented Programming, which concept is illustrated by Function 1 andFunction 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
• A function SCHEDULE() to allow user to enter values for TestCode,Description, NoCandidate & call function CALCNTR() to calculate the number ofCentres
• 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();
};
class AUTHOR : private BRANCH , public PUBLISHER
{
int Acode;
char Aname[20];
float Amount;
public:
AUTHOR();
void Start();
void Show();
};
(i) Write the names of data members, which are accessible from objects belong-ing to class AUTHOR.
(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 class AUTHOR.
(iv) How many bytes will be required by an object belonging to class AUTHOR?
3. (a) Write a function in C++ to merge the contents of two sorted arrays A & B intothird array C. Assuming array A and B are sorted in ascending order and theresultant 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 dynamicallyallocated 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 blanksmarked as Statement 1 and Statement 2 using seekp() and seekg() functionsfor 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 ScheduleNum Money Date
1001 Relay 100x4 Star Annex 16 10000 23-Jan-2004
1002 High jump Star Annex 10 12000 12-Dec-2003
1003 Shot Put Super Power 12 8000 14-Feb-2004
1005 Long Jump Star Annex 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 the Activities played in each of the Stadiumseparately.
(iii) To display the coach's name and ACodes in ascending order of ACode fromthe table COACH
(iv) To display the content of the Activity table whose ScheduleDate earlier than01/01/2004 in ascending order of ParticipantsNum.
(c) Give the output of the following SQL queries: 2
(i) SELECT COUNT(DISTINCT ParticipantsNum) FROM ACTIVITY;
(ii) SELECT MAX(ScheduleDate),MIN(ScheduleDate) FROM ACTIVITY;
(iii) SELECT Name,ActivityName FROM ACTIVITY A,COACH C
WHERE A.Acode=C.Acode AND A.ParticipantsNum=10;
(iv) SELECT DISTINCT Acode 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 asfollows: 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 Mangalorefor its office and web based activities. It has 4 blocks of buildings as shownin 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
Black A 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 organisationwith 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 regionwhere cable connection is not feasible, suggest an economic way to connect it withreasonably 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 withoutside 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 2known as Data Encapsulation. In a class, we wrap up the data and functions togetherin a single unit.
Data Hiding: Keeping the data in private visibility mode of the class to prevent it fromaccidental 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 4AUTHOR.
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, AmountMember function: Register(), Enter(), Display(), Haveit(), Giveit(), Start(), Show(),(1 Mark for correct answer)
(iv) 70(1 Mark for correct answer)
3. (a) void AddNSave(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++];elseif (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 withcorrect 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) SELECT Acodes, ActivityName FROM ACTIVITY ORDER BY Acode DESC; 4
(1 Mark for correct query)
OR(½ Mark for partially correct answer)
(ii) SELECT SUM(PrizeMoney), Stadium FROM ACTIVITY 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 * FROM ACTIVITY 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 1Switching, 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 IT Act 1
(1 Mark for correct answer)
d) An Internet Protocol (IP) address is a numerical identification and logical address 1that is assigned to devices connected in a computer network.
An IP Address is used to uniquely identify devices on the Internet and so one canquickly 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 wouldbe Block C, as this block contains the maximum number of computers, thusdecreasing the cabling cost for most of the computers as well as increasingthe 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 thatbetween B and C are quite large, so a repeater each, would ideally be neededalong their path to avoid loss of signals during the course of data flow in theseroutes.
For layout 2, since the distance between Blocks A and C is large so a repeater wouldideally 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, tointerconnect 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 useradio wave transmission, as they are easy to install, can travel long distances, andpenetrate buildings easily, so they are widely used for communication, both indoorsand outdoors. Radio waves also have the advantage of being omni directional, whichis they can travel in all the directions from the source, so that the transmitter andreceiver 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 1identical 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- 1pared to typical Proprietary Software. Proprietary Software typically favour visiblefeatures (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 butfavouring 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 softwarethat is admired by their peers. Highly prized factors are clean design, reliability andmaintainability, 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(int Arr[ ], int Count)
{
for (int C=1;C<Count;C++)
33
No. Questions Marks
Arr[C-1]+=Arr[C];
}
void main()
{
int A[]={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, whatmaximum 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 thesame. 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 purposeof 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 thefollowing 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
" A function SHOWINFO() 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 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 toclass CUSTOMER.
(ii) Write the names of all the member functions which are accessible from objectsbelonging to class SALESMAN.
(iii) Write the names of all the members which are accessible from member functions ofclass 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 Aand B by adding their corresponding elements as the formula A[i]+B[i]; wherevalue i varies from 0 to N-1 and transfer the resultant content in the third samesized array C. 3
(b) An array P[20][30] is stored in the memory along the column with each of theelement occupying 4 bytes, find out the Base Address of the array, if anelement P[2][20] is stored at the memory location 5000. 3
(c) Write a function in C++ to perform Push operation on a dynamically allocatedStack 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 markedas Statement 1 and Statement 2 using seekg() and tellg() functions forperforming 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 thefollowing 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 tothe end of file.
- To return total number ofbytes from the beginning offile 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) partsof this question:
Table: GAMES
GCode GameName Type Number Prize ScheduleMoney 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 Gcode1 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 than7000.
(iii) To display the content of the GAMES table in ascending order of ScheduleDate.
(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.Gcode AND 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 truthtable 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 andweb based activities. The company compound has 4 buildings as shown inthe 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 thesame city, which type of network out of LAN, MAN or WAN will be formed? Justifyyour 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 infunction 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()
{
int A=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 2using different set of inputs. Function overloading is one of the examples of polymor-phism, where more than one function carrying same name behave differently withdifferent 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 classAUTHOR.(1 Mark for correct answer)
(ii) Enter(), Show()(1 Mark for correct answer)
(iii) Data members: Voucher_No, Sales_Date, SalaryMember function:Sales_Entry(),Sales_Detail(),Enter(),Show(),Register(),Status()(1 Mark for correct answer)
(iv) 66(1 Mark for correct answer)
3. (a) void AddNSave(int A[ ],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, 3W=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 withcorrect 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. of Alphabets:"<<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) void Addnew() 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 2Primary Key. If a table has more than one such attributes which identify a tuple uniquelythan 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
112
13
15
114
17
13
54
No. Answers Marks
7.
a) Bandwidth is referred to the volume of information per unit of time that a transmission 1medium (like an Internet connection) can handle.
OR
The amount of data that can be transmitted in a fixed amount of time is known asbandwidth.
For digital devices, the bandwidth is usually expressed in bits per second(bps) orbytes per second. For analog devices, the bandwidth is expressed in cycles persecond, 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, 1you 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 processwhich can take quite some time), or for browser companies to adopt each other'sstandards (yeah right!), with XML, you can create your own set of tags at your ownpace.
(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 ofdevices configured to permit, deny, encrypt, decrypt, or proxy all (in and out) computertraffic between different security domains based upon a set of rules and other criteria.
(1 Mark for writing appropriate explanation)
d) A Uniform Resource Locator (URL) is used to specify, where an identified resource 1is available in the network and the mechanism for retrieving it. A URL is also referredto 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 RajBuilding, as this block contains the maximum number of computers, thus decreasingthe cabling cost for most of the computers as well as increasing the efficiency of themaximum 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, tointerconnect 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 (Metropolitan Area 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 1ware that is available for use at no cost or for an optional fee. Freeware is generallyproprietary 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 thesoftware.
Shareware is usually offered as a trial version with certain features only available afterthe license is purchased, or as a full version, but for a trial period. Once the trial periodhas passed the program may stop running until a license is purchased. Shareware isoften offered without support, updates, or help menus, which only become availablewith the purchase of a license. The words "free trial" or "trial version" are indicative ofshareware.
(1 Mark for appropriate difference)
g) A Trojan horse is a term used to describe malware that appears, to the user, to per 1form a desirable function but, in fact, facilitates unauthorized access to the user'scomputer system
A computer worm is a self-replicating computer program. It uses a network to sendcopies of itself to other nodes (computers on the network) and it may do so without anyuser intervention.
(1 Mark for appropriate difference)