Ashok Garg - 9149405 Code No.08 Roll No. Candidate must write the Code on the title page of the answer-book Please check that this question paper contains 8 printed pages. Code number given on the right hand side of the question paper should be written on the title page of the answer book by the candidate. Please check that this question paper contains 7 questions. Please write down the Serial Number of the question paper before attempting it. Write down the question numbers fully and neatly. i.e. (a), (b) etc. COMPUTER SCIENCE (CODE 08) CLASS XII Time allowed : Hours Maximum. Marks 70 Instructions: (i) All questions are compulsory. (ii) Programming Language : C++ 1(a) Name the header file to which the following belong: 1. random(). setw() 1 (b) Find the output of the following program. #include<iostream.h> #include<conio.h> struct PLAY int Score, Bonus; ; void Calculate(PLAY &P, int N=10) P.Score++; P.Bonus+=N;
void main() clrscr(); PLAY PL=10,15; Calculate(PL,5); cout<<pl.score<<":"<<pl.bonus<<endl; Calculate(PL); cout<<pl.score<<":"<<pl.bonus<<endl; Calculate(PL,15); cout<<pl.score<<":"<<pl.bonus<<endl; getch(); (c) Write the output of the following program segment. #include<iostream.h> #include<conio.h> int &max(int &x, int &y) if(x>y) x++; return x; else y++; return y; void main() clrscr(); int A=5, B=7; max(a,b)=-1; cout<<"a = "<<A<<"\tB = "<<B<<endl; max(b,a)=4; cout<<"a = "<<A++<<"\tB = "<<--B<<endl; max(a,b)=5; cout<<"a = "<<A<<"\tB = "<<B<<endl; getch(); (d) State the reason why enum Boolean(false, true); is better than enum Boolean(true, false);
(e) Write a program to print the truth table for XY+Z. (Using Loops) (a) What will be the output of following? #include<iostream.h> #include<conio.h> class MAIN MAIN() calculate(); cout<<"\t"<<"constructor\n"; void calculate() show(); cout<<"\t"<<"calculating"; void show() cout<<"i am displaying"; ; void main() MAIN one; (b) A Group Housing Society received applications from various applicants. They want to allot houses by lottery system. Write a program to computerized their system with the following specifications. 4 Define a class named HOUSING in C++ with the following description Private members: Reg_no Regestration Number - Integer( ranges 10 1000); Name Name of the person - Array of characters (max 0 characters) Type Type character(general - G, Reserved - R) Cost double Public members: read_data() - Function to read an object of Housing type void disp_data() - Function to display the details of an object void draw_nos() - Function to choose and display the details of houses selected randomly from an array of 10 objects of type HOUSING. Use random function to generate regestration nos. to match with Reg_no from the array.
4 (c) What is containership? How does it differ from inheritance? (d) Answer the question 1 to 4 based on the following code: 4 class Book char Title[0]; char Author[0]; int No_of_pages; void read(); void show(); ; class Textbook:private Book int no_of_chapters, no_of_assignments; protected: int standard; void readtextbook(); void showtextbook(); ; class Physicsbook:public Textbook char Topic[0]; void readphysicsbook(); void showphysicsbook(); ; 1. Name the members, which are accessed from the member functions of class physicsbook.. Name the members, which are accessed by an object of class Textbook.. Name the members, which are accessed by an object of class Physicsbook. 4. What will be the size of an object (in bytes) of class Physicsbook? (a) Write a function in C++ which accepts an integer array and its size as arguments/parameters and assign the elements into a two dimensional array of integers in the following format. If the array is 1,,,4,5 then the resultant -D array is of type: 1 0 0 0 0 1 0 0 0 1 0 0 1 4 0 1 4 5
5 (b) If an array B[11][8] is stored as column wise and B[][] is stored at 104 and B[][] at 1084. Find the address of B[5][] and B[1][1]. (c) Given two arrays of integers X and Y of sizes m and n respectively. Write a function named MERGE() which will produce a third array named Z, such that the following sequence is followed: 1. All odd numbers of X from left to right are copied into Z from left to right.. All even numbers of X from left to right are copied into Z from right to left.. All odd numbers of Y from left to right are copied into Z from left to right. 4. All even numbers of Y from left to right are copied into Z from right to left. X, Y and Z are passed as arguments to MERGE() Example: X,,1,7,6, Y9,,5,6,8,10 Z,1,7,,9,,5,10,8,,6,6, 4(a) Distinguish between Serial files and Sequential files. (b) Assuming the class BUS as shown below: #include <fstream.h> #include<string.h> #include<process.h> #include<stdio.h> #include<conio.h> class BUS int bus_no; char destination[0]; float distance; float bus_fare; void getdata(); //To read an object from the keyboard void dispdata(); //To show an object on monitor. int retbus_no() return bus_no; ; void BUS::getdata() cout<<"enter Bus Number : "; cin>>bus_no; cout<<"enter destination : "; gets(destination); cout<<"enter distance : "; cin>>distance; cout<<"enter Bus fare : "; cin>>bus_fare; void BUS::dispdata() cout<<"bus Number : "<<bus_no<<endl; cout<<"destination : "<<destination<<endl; cout<<"distance : "<<distance<<endl; cout<<"bus fare : "<<bus_fare<<endl;
6 Write a function modibus() which will accept a bus number and modify the contents related to that bus. Display proper message if the given bus number not found. (c) Write a program that reads a text file and create another file that is identical except that every sequence of consecutive blank spaces is replaced by a single space. For Example: After Running your program the contents of file Golden.txt saved in file Golden1.txt as shown. Each student will take the full responsibility of keeping the class syllabus to perform in class test, unit tests and other examination and getting all class work and home work checked in time. Golden1.txt Each student will take the full responsibility of keeping the class syllabus to perform in class test, unit tests and other examination and getting all class work and home work checked in time. (d) What is the difference between put() and write()? 5(a) Define the following. 1. Primary Key. Foreign Key (d) LIBRARY NO TITLE AUTHOR TYPE PUB QTY PRICE 1 DATA STRUCTURE LIPSCHUTZ DS MCGRAW 4 17 COMPUTER STUDIES FRENCH FND GALGOTIA 75 ADVANCED PASCAL SCHIDT PROG MCGRAW 4 50 4 DBASE DUMMIES PALMER DBMS PUSTAKM 5 10 5 MASTERING C++ GUREWICH PROG BPB 95 6 GUIDE NETWORK FREED NET ZPRESS 00 7 MASTERING FOXPRO SEIGAL DBMS BPB 15 8 DOS GUIDE NORTON OS PHI 175 9 BASIC FOR BEGINNERS MORTON PROG BPB 40 10 MASTERING WINDOW COWART OS BPB 1 5 1. SELECT ALL THE PROG TYPE PUBLISHED BY BPB FROM LIBRARY.. DISPLAY A LIST OF ALL BOOKS WITH PRICE MORE THAN 10 AND SORTED BY QTY.. DISPLAY ALL THE BOOKS SORTED BY PRICE IN ASCENDING ORDER. 4. DISPLAY A REPORT LISTING BOOK ID, CURRENT VALUE AND MISPLACEMENT CHARGES FOR EACH BOOKS IN THE ABOVE TABLE. CALCULATE THE MISPLACEMNT CHARGES FOR ALL BOOKS AS 8
PRICE*1.5. 7 5. COUNT THE NUMBER OF BOOKS PUBLISHED BY PHI. 6. INSERT A NEW BOOK IN THE LIBRARY TABLE. FILL ALL THE COLUMN WITH VALUES. 7. GIVE THE OUTPUT OF FOLLOWING SQL COMMANDS ON THE BASIS OF TABLE LIBRARY. a. SELECT MIN(PRICE) FROM LIBRARY WHERE PRICE<150. b. SELECT AVG(PRICE) FROM LIBRARY WHERE QTY< c. SELECT COUNT(DISTINCT TYPE) 6(a) State DeMorgan s Law. Verify one of the DeMorgan s Laws using truth tables. (b) Prove X Y + Z = (X + Y + Z) (X + Y + Z) (X + Y + Z) algebraically. (c) Write the dual of the Boolean expression (U + W) (V U + W) 1 (d) Obtain simplified form for a Boolean expression F= (0, 1,, 5, 7, 9, 11, 1, 1, 15) using K-Map. (e) Represent the Boolean expression X + YZ with the help of NOR gates only 1 (f) Write the Product Of Sum form of the function H(u, V, W), truth table representation of H is as follows: 1 U V W H 0 0 0 1 0 0 1 0 0 1 0 1 0 1 1 0 1 0 0 0 1 0 1 1 1 1 0 0 1 1 0 7(a) Identify and correct the error in the following code fragment: struct first int a; float b; S1; struct second int a; float b;
S; 8 S1=S; (b) Why do you think function overloading must be a part of an Object Oriented Language? (c) Distinguish between the following two statements (statement 1 and statement ): class time int hr,min,sec; time(int hh, int mm, int ss) hr=hh; min=mm; sec=ss; ; time T1(1, 10, 5); //statement 1 time T1=time(1,10,5); //statement (d) What is Recursion? Write a function to calculate factorial of a number using recursion and implement it. 4
9