KENDRIYA VIDYALAYA SANGATHAN ERNAKULAM REGION FIRST COMMON PRE BOARD EXAMINATION CLASS:XII SUB:COMPUTER SCIENCE Code No. 083 Instructions: (i) All questions are compulsory. (ii) Programming language: C++ (iii) Total pages 7 TIME:3 Hrs MaxMarks:70 1 a) What is the difference between call by reference & call by value method in a user defined function in C++? Explain it with suitable example. (2) b) Name the header file to which the following belong : (i) gotoxy( ) (ii) gets() (1) c) Rewrite the following program after removing all the syntactical errors (if any), underlining each correction. : (2) include<iostream.h> typedef char[40] string; void main( ) string S= Australia ; L=strlen(S); cout<< String <<S<< has <<L<< Characters <<endl; d) Find the output of the following program: (3) #include <iostream.h> #include<conio.h> void Changethecontent(int Arr[ ], int Count) for (int C=1;C<Count;C++) Arr[C-1]+=Arr[C]; void main() int A[]=3,4,5,B[]=10,20,30,40,C[]=900,1200; Changethecontent(A,3); Changethecontent(B,4); Changethecontent(C,2); for (int L=0;L<3;L++) cout<<a[l]<<'#'; cout<<endl; for (L=0;L<4;L++) cout<<b[l] <<'#'; cout<<endl; for (L=0;L<2;L++) cout<<c[l] <<'#'; getch(); 1
e) Find the output of the following program: (2) #include <iostream.h> #include<conio.h> void Secret(char Str[ ]) for (int L=0;Str[L]!='\0';L++); for (int C=0;C<L/2;C++) if (Str[C]=='A' Str[C]=='E') Str[C]='#'; else char Temp=Str[C]; Str[C]=Str[L-C-1]; Str[L-C-1]=Temp; void main( ) char Message[ ]="SteveJobs"; Secret(Message); cout<<message<<endl; getch(); f) Study the following program and select the possible output from it with reason: (2) #include<iostream.h> #include<stdlib.h> #include<conio.h> void main( ) clrscr( ); randomize( ); int Mynum,Max=4; Mynum=20+random(Max); for(int N=Mynum;N<=25;N++) cout<<n<<"*"; i) 20*21*22*23*24*25 ii) 22*23*24*25* iii) 23*24* iv) 21*22*23*24*25 2. a) What is constructor overloading? Support your answer with example. (2) b) Answer the questions (i) and (ii) after going through the following class class ROOM int l; int w; int h; ROOM() // function 1 l=0; w=0; h=0; 2
ROOM(int x) // function 2 l=x; w=x; h=x; ROOM(int x, int y, int z) // function 3 l=x; w=y; h=z; ~ROOM(int x, int y, int z) // function 4 ; (i) In Object Oriented programming, what is function 2 referred as and when does it get invoked/called? Write suitable code for calling. (1) (ii) In Object Oriented Programming, what is function 4 referred as and when does it get invoked/called? Write suitable code for calling. (1) c) Define a class TAXPAYER in C++ with following description : (4) 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 : A parameterized constructor to initialize all the members A function INTAX( ) to enter data for the tax payer and call function CompTax( ) to assign TotTax. A function OUTAX( ) to allow user to view the content of all the data members. d) Answer the questions (i) to (iv) based on the following : (4) class Student private : char Rollno[20], Sname[30]; protected : float marks; Student( ); void ENROL( ); void SHOW( ); ; 3
class Graduate: public Student char Fname[30]; protected: unsigned int age; Graduate( ); void GENROL( ); void GSHOW( ); ; class Pgraduate: private Graduate char Mname[25]; signed int year; Pgraduate( ); void PGENROL( ); void PGSHOW( ); ; i) Mention the member names that are accessible by an object of Pgraduate class. ii) Name the data members which can be accessed by the objects of Graduate class. iii) Name the data members that can be accessed by the functions of Pgraduate class. iv) How many bytes will be occupied by an object of class Pgraduate? 3. a) Write a function in C++ which accepts an integer array and its size as arguments and replaces elements having even values with its half and elements having odd values with twice its value. (3) Example : If an array of five elements initially contains the elements as 3, 4, 5, 16, 9 then the function should rearrange content of the array as 6, 2, 10, 8, 18 b) An array Arr[15][20] is stored in the memory along the row with each element occupying 4 bytes. Find out the Base address of the location Arr[3][2], if the location Arr[5][2] is stored at the address 1500. (3) c) Write functions to perform PUSH & POP operations in a dynamically allocated stack containing the objects of the following structure: struct NODE char name[30]; float fees; NODE *next; ; (4) d) Write a function in C++ which accepts a 2D array of integers and its size as arguments and displays the elements of middle row and the elements of middle column. [Assuming the 2D Array to be a square matrix with odd dimension i.e., 3x3, 5x5, 7x7 etc ] (2) Example : If the array content is 3 5 4 7 6 9 2 1 8 Output through the function should be : Middle Row : 7 6 9 Middle Column : 5 6 1 e) Evaluate the following postfix notation of expression: (2) 30, 6, 4, +, /, 14, +, 4, * 4
4. a) Observe the program segment given below carefully and answer the question that follows : (1) class school private : char name[25]; int numstu; void inschool( ); void outschool( ); int retnumstu( ) return numstu; ; void modify(school A) fstream INOUT; INOUT.open( school.dat,ios::binary ios::in ios::ate); school B; int recread=0, found=0; while(!found && INOUT.read((char*)&B,sizeof(B)) recread++; if(a.retnumstu( )= = B.retnumstu( )) //missing statement INOUT.write((char*)&A,sizeof(A)); Found=1; else INOUT.write((char*)&B,sizeof(B)); if(!found) cout<< \nrecord for modification does not exist ; INOUT.close( ); If the function modify( ) is supposed to modify a record in file school.dat with the values of school A passed to its argument, write the appropriate statement for missing statement using seekp( ) or seekg( ), whichever needed, in the above code that would write the modified record at its proper place. b) Write a function to count the number of vowels stored in a text file STRINGS.TXT. (2) c) Write a function to delete a record on the given model number for a TV from the binary file TV.DAT containing the objects of TV (as defined below) : (3) class TV long model; float size; char brand[30],comp[30]; long retmodel( ) return model; void Input( ) cin>>model>>size; gets(brand); gets(comp); void Output( ) cout<<model<<size<<brand<<comp<<endl; ; 5. a) What do you understand by DOMAIN and TUPLE of a RELATION? (2) b) Consider the following tables Product and Client. Write SQL commands for the statements (i) to (iv) and give outputs for SQL queries (v) to (viii) (6) 5
TABLE:PRODUCT P_ID ProductName Manufacturer Price TP01 Talcom Powder LAK 40 FW05 FaceWash ABC 45 BS01 Bath Soap ABC 55 SH06 Shampoo XYZ 120 FW12 Face Wash XYZ 95 TABLE:CLIENT C_ID ClientName City P_ID 01 Cosmetic Shop Delhi FW0 5 06 Total Health Mumbai BS01 12 Live Life Delhi SH06 15 Pretty Woman Delhi FW1 2 16 Dreams Bangalore TP01 (i) To display the details of those Clients whose City is Delhi (ii) To display the details of Products whose Price is in the range of 50 to 100 (Both values included) (iii) To display the ClientName, City from Table Client, and ProductName and Price from table Product, with their corresponding matching P_ID (iv) To increase the Price of all Products by 10 (v) SELECT DISTINCT Address FROM Client (vi) SELECT Manufacturer, MAX(Price), Min(Price), Count(*) FROM Product GROUP BY Manufacturer; (vii) SELECT ClientName, ManufacturerName FROM Product, Client WHERE Client.Prod_Id = Product.P_Id; (viii) SELECT ProductName, Price * 4 FROM Product; 6. a) State and verify Absorption law in Boolean algebra. (2) b) Write the SOP form of a Boolean function G, which is represented in a truth table as follows : (1) A B C G 0 0 0 1 0 0 1 1 0 1 0 0 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 0 1 1 1 1 c) Draw a Logical Circuit Diagram for the following Boolean Expression (2) X. (Y + Z) 6
d) Reduce the following Boolean expression using K Map (3) F (A, B, C, D) = (0,2,3,4,6,7,8,10,12) 7. a) What is the difference between packet & message switching? (1) b) Expand the following terminologies : i) PHP ii) SMSC (1) c) What is infrared technology? (1) d) What do you mean by spam? (1) e) What is proprietary software?. (1) f) What is Web Hosting? (1) g) Indian Industries has the following four buildings in Chennai. Distance between various wings are given below: II 2 II 4 II1 II 3 Wing II1 to Wing II 3 Wing II1 to Wing II 2 Wing II 1 to Wing II 4 Wing II 3 to Wing II 4 Wing II 2 to Wing II3 Number of Computers Wing II 1 35 Wing II 2 25 Wing II 3 80 Wing II 4 60 70m 20m 115m 30m 25m i. Suggest suitable CABLE LAYOUTS FOR THESE BUILDINGS. (1) ii. Name the wing where the Server is to be installed. Justify your answer. (1) iii. Suggest the placement of Hub/Switch in the network. (1) iv. Mention an economic technology to provide Internet accessibility to all wings. (1) 7
8