Kendriya Vidyalaya Sangathan, Jaipur Region

Pre-Board Examination (2017-18)

Class : XII

Subject :Computer Science(083)

General Instructions:

·  All questions are compulsory.

·  Programming language C++.

Time allowed: 3 hours Maximum Marks: 70

Q.No. / QUESTIONS / Marks
1.
(a) / What do you mean by function prototype? Write down any two advantages of function prototypes in C++. / 2
(b) / Name the header file(s), which are essentially required to run the following program segment:
void main ( )
{
char String[20];
gets (String);
for(int i=0; String[i]!=’\0’; i++)
String = toupper[i];
puts(String);
} / 1
(c) / Observe the following C++ code carefully and rewrite the same after removing all the syntax error(s) present in the code. Ensure that you underline each correction in the code.
Important Note:
Ø  Correction should not change the logic of the programme.
# include (iostream.h)
void main( )
{
int A, B;
cin>A;
for( B=0 ; B < 10 , B++)
if A = = B
cout < B + A;
else
cout > B;
} / 2
(d) / Observe the following C++ code carefully and obtain the output, which will appear on the screen after execution of it.
Important Note:
Ø  All the desired header files are already included in the code, which are required to run the code.
#include <iostream.h
#include <stdlib.h
int main( )
{ int arr[ ] = { 12, 23, 34, 45}
int *ptr = arr;
int val = *ptr; coutvalendl;
val = *ptr++; coutval <endl;
val = *ptr; cout< val < endl;
val = *++ptr; coutvalendl;
val = ++*ptr; coutvolendl;
return 0;
} / 2
(e) / Write the output of the following programme:
#include<iostream.h
#include<conio.h
int global=10;
void func(int &x, int y)
{
x=x-y;
y=x*10;
cout<x<’,’<y<’\n’;
}
void main()
{
int global=7;
func(:: global, global);
cout<global<’,’<::global<’\n’;
func(global,::global);
cout<global<’,’<::global<’\n’;
} / 3
(f) / Go through the C++ code shown below, and find out the possible output(s) from the options (i) to (iv). Also write the least value and highest value, which can be assigned to the variable Guess.
#include<iostream.h
#include<stdlib.h
void main( )
{
randomize( );
int Guess, Max = 5;
Guess = 20 + random (Max);
for (int N = Guess; N<=25; N++)
cout < N < “*”;
}
(i). 20*21*22*23*24*25 (ii). 21*22*23*24*25
(iii). 23*24* (iv). 22*23*24*25* / 2
2.
(a) / What is Polymorphism? Give an example in C++ to show its implementation in C++. / 2
(b) / Answer the question (i) and (ii) after going through the following class:
class workshop
{
int duration; // in hours
public:
workshop( ) // Function 1
{
duration = 6;
cout<Inaugural Function”<endl;
}
~workshop( ) // Function 2
{
cout<” Valedictory Function”< endl;
void session(int s = 1) // Function 3
{
cout<”session”< s < “is on” < endl;
}
workshop (int time) // function 4
{
duration = time;
cout < Inaugural Function”<endl;
}
};
i). In object oriented programming, what is function 2 referred to
as and when does it get invoked/called?
ii). In object oriented programming, which concept is illustrated by
Function 1 and Function 4? Write an example illustrating the
calls for these two functions. / 2
(c) / Define a class SPENCER in C++ with the following description:
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 00%
if 50 < Qty <= 100 Discount is 05%
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.
·  A Function ShowAll ( ) to allow user to view the content of all the data member. / 4
(d) / Consider the following C++ code and answer the questions from (i) to (iv):
class coach
{
char cno[5], cname[20], specialization[10];
int days;
protected:
float remuneration;
void assignRem(float);
public:
coach( );
void cEntry( ) ;
void cDisplay( );
};
class player
{
char regNo[10], pName[20], sport[10];
protected:
int attendance, grade;
public:
player( );
void pEntry( );
void pDisplay( );
};
class institute : public player, public coach
{
char icode[10], iname[20];
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 the objects of class institute from the following
cEntry( )
pDisplay( )
iEntry( )
iii). Write the names of all the member(s) accessible from member
function of class institute.
iv). If class Institute was derived privately from class player and
privately from class coach, than, name the member function(s)
that could be accessed through object of class Institute. / 4
3.
(a) / Write a programme in C++ which perform the following task:
Ø  Initialize an integer array of 10 elements in main( )
Ø  Pass the entire array to a function modify( ) and define the modify( ) function to multiply each element of array by 3.
Ø  Return the control to main( ) and print the new array elements in main( ). / 3
(b) / An array P[20][30] is stored in the main memory along the column with each of the element occupying 6 bytes, find out the base address of the array if an element P[2][20] is stored at the memory location 5000. / 3
(c) / Write a user defined function to store and print the elements of a unit matrix.
(note: The unit matrix is the matrix whose left diagonal elements are 1 and rest of the elements are 0) / 2
(d) / Obtain the postfix notation for the following infix notation of expression showing the content of the stack and postfix expression formed after each step of conversion:
A / B + (C – D * F) / 2
(e) / Define a member function queins( ) to insert nodes and quedel( ) to delete nodes, of the linked list implemented class queue, where each node has the following structure:
struct movie
{
int seatNo;
char name[20];
movie *Next;
};
class queue
{
movie *rear, *front;
public:
queue( ) { rear = NULL; front = NULL; }
void queins( );
void quedel( );
}; / 4
4.
(a) / Observe the programme segment given below carefully and fill the blanks marked as statement 1 and statement 2 using seekg( ), seekp( ), tellp( ) and tellg( ) function for performing the required task.
#include<fstream.h
class BUS
{ int tno, char pname[20]; float amount;
public:
.
.
void modifyamt( )
};
void BUS : : modifyamt( )
{
fstream file;
file.open(“BUS.dat, ios::binary|ios::in|ios::out);
int Pno;
cout< “Ticket no to modify amount :”;
cinPno;
while(file.read( (char*) this, sizeof(BUS)))
{ if( Pno = = tno)
{
cout< “Present Amount :” < amount < endl;
cout< “Changed Amount :” < cin> amount;
int filePos = ______// Statement 1
______// Statement 2
File.write( ( char*) this, sizeof(BUS)); // rewriting the record
}
}
file.close( ):
} / 1
(b) / Write a function to carry out the following :
(i). To read the text file INPUT.TXT
(ii). Print each word in reverse order
Note: Assume that each word length is maximum of 10 characters and each word is separated by newline/blank character.
For example:
INPUT : INDIA IS MY COUNTRY
OUTPUT : AIDNI SI YM YRTNUOC / 2
(c) / Write a function in C++ to search for a computer from a binary file “COMPUTER.DAT” containing the objects of class COMPUTER (as defined below). The user should enter the model no and the function should search and display the details of the computer.
class COMPUTER
{
long ModelNo;
float RAM, HDD;
char Details[120];
public:
void stockenter( )
{ cinModelNo>RAM>HDD; gets(Details);}
void stockdisplay( )
{ cout< ModelNo<RAM<Details<endl; }
long return getModelNo( ) { return ModelNo;}
}; / 3
5.
(a) / What is Data Independence? Explain each level of data independence. / 2
Consider the following tables Consignor and Consignee. Write SQL commands for the statements (i) to (iv) and give outputs for SQL Queries (v) to (viii).
TABLE : CONSIGNOR
CnorID / 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 / 21-K, Westend / Mumbai
TABLE: CONSIGNEE
CneeID / CnorID / 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
b / i). To display the name of all Consignors from Mumbai.
iii). To display the CneeID, 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. / 4
c / v). SELECT DISTINCT CneeCity form Consignee
vi). Select A.consignor , B.CneeName from Consignor A, Consignee B
WHERE A.CnorID = B.CnorID AND B.CneeCity = ‘Mumbai’ ;
vii). SELECT CneeName, CneeAddress from Consignee
WHERE CneeCity NOT IN (‘Mumbai’ , ‘Kolkata’);
viii). SELECT CneeID, CneeName from Consignee
WHERE CnorID = ‘MU15’ OR CnorID = ‘ND01’ ; / 2
6.
(a) / State and prove the De Morgan’s Theorem (any one) Algebraically. / 2
(b) / Draw Logic circuit diagram for the following:
x y + x ȳ + x̄ z / 2
(c) / Write the Product of Sum form of Boolean function H( X, Y, Z), for the following truth table representation of H.
X / Y / Z / H
0 / 0 / 0 / 1
0 / 0 / 1 / 0
0 / 1 / 0 / 1
0 / 1 / 1 / 1
1 / 0 / 0 / 1
1 / 0 / 1 / 0
1 / 1 / 0 / 0
1 / 1 / 1 / 1
/ 1
(d) / Obtain a simplified form of the following Boolean expression using Karnaugh’s Map.
F(U,V,W,Z) = Π(0,1,3,5,6,7,10,14,15) / 3
7.
(a) / Arrange the following Communication channels in ascending order of their data transmission rates.
Ethernet cable, Optical Fiber, Telephone cable, Co-axial cable / 1
(b) / Which cable connectors are used to connect a cable from router’s console a PC? / 1
(c) / ABC industries are setting up a secured network for their office campus at Delhi for their day to day office and web based activities. They are planning to have connectivity between 3 buildings and the head office situated in Mumbai. Answer the questions (i) to (iv) after going through the building positions in the campus and other details, which are given below:

Distance between various buildings:
Building GAS to Building Petroleum / 125 m
Building GAS to Building Administration / 60 m
Building Administration to Building Petroleum / 65m
Delhi to Head Office Mumbai / 1500km
Number of Computers:
Building GAS / 25
Building Petroleum / 150
Building Administration / 51
Head Office / 10
/ 4
i). Suggest the most suitable place (Building) to house the server
of this industry.
ii). Suggest the cable layout connections between the building
inside the Delhi campus.
iii). Suggest the placement of the following devices with
justification: (a). Switch (b). Repeater
iv). The industry is planning to provide high speed link with its head
office situated in Mumbai using a wired connection. Which of
the following cables will be most suitable for this job.
(a)  Optical Fiber (b) Co-axial cable (c) Ethernet cable
(d) / Differentiate between Open source software and freeware. / 1
(e) / What are cookies? / 1
(f) / How can you protect your mailbox from spams? / 1
(g) / Write the name of one client-side and one server side script. / 1