KENDRIYA VIDYALAYA SANGATHAN RO GURGAON

COMPUTER SCIENCE (083)

FIRST PRE BOARD

CLASS : XII MAX. MARKS: 70 TIME: 3:00 Hrs

1 / (A) / What is Global & Local variable? Explain with Example. / 2
(B) / Observe the following code and write the name(s) of the header files essentially required to compile it.
void main()
{
charch; cin>ch;
int x=isdigit(ch);
if(x)
cout<”It is a digit”;
} / 1
(C) / Find out the syntax errors (if any) in the following program. (Assuming all the required header files are included.
typedef char[30] string;
void main()
{
string s;
for(i=0,i<10,i++)
s[i]=65+i;
s[i]="\0";
cout<s;
} / 2
(D) / Find the output of the following program.
#include<iostream.h>
void main()
{
int a[]={5,10,15,20,25,30};
int *p=a+3;
for(inti=0;i<3;i++)
{
p[i]=a[i];
a[i]=p[i]*2;
}
for(i=0;i<6;i++)
cout<*(a+i)<" ";
} / 3
(E) / Find the output of the following program.
#include <iostream.h>
#include<string.h>
void encode(char S[ ])
{
int L=strlen(S);
for (int C=0;C<L/2;C++)
if (S[C]=='A' || S[C]=='E')
S[C]='#';
else
{
char T=S[C];
S[C]=S[L-C-1];
S[L-C-1]=T;
}
}
void main()
{
char Text[ ]="AISSCE 2015";
encode(Text);
cout<Text<endl;
} / 2
(F) / In the following program, if the value of Guess entered by the user is 65, what will be the expected output(s) from the following options (i), (ii), (iii) and (iv)?
#include <iostream.h>
#include <stdlib.h>
void main()
{
int Guess;
randomize();
cin>Guess;
for (int I=4;I>=1;I--)
{
New=Guess+random(I);
cout<(char)New;
}
}
(i) ACBA (ii) BBCA
(iii) CDBA (iv) DABA / 2
2. / (A) / What do you understand by Data Encapsulation and Data Hiding? / 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.
(ii)  Write complete definition for constructor 2. / 2
(C) / Define a class Show in C++ with the description given below:
Private Members:
name_of_Show of type character array(string)
date_of_release of type character array(string)
name_of_director of type character array(string)
star of type int
total_print_release of type int
Public Members:
A constructor to assign initial values as follows:
name_of_Show NULL
date_of_release 1_1_2007
name_of_director NULL
star 2
total_print_release 100
A function calculate_star() which calculates and assigns the value of data member Star as follows:
Total Print Release Star
>= 1000 5
< 1000 >=500 4
< 500 >=300 3
< 300 >=100 2
< 100 1
·  A function EnterShow() to input the values of the data members name_of_Show, date_of_release, name_of_director and total_print_release and invokes the function calculate_star( ).
·  A function DisplayShow() which displays the contents of all the data members for a play. / 4
(D) / class COMP
{ private :
char Manufacturer [30];
char addr[15];
public:
toys( );
void RCOMP( );
void DCOMP( );
};
class TOY: public COMP
{ private:
char bcode[10];
public:
double cost_of_toy;
void RTOY ( );
void DTOY( );
};
class BUYER: public TOY
{ private:
char nm[30];
char delivery date[10];
char baddr;
public:
void RBUYER( );
void DBUYER( );
};
void main ( )
{ BUYER MyToy; }
i)  Mention the member names that are accessible by MyToy declared in main( ) function.
ii)  Name the data members which can be accessed by the functions of BUYER class.
iii)  Name the members that can be accessed by functionRTOY( ).
(iv) How many bytes will be occupied by the objects of class BUYER? / 4
3. / (A) / Write a function in C++ which accepts an integer array and its size as
arguments/parameters and exchanges the values of first half side elements with thesecond half side elements of the array. 3
Example:
If an array of eight elements has initial content as
2,4,1,6,7,9,23,10
The function should rearrange the array as
7,9,23,10,2,4,1,6 / 2
(B) / An array PP[20][25] is stored in the memory along the row with each of the elements occupying 4 bytes. Find out the memory location for the element PP[13][20], if the element PP[7][10] is stored at memory location 3454. / 3
(C) / Write a function in C++ to display the sum of all the positiveand even numbers , stored in a two dimensional array. The function prototype is as follows: voidSumPosEven(int Array[5][5]); / 3
(D) / Write a function in C++ to perform insert operation on a dynamically allocated Queue. struct Node
{
int Code;
char Description[10];
Node * link;
} / 4
(E) / Evaluate the following postfix notation of expression :(Show status of Stack after each operation)
True,False,NOT,OR,False,True,OR,AND / 2
4. / (A) / Observe the program segment given below carefully and fill the blanks marked as Statement 1 and Statement 2 using seekg() and tellg() functions for performing the required task.
#include <fstream.h>
class Employee
{
intEno;charEname[20];
public:
//Function to count the total number of records
intCountrec();
};
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;
}
/ 1
(B) / Write a function in C++ to read the content of a text file “PLACES.TXT” and display all those lines on screen, which are either starting with ‘P’ or starting with ‘S’. / 2
(C) / Write a function in C++ to search for a Pcode from a binary file “PRODUCT.DAT”, assuming the binary file is containing the objects of the following class.
class PRODUCTS
{
intPcode;
char Pname[20];
float Price;
public :
void getproducts()
{
cin>Pcode>Pname>Price;
}
void showproducts()
{
cout<Pcode<Pname<Price<endl;
}
int *getproduct()
{
return Pcode;
}
}; / 3
Q.5. / (A) / What do you understand by Candidate Keys in a table ? Give a suitable example. / 2
(B) / Consider the following tables SHOP and SUPPLIER and answer the following questions:
TABLE : SHOP
ICODE / INAME / SCODE / QTY / RATE / BUYDATE
1005 / Note Book / 13 / 120 / 24 / 03-May-13
1003 / Eraser / 12 / 80 / 5 / 07-Aug-13
1002 / Pencil / 12 / 300 / 10 / 04-Mar-13
1006 / Bag / 11 / 70 / 300 / 27-Dec-12
1001 / Pen / 13 / 250 / 20 / 18-Jul-13
1004 / Sharpener / 12 / 100 / 10 / 23-Jun-13
1009 / Box / 11 / 50 / 80 / 17-Dec-12
TABLE : SUPPLIER
SCODE / SNAME
11 / Arya Stationers
12 / Stationery House
13 / Sapna Stores
Write SQL commands for the following statements i to iv and Output for v to viii
(I) / To display details of all the items in the shop table in ascending order of
Buydate. 1 Mark / 1
(II) / To display ICODE and INAME of the items with QTY more than 100. / 1
(III) / To diplay the ICODE, INAME and TOTAL AMOUNT of each item ( TOTAL AMOUNT is the product of QTY and RATE. / 1
(IV) / To display SCODE and Number of items supplied for each Supplier. / 1
(V) / SELECT COUNT (DISTINCT SCODE) FROM Shop; / ½
(VI) / SELECT SUM(QTY) FROM Shop where SCODE=11; / ½
(VII) / SELECT INAME, SNAME FROM Shop S, Supplier P WHERE S.Scode =
P.Scode AND ICODE = 1006 ; / ½
(VIII) / SELECT MIN (BUYDATE) FROM Store ; / ½
6. / (A) / Prove that / 2
(B) / Draw the logic circuit for the following Boolean expression ((A+B')(B+C)')' / 2
(C) / Write the POS expression for the Boolean function given by the following truth table
A / B / C / F
0 / 0 / 0 / 1
0 / 0 / 1 / 0
0 / 1 / 0 / 1
0 / 1 / 1 / 1
1 / 0 / 0 / 0
1 / 0 / 1 / 1
1 / 1 / 0 / 0
1 / 1 / 1 / 1
/ 1
(D) / Minimize the given Boolean function using k-map and draw the logic circuit for the reduced expression.
F(A,B,C,D)=∑(0,1,2,4,5,6,8,12) / 3
7. / (A) / What is WAN? What does the MAC address refer to? / 1
(B) / Define the term Bandwidth. / 1
(C) / Which of the following is/are not a Client Side script:
(i) PHP (ii) Java Script (iii) VB Script (iv) ASP / 1
(D) / What is the use of Cloud Computing? / 1
(E) / “Eduminds University” is starting its first campus in a small town Parampur of Central India with its centre
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 (i) to (iv) 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 / 1450Km
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 Building / 5
(i)  Suggest to the authorities, the cable layout amongst various buildings inside University campus for connecting the buildings.
(ii)  Suggest the most suitable place (i.e. building) to house the server of this organization with a suitable reason.
(iii) Suggest an effective device from the following to be installed in each of the buildings to connect all the computers:
Ø  Gateway
Ø  Modem
Ø  Switch
(iv) Suggest the most suitable (very high speed) service to provide data connectivity between Admission building located in Delhi and the campus located in Parampur from the following options:
Ø  Telephone line
Ø  Fixed line Dial-up connection
Ø  Co-axial Cable Network
Ø  GSM
Ø  Satellite Connection
/ 4
(F) / Write the full forms of the followings:
(i)  XML
(ii)  FLOSS / 1
(G) / Write one advantage and one disadvantage of BUS topology. / 1

KENDRIYA VIDYALAYA SANGATHAN

First Pre Board Examination

COMPUTER SCIENCE

Time allowed: 3Hours Maximum Marks: 70

Instructions:

I)  All questions are compulsory

II)  Programming Language : C++

1. (a) / What is scope of variable/function? Explain with the help of an example / 2
(b) / Observe the following C++ code and write the names of header files which will be essentially required to run it in a C++ compiler:
void main()
{
char x;
cin>x;
if(isupper(x)) x=tolower(x);
cout<”x = “<x;
} / 1
(c) / Rewrite the following C++ code after removing all the syntax error(s), if present in the code. Make sure that you underline each correction done by you in the code.
Assume all the required header files are already included, which are essential to run this code
The corrections made by you do not change the logic of the program.
typedef char[100] Str;
void main()
{
T Str;
Gets(T);
cout<T[0]<”\t’<T[2];
cout<T<”\N’;
} / 2
(d) / Obtain the output from the following C++ program as expected to appear on the screen after its execution, assuming all the required header files are included
#include <iostream.h>
Class AroundUs{
int Place, Humidity, Temp;
public:
AroundUs(int P=2) {Place=P; Humidity=50; Temp=15;}
void HOT(int T){Temp+=T;}
void Humid(int H){Humidiy+=H;}
void JustSee(){
cout<Place<”:”<Temp<”&”<Humidity<”%”<endl;
}
};
void main(){
AroundUs A,B(5);
A.HOT(10);
A.JustSee();
B.Humid(15);
B.HOT(2);
B.JustSee();
A.Humid(5);
A.JustSee();
} / 3
(e) / Obtain the output from the following C++ program as expected to appear on the screen after its execution, assuming all the required header files are included
#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‟;I++)
if (I%2==0)
Info[I]=Info[I] - N;
else if (islower(Info[I]))
Info[I] = toupper(Info[I]);
else
Info[I]=Info[I]+N;
} / 2
(f) / Read the following C++ code carefully and find out which out of the given options (i) to (iv) are expected correct output(s) of it. Also write the minimum and maximum value that can be assigned to the variable T used in the code:
#include<iostream.h>
#include<stdlib.h>
void main( )
{
randomize( );
int G,H=5;
G=random(H)+30;
for(int i=35;i>G;i--)
cout<i<’$’;
cout<i;
}
1.  35$34$33$32$31$30$
2.  35$34$33$32$31
3.  30$31$32$33$34$35$36
4.  35$34$33$32$31$30 / 2
2. (a) / What is copy constructor? Explain with example. / 2
(b) / Answer the questions (i) and (ii) after going through the following class:
class BUS
{ private:
char Pname[30],TicktNo[20];
float Fare;
public:
BUS( ) //function 1
{ strcpy(Pname,”\0”);
strcpy(TicktNo,”\0”);
Fare=0; }
void Details( ) //function 2
{ cout<Pname<endl<TicktNo<endl<Fare<endl; }
BUS(char * name, char *tno, float N); //function 3
BUS(BUS &F); // function 4
};
1.  In OOP, what is function 3 referred to as? Also define this function.
2.  Define function 4 and write about its purpose? / 2
(c) / Define a class TAXPAYER in C++ with the following specification
Private members :
a.  Name of type string
b.  PanNo of type string
c.  Taxabincm (Taxable income) of type float
d.  TotTax of type double
e.  A function CompTax( ) to calculate tax according to the following slab:
Taxable Income Tax%
Up to 160000 0
>160000 and <=300000 5
>300000 and <=500000 10
>500000 15
Public members :
o  A parameterized constructor to initialize all the members
o  A function INTAX( ) to enter data for the tax payer and call function CompTax( ) to assign TotTax.
o  A function OUTAX( ) to allow user to view the content of all the data members. / 4
(d) / Consider the following C++ code and answer the questions from (i) to (iv)
class FaceToFace
{
char CenterCode[10];