All Questions Are Compulsory Programming Language: C++
All Questions Are Compulsory Programming Language: C++
com/
Guess Paper 2012
Class XII
Subject Computer Science
GENERAL INSTRUCTIONS:
1. a) What is the difference between entry controlled loop and exit controlled loop?
Illustrate your answer with a C++ valid code.
2
b) Name the header files(s) used for successive compilation of the following:
void main( )
{
char word[30];
strcpy ( word, Pre Board Examination );
int s = strlen (word);
if(s%2= = 0)
cout<<setw(20)<<word;
}
c) Rewrite the following code after removing syntactical error(s), if any
Underline each correction:
#include<iostream.h>
struct A
{ int a, b;
};
void main ( )
{
int N=5;
A str [N] = (2, 5), *p;
p = str;
cout<<p.a<<p.b<<endl;
}
www.cbseguess.com
Other Educational Portals
www.icseguess.com | www.ignouguess.com | www.dulife.com | www.magicsense.com |
www.niosguess.com | www.iitguess.com
http://www.cbseguess.com/
int change[10];
for(int i=0;i<6;i++)
{
if(arr[i]>arr[i+1])
change[i]=arr[i];
else
change[i]=arr[i+1];
}
split(arr,change);
for(i=0;i<6;i++)
{
if(i%2= =0) cout<<arr[i]+change[i]<<"#";
else
cout<<change[i]-arr[i]<<"*";
}
}
f) Chose the correct alternative from the options (i)- (iv). Justify your answer.
#include<iostream.h>
#include<stdlib.h>
#define Getval (N) ((N%2 = =0)? N+1:N+2)
void main( )
{
randomize( );
int num= random(3)+3;
for( int I= num ; I<=num+2 ;I++)
cout<<Getval(I)<<@;
}
Options:
a) 3@5@7@
b) 7@7@9@
c) 7@9@9@
d) 7@9@11@
2 a) Give differences between a copy and a parameterized constructor.
Also use a suitable C++ code to support your answer.
b) Answer questions 1 and 2 after going through the following class:
class game
{
char name[20];
int players;
public:
game (int, char*);
// MODULE 1
game (game&);
// MODULE 2
~game( );
// MODULE 3
};
1.
Define MODULE 2 outside the class.
2.
What is MODULE 3 known as? Which OOP concept do they imply?
c) Define a class STUDENT in C++ with the following specifications :
2
2
Class name
Student
Data Members
Type
Std_name
string
Std_rollno
long
Marks
float
Stream
string
A function Assign_stream( ) to assign stream on the following basis:
Marks
Stream
300 and above
Science
Between 250 and 300
Commerce
Between 200 and 250
Humanities
Below 200
NULL
Public Member Functions:
A constructor to initialize data members with legal initial values.
A function Initialize ( ) to input the values for the data members and invoke the Assign_stream ( )
function.
A function to display the values of data members.
www.cbseguess.com
Other Educational Portals
www.icseguess.com | www.ignouguess.com | www.dulife.com | www.magicsense.com |
www.niosguess.com | www.iitguess.com
http://www.cbseguess.com/
d) Answer Questions 1 to 4 after going through the following code:
class drama {
class realityshow {
char dname[20];
int Dduration;
protected:
char dactors[10][20];
public:
void enterdrama( );
void displaydrama( );
char rname[15];
int Rduration;
protected:
char Rparticipants[15][20];
public:
void enterreality ( );
void dispreality( );
int Nduration;
char nreader[10][15];
public:
void enternews( );
void dispnews( )
class tvprog : public drama, private realityshow, public news
{
char chnlgrp[20];
float pkgcost;
public:
void enterprog( );
void dispprog( );
};
};
class news{
1.
2.
3.
4.
};
};
Write the names of all members accessible from dispprog( ) of class tvprog.
Write name of all data members accessible from object of class tvprog.
Calculate size of an object of class tvprog.
Write the order for the call of the constructors when object of class tvprog is declared.
3. a) Write a 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 definition :
struct Student{
char name[20];
long rollno;
};
b) An array X[5] [20] is stored in the memory along the column with each element
occupying 4 bytes of memory. Calculate the address of an element X [2] [15] if
the element X [3] [10] is stored at the address 2200.
c) Write a function in C++ to insert an element in a dynamically allocated Queue
containing the names of the countries. Give necessary declarations.
d) Write a user defined function int ALTERSUM(int B[], int N, int M) in C++ find
and return the sum of elements from all alternate elements of a 2-D array from B[0][0]
EXAMPLE:
5
4
3
6
7
8
1
2
9
The function should add 5,3,7,1,9 and return 25.
e) Evaluate the following postfix expression showing the stack content:
False, True, NOT, OR, True, False, AND, OR.
3
4
2
4 a) Assume that a text file named FILE.TXT already contains some text written into it. But
while writing into the file, the word, when has been misspelled whn everywhere in the
Write a function named Corrections ( ) in C++ that reads the file FILE.TXT. and corrects
the word whn.
2
www.cbseguess.com
Other Educational Portals
www.icseguess.com | www.ignouguess.com | www.dulife.com | www.magicsense.com |
www.niosguess.com | www.iitguess.com
http://www.cbseguess.com/
b) Given a binary file BOOK.DAT containing records of the following type:
class user
{
char unmae[20], status;
// A active I inactive.
int uid;
public:
void readdetails( );
void showdetails( );
char getstatus( )
{
return status
};
void setstatus( char s )
{
status=s;
};
int getid( )
{
return id
};
};
Write a function which changes the status of all users with previous status as I to A.
c) Considering the text file already contains the following word September (Double
Quotes are not the part of the text.) What will be the output of the following:
void main ( ) {
fout<<Exams ;
cout.tellp( );
ofstream fout(NOTES.TXT,ios::app);
fout.close( );
}
5. a) What do you understand by the following in a relation database :
i) Candidate Key
ii) Project Operation.
b) Consider the following tables BOOKINGS and PACKAGE and write SQL
commands for (i) to (iv) and outputs for (v) and (vi).
Pcode
P5
P2
P5
P6
P3
P6
P1
P1
Pcode
P1
P2
P3
P4
P5
P6
BOOKINGS
Tourist Name
Raghavendra
Hardep
Shazia
Lizza
Diana
Harshal
Rajiv Khanna
Veena Sethi
PACKAGE
Pname
Kerala
Malaysia
Goa
Manali
Simla
Singapore
Agency
Voyager
Pristine
Go Now
Pristine
Voyager
Go Now
Travels
Voyager
No_of_persons
2
4
6
2
4
4
12
5
2
6
Tdate
23-dec-10
12-jan-11
25-dec-10
28-dec-10
19-mar-11
21-mar-11
12-apr-11
01-apr-11
Per_Person_amt
20000
35000
56525
15000
12000
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;
www.cbseguess.com
Other Educational Portals
www.icseguess.com | www.ignouguess.com | www.dulife.com | www.magicsense.com |
www.niosguess.com | www.iitguess.com
http://www.cbseguess.com/
2
1
3
2
1
1
1
1
4
B
A
C
i)
A and B
20 m
B and C
150 m
C and D
70 m
C and E
5000 Km
A and D
165 m
B and D
90 m
B and E
5000 km
mumb
ai
Number of Computers:
Suggest
A
a suitable Network connection.
B
ii) Where do you think repeaters should be kept?
C
iii) Suggest an economic technology to provide internet
D
all buildings.
E
iv) Building C has to be used for critical operations. It
get maximum bandwidth. Which network device should be used for this?
f) Differentiate between free and an open source software.
g) Differentiate between Trojan Horse and a worm.
40
45
110
70
60
accessibility to
wants its PC to
1
1
www.cbseguess.com
Other Educational Portals
www.icseguess.com | www.ignouguess.com | www.dulife.com | www.magicsense.com |
www.niosguess.com | www.iitguess.com