KENDRIYA VIDYALAYA SANGATHAN

FIRST PREBOARD EXAMINATION 2015-16 FOR CLASS XII

SUBJECT: COMPUTER SCIENCE

F.M. 70TIME: 3 HRS

General Instructions:

Programming Language – C++

All Questions are compulsory.

Q1. (a) Differentiate local and global variable with suitable example.[2]

(b) Which header file(s) are essential to be included to execute the following C++ code[1]

void main( )

{char Name[15], *Str="Hello!";

puts("Enter your name : "); gets(Name);

strcat(Str,Name); puts(Str);

}

(c) Find the output of the following program[2]

# include <iostream.h>

void main( )

{ int a=5, b=10;

cout<b++ – + +a<endl;

cout<– – a + b – – <endl;

}

(d) Rewrite the following program after removing syntax errors. Underline each correction [2]

# include <iostream.h>

CallFun(int X, int Y:10)

{cout<X<"\t"<Y<endl}

void main( )

{ One=1, Two=2;

CallFun(One,Two);

CallFun(One);

}

(e) Find the output of the following program[3]

# include <iostream.h>

void main( )

{ char *TXT="Good Night!";

int Num[ ]={1,2,3,4,5};

int *P=Num; TXT+=10;

while(*P<5)

{cout<*P<"#"<TXT<endl;

P++; TXT – –;

}

}

(f) Find the output(s) which will not be expected on execution of the following program[2]

# include <iostream.h>

# include <stdlib.h>

void main( )

{ int A[ ]={10,20}, RN;

randomize( );

for(int X=0; X<2; X++)

{RN=random(X+1)+10;

cout<A[X]+RN<"@";

}}

(i)10@20@

(ii)20@30@

(iii)21@31@

(iv)20@31@

Q2.(a) Differentiate between protected private visibility modes in the context of inheritance[2]

(b) Answer the questions (i) and (ii) after going through the following class: [2]
class Subject
{ char Topic[20];
int Weightage;
public:
Subject ( ) { }//Function 1
Subject( char *T)//Function 2

{
strcpy (Topic, T );
Weightage = 30;
}

Subject( Subject &S)//Function 3

{
strcpy (Topic, S.Topic );
Weightage = S.Weightage;
}

~Subject( ) { }//Function 4

void Show( )//Function 5

{

cout<Topic<"\t"<Weightage<endl;

}

};

void main( )

{Subject S1("CS"), S2(S1);//Statement1

S1.Show( );

S2.Show( );

}

(i) What is Function4 Known as? When does it get executed?
(ii) Which out of the above defined functions get executed for Statement1?

(c) Define a class TAXPAYER in C++ with following description [4] Private Members:

(i)Nameof type string to store Name

(ii)PAN of type string of to store the Personal Account Number (10 characters)

(iii)Income of type double to store Taxable income

(iv)Tax of type double to store Tax to be paid

(v)A function Compute( ) to calculate tax according to the following slab:

Taxable IncomeTax
Up to 200000 0
>200000 and <=500000 10% of Taxable Income
>50000020% of Taxable Income

Public members:

(i)A function GET( ) to enter data for the tax payer

(ii)A function PRINT ( ) to allow user to view the content of all the data members after calculating amount of tax to be paid using Compute ( ) and assigning it to Tax.

(d)Observe the following code carefully and answer (i) to (iv) [4]

class Teacher
{ int Code;

char Name[20], Desig[15];
protected:
float Salary;
void AssignSal(float);
public:
void Enter( ) ;
void Display( );
};

class Student
{
int Admno[10];

char StName[20], Stream[10];
protected:
int Attendance;
public:
void Input( );
void Output( );
};

class School : publicStudent, protectedTeacher
{
char AffNo[10], SchName[20];
public:
void Accept( );
void Show( );
};

(i)Which type of Inheritance is depicted by the above example?

(ii)What is the size of an object of Student Class?

(iii)Write the all the member function(s) that cannot be called directly from the objects of School class

(iv)Write name of all the data member(s) accessible from Show( ) method

Q3.(a)Define a function in C++ that accepts an integer array and its size as argument and

Sort its elements in ascending order using insertion sort.[3]

(b)An integer array X[30[30] is stored in column major order. Find the address of the element X[20][15] if address of X[10[10] is 5000. [3]

(c)Define a function InsertQ(float [ ], float) to insert an element into a Queue of floating point numbers of size N implemented using array. [4]

(d)Define a function in C++ which shifts each element of an array A[ ] to its left by one position. In doing so the 1st element becomes the last element of the array. [2]

e.g. If the array is: 1,2,3,4,5 after shifting it contains elements in the order 2,3,4,5,1

(e) Evaluate the following postfix expression and show the status of the stack after every step [2]

12, 7,3, – , /, 2, 1, 5, +, *, +

Q.4 (a) Observe the program segment carefully and write code for the missing statements [1]

class Book
{ int BNum :
char BName[20] ;
public:
void getDetails( ) ;//function to enter Book details
void showDetails( ) ;//function to display Book details

void changeDetails( ) ;//function to display Book details

int RerBNum( ) {return BNum ;} //function to return Book number
} ;

void Modify(int N)
{ fstream File ;

Book B ;

int Found = 0 , RecNo=0;
File.open(“BOOK.DAT”, ios :: binary l ios :: in l ios :: out) ;
while ( File.read((char*)&B, sizeof(B) ) )
{ if (N == B.RetBNum( ))

{ RecNo++ ;

------//Statement1

B.changeDetails();

------//Statement2

Found = 1 ;}

}

if (Found==0)
cout < “Record does not exist”;
File.close( ) ;
}

Write Statement1to position file pointer at proper place for writing and Statement2 to write the modified record to the file.

(b) Write a function in C++ to read the content of a text file NOTES.TXT and display all those lines which are either starting with ‘S’ or ‘T’. [2]

(c) A binary file STUDENT.DAT, contains STUDENT records as defined below. Write a function in C++, to search and display details of the student having admission number 154. [3]

class STUDENT
{ int AdmNo; //Admission number of student
char Name[30] ; //Name of student
float Percent; //Percentage of marks obtained
public :
void EnterData( )//Enter student details
{ cout<”\n Enter Students Admission Number : “;

cin>AdmNo ;

cout<”\n Enter Students Name : “;

gets(Name) ;

cout<”\n Enter percentage of marks obtained : “;

cin > Percent ;

}
void DisplayData( )//Display student details
{

cout < “\nAdmission Number\tName\t\tPercentage\n” ;

cout<AdmNo<”\t”<Name<”\t\t”<Percent<endl;

}
int RetAdmNo( ) {return AdmNo ;}//Return admission number

} ;

Q 5 (a) What is a Primary Key?[1]

(b) Differentiate between char and varchar. [1]

(c) Consider the following tables Consumer and Stationary.

Table: Stationary

S_ID / StationaryName / Company / Price
BP01 / Ball Pen / Reynolds / 10
PL02 / Pencil / Natraj / 5
ER05 / Eraser / Natraj / 3
PL01 / Pencil / Apsara / 6
GP02 / Gel Pen / Reynolds / 15

Table: Consumer

C_ID / ConsumerName / City / S_ID
01 / Pen House / Delhi / PL01
06 / Write Well / Mumbai / GP02
12 / Topper / Delhi / BP01
15 / Good Learner / Delhi / PL02
16 / Motivation / Bangalore / PL01

Write SQL statements for (i) to (iv)[4]

(i)To display the consumer detail in descending order of their name.

(ii)To display the Name and Price of Stationaries whose Price is in the range 10 to 15.

(iii)To display the ConsumerName, City and StationaryName for stationaries of "Reynolds" Company

(iv)To increase the Price of all stationary by 2 Rupees.

Write the output of SQL queries for (v) to (viii)[2]

(v)SELECT * FROM CITY WHERE StationaryName Like 'B%'

(vi)SELECT DISTINCT City FROM Consumer;

(vii)SELECT Company, MAX(Price), MIN(Price), COUNT(*) from Stationary GROUP BY Company;

(viii)SELECT C.ConsumerName, S.StationaryName, S.Price

FROM Stationary S, Consumer C WHERE C.S_ID=S.S_ID;

Q 6.(a) Prove that [2]

(b) Draw the logic circuit for the following Boolean expression[2] ((A+B')(B+C)')'

(c) Write the POS expression for the Boolean function given by the following truth table[1]

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

( d) Minimize the given Boolean function using k-map and draw the logic circuit for the reduced expression. [3]

F(A,B,C,D)=∑(0,1,2,4,5,6,8,12)

Q. 7 (a)What is Firewall? [1]

(b) Expand the terms GPRS, TCP[1]

(c) Which network (PAN/MAN) is formed when two mobiles are connected via Bluetooth?[1]

(d) Name any two protocol used in Communication.[1]

(e) Differentiate between LAN and WAN[2]

(f) MHA & Co. has set up its new center at Mumbai for its office and web based activities. The company compound has 4 blocks as shown in the diagram below: [4]

Distances between various blocks and Number of Computers at each block are given below

Blocks / Distance
Black A to Block B / 50 m
Block B to Block C / 150 m
Block C to Block D / 125 m
Block A to Block D / 170 m
Block B to Block D / 115 m
Block A to Block C / 75 m
Block / No. of Computers
Black A / 25
Block B / 35
Block C / 95
Block D / 20

(i)Suggest a cable layout for connecting the blocks.

(ii)Suggest the most suitable place to house the server.

(iii)Suggest the placement of the following devices with justification

  1. Repeater (b) Switch

(iv)Suggest a way to connect its front office in Mumbaiwith office at Chennei at reasonably high speed.

------