Mock Test Paper-3 Computer Science Mock Test Paper-3 11 Duration : 3hrs Max Marks : 70 1. (a) How does a class inforce data hiding? 2 (b) Name the header files to which the following belong- 1 (c) Rewrite the following program after removing the syntactical errors. If any. 2 Underline the each correction. #include <iostream.h> struct serial char serial_name[20]; char serial_type; int cost=200; SERIAL; gets(serial_name); gets(serial_type); (d) Find the output of the following program : 3 #include<iostream.h> #include<string.h> class student char *s_name; int l; student() l=0; s_name =new char[l+1]; student(char *s) l=strlen(s); s_name=new char[l+1]; strcpy(s_name,s); void display() cout<<s_name<<endl; void manipulate( student &a, student &b) l=a.l +b.l; delete s_name; s_name = new char[l+1]; strcpy(s_name,a.s_name); strcpy(s_name,b.s_name);
12 CBSE-XII Computer Science ; char *temp= John ; student name1(temp), name2( Johny ), name3( Janardan ),s1,s2; s1.manipulate(name1,name2); s2.manipulate(s1,name3); s1.display(); s2.display(); (e) Find the output of the following program- 2 #include<iostream.h> long number=7583241; int First=0, Second=0; do int R=Number%10; if (R%2 = = 0) First +=R; else Second+=R; Number/=10; while (Number>0); cout<<first Second; (f) In thefollwoing program, find the correct possible output(s) from the options : 2 #include<stdlib.h> #include<iostream.h> randomize(); char City[][10]= DEL, CHN, KOL, BOM, BNG ; int Fly ; for( int I= 0 ;I<3;I++) Fly = random(2)+1; cout<<city[fly]<< : ;
2. Outputs : (i) DEL : CHN : KOL : (ii) CHN : KOL : CHN : (iii) KOL : BOM : BNG :(iv) KOL : CHN : KOL : Mock Test Paper-3 13 (a) What is this pointer? Give an example to illustrate the use of it in C++.2 (b) Answer the questions (i) and (ii) after going through the following classclass exam int year; exam(int y) year=y; //Constructor 1 exam(exam &t); //Constructor 2 ; (i) Create an object, such that it invokes constructor 1. 1 (c) Define a class named Hostel in C++ with the following descriptions : 4 Private members- REG_NO Integer NAME Array of characters (String) TYPE Character COST Float Public members- - Function Read_Data() to read an object of Hostel type. - Function Display() to display the detail of an object. (d) Answer the questions (i) to (iii) based on the following codesclass Furniture char Type; char Mode[10]; furniture(); void Read_fur_details(); void Disp_fur_details(); ; class Sofa :public Furniture int no_of_seats; float cost_of_sofa; void Read_sofa_details(); void Disp_sof_details(); ; class Office :private Sofa
14 CBSE-XII Computer Science int no_of_pieces; char delivery_date[10]; void Read_office_details(); void Disp_office_details(); ; Office MyFurniture; (i) Mention the member names which are accessible by MyFurniture declared in main() function. (ii) What is the size of MyFurniture in bytes? (iii) Mention the names of functions accessible from the member function Read_office_details() of class Office. (iv) Name the data members accessible from the object of Furniture. 3. (a) Write a function in C++ which accepts an integer array and its size as arguments/ parameters and assigns the elements into a two dimensional array of integers in the following format- 3 if the array is 1,2,3,4,5,6 if the array is 1,2,3 The resultant 2D array is given below The resultant 2D is given below 1 0 0 0 0 0 1 0 0 1 2 0 0 0 0 1 2 0 1 2 3 0 0 0 1 2 3 1 2 3 4 0 0 1 2 3 4 5 0 1 2 3 4 5 6 (b) An array X[10][10] is stored in the memory along the row with each element occupying 4 bytes of memory. Find out the base address and the address of element X[8][5], if the location of X[3][7] is stored at the address 1000. 3 (c) Write a function PUSH() to add an element to the top of the Stack dynamically. Consider the following NODE for stack- 4 4. struct NODE int RollNum; char Name[20]; NODE *Link; ; (d) Write a function MatConvert() in C++ to convert the odd numbers even by multiplying the elements by 2 and convert all even numbers by dividing the elements by 2 of Arr[M][N]. 2 (e) Solve the following postfix expression - 2 10,3,*,7,1,-,*,23,+
Mock Test Paper-3 15 (a) Observe the program segment given below carefully, and answer the question that follows : 1 class Book int Book_No; char Book_Name[20]; //function to enter book detail void enterdetails(); //function to display Book details void showdetails(); //function to return Book_no int Rbook_no() return Book_no; ; void Modify(Book NEW) fstream File; File.open( Book.Dat,ios : :binary ios : :in ios : :out); Book OB; int Recordsread = 0, Found = 0; while (!Found && File.read((char *)&&OB, sizeof(ob))) Recordsread++; if ( NEW.RBook_no() = = OB.RBook_no()) //Missing statement File.write((char*)&&NEW, sizeof(new)); Found=1; else File.write((char *)&OB, sizeof(ob)); if (!Found) cout<< Record for modification does not exist ; File.close(); If the function Modify is supposed to modify a record in file BOOK.DAT with the values of Book NEW passed to its argument, write the appropriate statement for Missing Statement using seekg(0 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 alphabets present in a text file named TEXT.TXT. 2 (c) Following is the structure of each record in a data file named ITEMS.DAT. struct ITEM
16 CBSE-XII Computer Science char Item_code[10]; char Item_Description[10]; int Stock; ; Write a function in C++ to update the file with a new value of stock. The Stock and the Product_code whose stock is to be updated, are reading during the execution of the program. 3 void modify() fstream out; out.open( ITEMS.DAT,ios : :binary iost : :in ios : :out) ITEM P1; int flag=0;stock; char Icode[10]; gets(icode); cin>>stock; while (out.read((char *)&P1, sizeof(p1))) if (strcmp(p1.item_code,icode)= =0) flag=1; P1.Stock=stock; int Position =out.tellg()-sizeof(p1); out.seekp(position); out.write((char *)&P1, sizeof(p1)); if (!flag) cout<< Product code does not match <<endl; out.close(); 5. (a) What are DDL and DML? 2 (b) Study the following tables FLIGHTS and FARES and answer the questions given in b1 and b2. TABLE : FLIGHTS FL_NO STARTING ENDING NO_FLIGHTS NO_STOPS IC301 MUMBAI DELHI 8 0 IC799 BANGLORE DELHI 2 1 MC101 INDORE MUMBAI 3 0 IC302 DELHI MUMBAI 8 0 AM812 KANPUR BANGLORE 3 1 IC899 MUMBAI KOCHI 1 4 AM501 DELHI TRIVENDRUM 1 5 MU499 MUMBAI MADRAS 3 3 IC701 DELHI AHMEDABAD 4 0
TABLE : FARES Mock Test Paper-3 17 FL_NO AIRLINES FARE TAX% IC701 Indian Airlines 6500 10 MU499 Sahara 9400 5 AM501 Jet Airways 13450 8 IC899 Indian Airlines 8300 4 IC302 Indian Airlines 4300 10 IC799 Indian Airlines 10500 10 MC101 Deccan Airlines 3500 4 (b1) Write the SQL commands for the following statements- 4 6. (i) Display FL_NO and NO_FLIGHTS from KANPUR to BANGLORE from the table FLIGHTS. (ii) Arrange the contents of the table FLIGHTS in the ascending order of FL_NO. (iii) Display the FL_NO and fare to be paid for the flights from DELHI to MUMBAI using the tables FLIGHTS and FARES, where the fare to be paid = FARE +FARE * TAX%100. (iv) Display the minimum fare Indian Airlines is offering from the table FARES. (b2) Write the output of the following SQL statements- 2 (i) SELECT FL_NO, NO_FLIGHTS, AIRLINES from FLIGHTS, FARES where STARTING= DELHI and FLIGHTS.FL_NO=FARES.FL_NO; (ii) SELECT COUNT(DISTINCT ENDING) from FLIGHTS; (iii) SELECT ENDIING,COUNT(ENDING) FROM FLIGHTS GROUP BY ENDING; (a) State and verify Associative Law. 2 (b) Write the equivalent expression for following logical circuit- 2 (c) Express P+Q R in POS form- 1 (d) Reduce the following Boolean expression using K-Map- 3 F(P,Q,R,S)=?(0,3,5,6,7,11,12,15) 7. (a) Name two transmission media for networking. 1 (b) Expand the following terms- 1 (i) GSM (ii) CDMA (c) Differentiate between Hackers and Crackers. 1
18 CBSE-XII Computer Science (d) What is meant by FTP? 1 (e) Indira Convent School in Lucknow is setting up the network between its different wings. There are 4 wings named as Senior(S), Junior(J), Admin(A) and Hostel(H). Distance between various wings is given below- Wing A to Wing S 100m Wing A to Wing J 200m Wing A to Wing H 400m Wing S to Wing J 300m Wing S to Wing H 100m Wing J to Wing H 450m Number of Computers Wing A 10 Wing S 200 Wing J 100 Wing H 50 (e1) Suggest a suitable topology for networking the computer of all wings. 1 (e2) Name the wing where the server is to be installed. Justify your answer. 1 (e3) Suggest the placement of Hub/Switch in the network. 1 (e4) Mention the economic technology to provide Internet accessibility to all the wings. 1 Note : Satellite Link, Optical Fiber, Microwave and leased line are not acceptable solution for this question. (f1) What is a shareware? 1 (f2) Explain hacking. 1