KENDRIYA VIDYALAYA SANGATHAN BHUBANESWAR REGION SECOND PREBOARD EXAMINATION 2014-15 FOR CLASS XII SUBJECT: COMPUTER SCIENCE SET-I F.M. 70 General Instructions: Programming Language C++ All Questions are compulsory. TIME: 3 HRS 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] 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] 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] CallFun(int X, int Y:10) cout<<x<<"\t"<<y<<endl One=1, Two=2; CallFun(One,Two); CallFun(One); (e) Find the output of the following program [3] 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 <stdlib.h> int A[ ]=10,20, RN; randomize( ); for(int X=0; X<2; X++) RN=random(X+1)+10; cout<<a[x]+rn<<"@";
(i) (ii) (iii) (iv) 10@20@ 20@30@ 21@31@ 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; 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; ; 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) Name of 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 Income Tax Up to 200000 0 >200000 and <=500000 10% of Taxable Income >500000 20% 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); void Enter( ) ; void Display( ); ; class Student int Admno[10]; char StName[20], Stream[10]; protected: int Attendance; void Input( ); void Output( ); ; class School : public Student, protected Teacher char AffNo[10], SchName[20]; 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 1 st 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] ; 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 Statement1 to 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, SIM [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 A Block B to Block C Block C to Block D Block A to Block D Block B to Block D Block A to Block C 150 m 125 m 170 m 115 m Block No. of Computers Black A 25 Block B 35 Block C 95 Block D 20 75 m (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 a. Repeater (b) Switch (iv) Suggest a way to connect its front office in Mumbai with office at Chennei at reasonably high speed. --------- B D C