Practice Paper - 1: Time: 3 Hrs. M.Marks: 70 General Instructions
Practice Paper - 1: Time: 3 Hrs. M.Marks: 70 General Instructions
General Instructions :
1. All questions are compulsory
2. Attempt all questions in serial order.
3. Programming Language : C++
Q1a) What is the similarities & differences between Inheritance and containership? (2)
(b) Name the header file to be included for the use of the following built in functions (2)
(i) sqrt( ) (ii) gotoxy ( )
(iii) gets( ) (iv) cos( )
(c) Will the following program execute successfully ? if not , state the reasons : (2)
class ABC
{
int x=10; float y;
ABC ( ) { y=5; }
~ABC( ) { }
};
void main ( )
{
ABC a1,a2;
}
(f) Write a C++ function having two value parameters x and n with result type float
to find the sum of series given below : (4)
1 + x + x2 + x3 + ……………….. + xn
— — — ——
2! 3! 4! (n+1)!
Q2(a) What is the difference between structure and class ? Why classes are more
useful ? (1)
(b) If a base class contains a member function basefunc( ) , and a derived class
does not contain a function with this name , can an object of the derived class
access basefunc( ) ? How show it with example . (2)
(c) Create a class called time that has separate int member data for hours , minutes
and seconds . One constructor should intialize this data to 0 , and another
should initializes to fixed values . A member function should display it ,in
11:59:59 format. The final member function should add two objects of type
time passed as arguments .
A main() program should create two initialized time objects ,and one that is not initialized . Then
it should add the two initialized values together , leving the
result in the third time variable . Finally it should display the value of this third
variable by invoking th member function. (4)
(d) Design a class called STR_FUNC which contains a string as one of its data (4)
members . Add member functions
a. Upit( ) that converts the string to uppercase.
b. Len( ) that calculates the length of the string
Also write the code in main ( ) to test these functions. ( implement string with
pointers & use pointer notation )
(e) Consider the following declaration and answers the questions given below : (4)
class WORLD
{
int H;
protected:
int S;
public:
void input(int);
void output( ) ;
};
class country : private world
{
int T;
protected :
int U;
public:
void indata(int ,int);
void outdata( );
};
class state : public country
{
int M;
public:
void display(void);
}
(i) Name the base class and derived class of the class country.
(ii) Name the data member(s)that can be accessed from function display( ) .
(iii) Name the member function(s) which can be accessed from objects of the class STATE. Is the
member function output( ) accessible by the objects of the class country.
(iv) How many bytes will be required by an object belonging to class state?
Q3(a) Comment on the efficiency of linear search and binary search in relation to
the number of elements being searched in the string. (2)
(b) Let an array contain the following elements 12,7,6,9,4,11,3 . Sort the
following elements using insertion sort showing array status after each pass. (2)
(c) For a circular queue with 5 memory locations ,show diagrammatically the status
of the queue after each of the following operations : (2)
a. 10 , 12 and then 14 is inserted
b. 10 deleted
c. 20 and 40 inserted
d. 12 and 14 deleted
e. 15 inserted and 20 deleted
f. 25 and 30 inserted
g. 40 and 15 deleted
h. 82 inserted.
(d) A circular queue is housed in an array of size N . Write C++ function to delete
an item from the front of the queue. (2)
(e) Write a program to create a linked list of ten nodes containing following
information : fight number , departure place , destination place . (2)
(g) An array B[10][15] is stored in the memory with each element requiring 4 bytes
of storage. If the base adres of S is 2000. Determine the location of S[5][10]
when the array S is stored by (i) Row major (ii) Column major form (3)
(h) Define a self referential structure for representing a simple linked list of integers.
Write a C++ function to split the list into two lists so that the first list contains
all even numbered position elements and the second list contains only odd
numbered position elements .For example , if the original list is
{ 2,8,1,14,6,18,0,7 } then the resultant first list would be { 8,14,18,17 }
and the second list would be { 2,1,6,0} (4)
(4)(a) Write appropriate statement to go to the beginning of a file at any time . (1)
(b) Write the difference between the open mode bits app and ate. (1)
(d) Write a program which display the size of a file in bytes .Read the name of a
file from the user. (3)
(e) A data file “BATCH.DAT” contains batch code and the name of the teacher
incharge as two of its fields. Write a C++ program to do the following : (4)
(i) Adding new batch details in the file.
(ii) Determine the name of the teacher if Batch code is known.
(b) Write the equivalent expression for the following logical circuit: 2
Number of Computers
Wing A 150
Wing S 10
Wing J 5
Wing H 50