CBSE Class 12 Half Yearly Question Paper

Subject: Computer
Academic Year: 2014 – 2015

1(a) What is the importance of INLINE FUNCTIONS? Give an example. (2)

(b) Name the header files(s) not required for successive compilation of the following: (1)

#include<iostream.h>
#include<math.h>
#include<string.h>
#include<stdio.h>
#include<ctype.h>
void main ( )
{
char word[30];
strcpy ( word, “Pre Board Examination “);
int s = strlen (word);
if(s%2= = 0).
cout<<setprecision( 4)<<word;
}

(c Rewrite the following code after removing syntactical error(s), if any. (2)

#include<iostream.h>
const int Multiple 3;
void main()
{
Value = 15;
for (int Counter = 1; Counter <= 5;Counter ++; Value – = 2)
if ( Value%Multiple = = 0)
cout<<Value * Multiple;
cout = endl;
else
cout << Value + Multiple << endl;
}

(d). Rewrite the following code after removing the syntax errors ( if any). Underline each correction. (Assume that the required header files are included) (2)

#include<iostream.h>
#include<stdio.h>
void main()
{
struct emp
{
char emp_name[15];
char emp_no;
int salary 5000; .
}EMPLOYEE;
gets(emp_name);
gets(emp_no);
}

(e) Find the output of the following program segment: (3)

#include<iostream.h>
void ChangetheContent(int Arr[], int Count)
{
for(int C=O; C<Count; C++)
Arr[C]= Arr[Count -C-1];
}
void main()
{
int A[]={1, 2, 3}, B[] = {20, 30, 40, 50}, C[]= {100, 200};
ChangetheContent(A,3);
ChangetheContent(B,4);
ChangetheContent(C,2);
for(int L=O; L<3; L++) cout<<A[L]<<‘#’;
cout<<endl;
for(int L=O; L<4;L ++) cout<<B[L]<<‘#’;
cout<<endl ,
for(int L=0;L<2, l++) cout<<C[L)<<‘#’;
cout<<endl;

(f) Give the output of the following program (Assuming that all required header files are included in the program): (3)

#include<iostream.h>
int global = 10;
void func(int &x, int y)
{
x = x-y; y = x * 10;
cout<< x <<‘ , ‘ << y << "\n”;
}
void main()
{
int global = 7;
func(:: global, global);
cout<<global<<‘ , ‘<<global<<"\n”;
func(global, ::global);
cout<<global<<‘ , ‘<<::global<<"\n”;
}

(g) In the following program, find the correct possible output(s) from the options: (2)

#include<iostream.h>
#include<stdlib.h>
const int LIMIT = 4;
void main()
{
randomize();
int Points;
Points= 100 + random(LIMIT);
for(int P=Points; P>=100, P–)
cout<<P<<‘#”;
cout<<endl;
}

(i) 103#102#101#100#
(ii) 100#101#102#103#
(iii)104#103#102#101#
(iv)103#102#101#100

2. a) Write the difference between Concrete class and Abstract Class. Explain with example. (2)
b) Answer the questions (i) and (ii) after going through the following class: (2)

class mammal
{
public:
char category[20];
mammal(char xname[]) // function1
{
strcpy(category, xname);
}
mammal(mammal &t); //function2
};
(i)Create an object, such that it invokesfunction1.
(ii)Wnte complete definition for function2

(c) Define a class HOTEL in C++ with the following description: (4)

private members :
Rno Room No of int type
Name Customer name of char type
Tarrif . stores per day charges of float type
NOD no of days integer
CALC() A function to calculate and return Amount as NOD*Tarrif and if the value of NOD*Tarrif is more than 10000 then as 1.05*NOD*Tarrif
Public Members:
A constructor to assign initial values Rno as 101, Name as “Null”, Taffif is 50 and NOD as 1.
Checkin() // A function to enter the Rno, Name , Tarrif and NOD
Checkout()// A function to display Rno, Name, Tarrif, NOD and Amount by calling CALC()

(d)Consider the following declarations and answer the questions given below: (4)

class FacetoFace
{
char CenterCode[10];<[10]public:
void Input( );
void Output( );
};
class Online
{
char Website[50];<[50]public:
void Sitein( );
void Siteout( );};
class Training: public FacetoFace, private Online
{
long T
code;
float Charge;
int Period;
public:
void Register( );
void Show ( );
};

(i)Which type of inheritance is shown in the above example?
(ii)Write names of all member functions accessible from Show() function of class Training.
(iii)Write names of all the members accessible through an object of class Training.
(iv)ls the function Output( ) accessible inside the function SiteOut()? Justify.

3(a) Write a function DELETE() in C++ to DELETE an element containing information of MOBILES(mobile no, brand ,price), from a LINKED QUEUE. Also write a function CHECK_EMPTY() which will return 1 if the stack is empty or 0 if not. This function will be invoked by the DELETE () function. (4)

(b )An array Array[20][1[20][15]ored in the memory along with row with each element occupying 4 bytes. Find out the base address and address of the element Array[2][3][2][3]e element Array[4][5][4][5]ored at the address 5000. (3)

(c) Convert the expression !(TRUE && ! FALSE)||(FALSE && ! TRUE) to postfix expression. Show the contents of the Slack at every step. Also evaluate the postfix expression using stacks. (4)

(d)Write a function in C++ to print the sum of all the non-negative elements present on either diagonal of a two dimensional array passed as the argument to the function. (2)

(e) Write H user defined function in C++ to search a students record from the given Array of structure using binary search technique. Assume the array is sorted in descending order of the roll number. Assume the following (2)

definition:
struct Student { char nalne[20];<[20]

.                         long roll no;

};

(f) Write a function to add an element to the circular queue storing integer type data. (2)

4(a) Observe the program segment given below carefully and fill the blanks marked as Statement1 and Statement2 using appropriate file functions. (1)

class Examiner

{
int eno; // examiner’s number
char ename(20); // examiner’s name
char eadd(25); // examiner’s address
int exp; // examiner’s experience
public:
void read data();
void out data();
void revised(); // function to make revision in the experience
int chno(); // returns the new experience
} ;
void experience (int revno)
{
fstream fin;
fin.open(“exam.dat”ios: :binary|ios: :in|ios: :out);
Examiner ex;
int rec=0;got=0;
while(!got &&fin.read((char*)&ex, sizeof(ex)))
{
if (revno=ex.chno())
{
cout<<“enter the new experience”;
ex.revised();

____________ / / statement 1

____________ / / statement 2

got=1;
}
rec++;
}
fin.close();
}
}

b) Write a function in c++ to read a text file “old.txt”( already created) and replace all three letter words with “***” (3)

c) Given a binary file TELEPHON.DAT, containing records of the following class Directory:
class Directory
{
char Name [20] ;[20] char Address [30] ;[30] char AreaCode[5] ;<[5] char Phone_No[15] ;[15] Public:
void Register ( ) ;
void Show( ) ;
int CheckCode (char AC [] )
{
return strcrnp ( AreaCode, AC ) ;
}
};
Write a function COPYABC ( ) in C++, that would modify all those records having AreaCode as “222” to “555” from TELEPHONE.DAT. (3)

d) Write a function to count all words beginning with “A” in a given text file. (3)

5 Consider the following tables BOOKINGS and PACKAGE and write SOL commands for (i) to (iv) and outputs for (v) and (vi). (6)

Pcode Tourist Name Agency No _ of _ persons Tdate
P5 Raghavendra Voyager 2 23-Dec-10
P2 Hardep Pristine 4 12-Jan-11
P5 Shazia Go Now 6 25-Dec-10
P6 Lizza Pristine 2 28-Dec-10
P3 Diana Voyager 4 19-Mar-11
P6 Harshal Go Now 4 21-Mar-11
P1 Rajiv Khanna Travels 12 12-Apr-11
P1 Veena Sethi Voyager 5 1-Apr-11
Pcode
Pname
Per_Person_amt
P1 Kerala 20000
P2 Malaysia 35000
P3 Goa 56525
P4 Manali 15000
P5 Simla 12000
P6 Singapore 75450

a) Display the name of all the tourists, their travel dates, names of the places they are traveling to and the total amount to be payed by each tourist.
b) Display the name of the agencies from the BOOKING table.
c) Arrange the contents of the table BOOKING in ascending order of travel date.
d) Display the maximum no_of_persons traveling of each travel agency.
e) SELECT Tourist Name, Agency, Pname from BOOKINGS, PACKAGE where BOOKINGS.Pcode = PACKAGES.Pcode and Per_person_amt > 3500;
f) SELECT Agency, sum(No_of_persons) from BOOKING group by agency having sum(No_of_persons>10;

6 Write SOL commands for the queries (a) to (b) based on the relations shown below: (5)

Code Name Dcode Qty Unit Stock-date
444 Drawing Copy 101 15 20 ‘2011-6-31’
445 Sharpner Camlin 102 25 8 ‘2011-4-22’
450 Eraser Natraj 101 20 6 ‘2011-6-15’
452 Gel Pen Montex 103 9 15 2011-9-11′
457 Geometry Box 102 27 65 ‘2011-15-11’
470 Office File 103 35 34 ‘2011-11-11’

 

Dcode D-name Location
101 Vikash Stationers Sadar Delhi
102 Goyal Publishing Varanasi
103 Priyam Pustak Bhandar Pulbangash Delhi

With reference to the above tables:

i) Write a command to display the amount that has to be spent to purchase Drawing copies and Geometry box.
ii) Disptay fhe name, qty, stock-date, unit, D-name and location of all the items.
iii) Write a command to delete the column Stock-Date from the table: STOCK.
iv) Write output:
a)SELECT, DCODE, (AVG (UNITPr)) from stock group by Dcode
b) SELECT CODE,NAME FROM STOCK WHERE CODE LIKE ‘0%’;

7 (a) Write full forms for the following:

(i) WLL (ii) FLOSS (1)
(b) Give two examples each of client server script and server side script. (2)
(c) How are viruses different from worms? (2)

Go Back to CBSE Class 12 HY Question Papers Home Page