You are on page 1of 9

HYCOMSET1QP1215

26/11/15

HALF YEARLY EXAMINATION (2015-16)


Subject: Computer Science
Grade: XII

Max. Marks: 70
Time: 3 hrs

General Instructions:
This question paper consists of 9 printed pages.
All answers to be written in the answer sheet provided.
Programming Language to be used is C++.
I.

a. What is the function of #define in C++? Explain with an example.

b. Observe the following C++ code and write the header files, which are essentially
required to run the program code.

void main()
{
char msg;
msg=getchar();
cout<<setw(5)<<tolower(msg);
}
c. Observe the following C++ code carefully and rewrite the same after removing
all the syntax error(s) . Ensure that you underline each correction.
(Assume that all the desired header files are already included.)

void simplify(int M , Num[])


{
for(int i=0;i<M;i++)
cout<<Num[i]<<" ";
}
void main()
{
typedef sal int;
sal Max = 5;
int No[Max]={10,20,30,40,50};
simplify(Max , No[]);
}
d. Observe the following C++ code carefully and obtain the output, which will
Page 1 of 9

appear on the screen after execution of it. (Assume that all the desired header files
are already included.)
void decrypt(char *Str)
{
int C , L= strlen(Str);
for (C=0;C<=L-2;C++)
if(!isalnum(*(Str+C)))
*(Str+C)= *(Str+C-1);
else if(isdigit(*(Str+C)))
*(Str+C)= *(Str+C)+5;
else if(isupper(*(Str+ C)))
*(Str + C)=*(Str+ L-C-1);
else
*(Str+C)= *(Str + C);
*(Str+C+1)= *(Str+C+1);
}
void main()
{
char *secret="Vr@No3@BeST";
decrypt(secret);
puts("The code is");
puts(secret);
}
e.

Observe the following C++ code carefully and obtain the output, which will
appear on the screen after execution of it. (Assume that all the desired header files
are already included.)

int W = 3;
void calculus(int x, int &y, char *z)
{
W += x+y;
x = W+y;
y += x;
z = z+3;
cout<<x<<'*'<<y<<'\n'<<z<<'*'<<W<<endl;
}
void main()
{
int W = 2, b = 5;
char *txt="MoToR ShoW";
calculus(W,::W,txt);
cout<<*txt<<'*'<<W;
}
f. Based on the following C++ code, find out the expected correct output(s) from
Page 2 of 9

the options (i) to (iv). Justify your answer.(Assume that all the desired header files
are already included.)
void main()
{
char msg[] = "HY EXAMS";
int marks[]= {85,72,67,45,93};
randomize();
cout<<marks[random(3)]-5;
for(int i=0;i<4;i++)
cout<<msg[sizeof(long)+random(2)+1];
}
Options:i) 62MAMA
ii) 80XMAM
iii) 62EXAA
iv) 68MMMM
II. a.

Differentiate between Abstract class and Concrete class with examples.

b. Answer the questions (i) and (ii) after going through the following class:-

2
2

class Syllabus
{
char ChapterName[20];
int Marks;
public:
Syllabus(char *cname, int ma)
//Member Function 1
{
strcpy (Chapter,Data Structures);
Marks = 14;
cout<<Chapter Initialised;
}
~Syllabus( )
//Member Function 2
{
cout<<Chapter Over;
}
};
i) Write statements to invoke Function 1 implicitly and explicitly.
ii) What is Function 2 and when does it get invoked.
c. Define a class Technovanza in C++ with the following specification:
Data Members:
Scode to store School code
Cname to store name of Comptt
Page 3 of 9

Group to store group name


Teamsize to store Teamsize
Member Functions:
A constructor function to initialize Scode as Sc01 ,Cname as Lets Quiz and Team
size as 4.
A function AllocateGroup() to assign group based on the following criteria:
Cname
Group
Collage Making
Graphic Designing
Web Creation
Web Designing
Code coding
Programming
Lets Quiz
Quizzing
A function Collect() to allow user to enter values for the data members. Also, this
function should call AllocateGroup() to allocate Group for each school..
A function Display() to display the content of all the data members on screen.
d. Consider the following C++ code and answer the questions from (i) to(iv):
class professor
{
int profcode;
char profname[20];
protected:
char dept[20];
char date_join[12];
public:
void enterdetails();
void printdetails();
};
class permanent: professor
{
float salary;
float allowance;
float net_salary;
protected:
void calc_net();
public:
void getdetails();
void putdetails();
};
class temporary : protected permanent
{
float wages;
protected:
int bonus;
Page 4 of 9

void calc_net();
public:
void enter();
void display();
};
i) Which type of Inheritance is shown in the above example.
ii) Write the names of member functions, which can be directly accessed from
the objects of class temporary.
iii) Write the names of data members, which can be accessed from getdetails()
function of class permanent.
iv) What is the size of class temporary.
III. a.

Write a function shift() which accepts a 1-D array A[] ,search element S and its size
N as parameter. Search for a particular element and perform the following
operations:
i)
Remove all occurrences of the search element.
ii)
Shift the elements of the array to the right so that used space is available
at the left end.

b. An array CA[10][12] is stored in the memory along the column with each element
occupying 4 bytes. Find the address of the element CA[2][10] if element CA[2][3] is
stored at the address 4500.

c. Write a function unitmatrix() which accepts a 2-D array (square matrix) and its size
as parameters and checks if the matrix is a unit matrix or not.
(A unit matrix is a square matrix with 1s on the major diagonal and 0s elsewhere.)

d. Convert the following infix expression to postfix showing the stack status.
(U-V)+W/X^Y*(Z/H)

e. Write stand-alone functions LQInsert() and LQDisplay() in C++ to perform insert


and display operation on a Linked Queue, whose structure is shown below:-

struct vehicle
{
int vehno;
char vehname[20];
char vehmake;
vehicle *link;
};
vehicle *front=NULL , *rear=NULL;
IV. a.

Observe the program given and fill the blanks marked as Statement 1 and 2 .
Page 5 of 9

class vaccine
{
int vaccno;
char vaccname[20];
float dosageamt;
public:
void getnewdetails(); // Function to accept new vaccine details.
void administer(); // Function to modify the details of particular vaccine no.
};
void vaccine::administer()
{
fstream f1;
f1.open(Medical.dat, ios::binary|ios::ate) ;
int vacn;
cout<<Enter vaccine no :;
cin>>vacn;
getnewdetails();
__________________________________________________; //Statement 1
__________________________________________________; //Statement 2
f1.close();
}
b. Write a function count() to count the number palindromes present in a text file
Story.txt. (Standard library functions can be used.)
Ex) "This is my mom and dad ." No of palindromes is 2

c. Observe the class Metal declared below:-

class Metal
{
char Mname[20];
char Mtype[20];
float Mprice;
public:
void getmetal();
void putmetal();
char *returntype()
{
return type;
}
}m1;
i) Write a function in C++ to read the objects of Metal from binary file Metal.dat
and display metal details, which are of corrosive type.
ii) Write a function to insert a new record after the 3rd record.
V. a. Differentiate between Primary Key and Alternate Key stating examples.
Page 6 of 9

b. Observe the tables given below:-

RELATION : FURNITURE
No
C001
F005
T008
F002
T003

Itemname
White Lotus
Dolphin
Comfort Zone
Royal Tiger
Pink feather

Type
Double Bed
Baby Cot
Double Bed
Sofa
Baby Cot

DateofStock
23/02/02
20/01/02
12/01/02
13/12/01
04/02/02

Price
30000
700
25000
31000
1100

Discount
25
20
15
25
10

RELATION : ARRIVALS
No
Location
T008
Sharjah
C001
Dubai
F005
Dubai
Write SQL commands for questions i) to iv) and state o/p for questions v) to viii):i) To list itemname and type of items from furniture table in which DateofStock is
before 22/01/02 in descending order of itemname.
ii) To count the items whose price is > 25000 and item name starts with D.
iii) To display the type and the maximum price in each type.
iv) To list the itemname and location to where the item has to be delivered.
v) SELECT MIN(Discount) FROM FURNITURE;
vi) SELECT SUM(Price) FROM FURNITURE WHERE Type IN (Sofa,Baby
Cot);
vii) SELECT COUNT(DISTINCT Type) FROM FURNITURE;
viii) SELECT No , Itemname , Price FROM FURNITURE WHERE Price
BETWEEN 25000 AND 30000 .
VI. a.

i) Find the complement of (XY)+(X+Y)

ii) Find the dual of (A.B+1)(A+1.A)


b. Obtain the Boolean expression for the logic circuit shown below:-

Page 7 of 9

c. Write the SOP form of the function F(A,B,C) for the following truth table :A
0
0
0
0
1
1
1
1

B
0
0
1
1
0
0
1
1

C
0
1
0
1
0
1
0
1

F(A,B,C)
1
0
0
1
1
0
1
0

d. Obtain the minimal form for the following Boolean expression using K-Map.
F(U,V,W,Z) = (0,2,3,4,5,6,8,10,11,12,13,14)
VII. a. State any 2 advantages of networking.

3
1

b. Differentiate between bridge and switch.

c.

Differentiate between RJ45 and RJ11.

d. Define the terms:i) Interspace


ii) Bandwidth

e. State 2 advantages of fiber optic cables.

f. HP Solutions is setting up its Academic schools at Bangalore and planning to set up


a network. The university has 3 academic schools and one administration center as
shown in the diagram below:

Center to center distances between various buildings is as follows :


Page 8 of 9

Law School to Business School


Law School to Technology School
Law School to Admin Center
Business School to Technology School
Business School to Admin Center
Technology School to Admin Center

60m
90m
115m
40m
45m
25m

Number of Computers in each of the Schools/Center is follows:


Law School
25
Technology School
50
Admin Center
125
Business School
35
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 using a wire
connectivity.
iii) The university is planning to connect its Admin center to the closest 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.
iv) Suggest an efficient device from the following to be installed in each of the blocks
to connect all the computers:
(A) MODEM
(B) SWITCH
(C) GATEWAY

***************

Page 9 of 9

You might also like