Professional Documents
Culture Documents
[All India]
Maximum Marks : 70
Note.
Duration : 3 Hours
2
2
2
#include <iostream.h>
void main( )
{
int x;
cin >> x;
for(int y=0, y<10, y++);
cout << x+y;
}
void main( );
{
int x = 5, y = 5;
cout << x;
cout << ",";
cout << x;
cout << ",";
cout << y << ","<< y;
}
#include <iostream.h>
void X(int &A, int &B)
{
A = A+B;
B = AB;
A = AB;
}
void main( )
{
int a=4, b=18;
X(a, b);
cout << a << "," << b;
}
(f) Write a function called zero_Small( ) that has two integer arguments being passed by reference and
sets the smaller of the two numbers to 0. Write the main program to access this function.
4
Ans. (a) Inheritance is a capability to define custom data types using classes, enables you to reuse the code
you develop. Inheritance enables you to more readily reuse an object, making slight adjustments,
wherever necessary. For Example,
class Student
{
Examination Paper
private :
char name[20];
int check (int e);
public :
void getdata( );
void putdata( );
protected :
int total;
void calc( );
};
class School : private Student
{
protected :
char class_stu[10];
public :
void getdata( );
void putdata( );
};
In the above example Student is the base class and School is the derived class.
(b) (i) iostream.h
(ii) fstream.h
(iii) math.h
(iv) string.h
(c) The errors are :
#include<iostream.h>
void main( )
{
int x;
cin>>x;
for(int y=0, y<10, y++);
cout << x+y;
// Error 2
#include<iostream.h>
void main( )
{
int x;
cin>>x;
for(int y=0;y<10;y++);
cout<< x+y;
}
(d) 5, 3, 4, 4
(e) 18, 4
(f) The function is :
#include <iostream.>
void zero_small(int &a, int &b)
{
if (a<b)
a = 0;
else
b = 0;
}
void main( )
{
int x, y;
2. (a) What do you understand about a member function ? How does a member function differ from an
ordinary function ?
2
(b) Define a class Student for the following specifications.
4
Private members of the Student are :
roll_no integer
name array of characters of size 20
class_st array of characters of size 8
marks array of integers of size 5
percentage float
calculate that calculates overall percentage marks and returns the percentage
Public members of the Student are :
readmarks reads mark and invoke the calculate function
displaymarks prints the data
(c) Write the output of the following program.
4
#include <iostream.h>
class Counter
{
private:
unsigned int count;
public :
Counter( ) {count = 0;}
void inc_Count( ) { count ++;}
int get_Count( ) { return count;}
};
void main( )
{
Counter C1, C2;
cout << "\n C1=" << C1.get_Count( );
cout << "\n C2=" << C2.get_Count( );
C1.inc_Count( );
C2.inc_Count( );
C2.inc_Count( );
cout << "\n C1=" << C1.get_Count( );
cout << "\n C2=" << C2.get_Count( );
}
Ans. (a) Member functions are functions defined within a class that act on the data members in the class. The
use of member functions distinguishes a class from a struct. Whereas an ordinary function can call
in any function without an object, the member function can call only by using its object. The member
function is a member of its own class but an ordinary function is not.
(b) The class is :
class student
{
int roll_no;
char name[20];
char class_st[8];
int marks[5];
Examination Paper
float percentage;
float calculate( );
public :
void readmarks( );
void displaymarks( );
};
float student :: calculate( )
{
float total = 0;
for (int I = 0; I < 5; I++)
total += marks[I];
return (total / 5);
}
void student :: readmarks( )
{
cout << "Enter 5 marks :";
for (int I=0; I < 5; I++)
cin >> marks[I];
percentage = calculate( );
}
void student :: displaymarks( )
{
cout << "The 5 marks are : ";
for (int I=0; I < 5; I++)
cout << marks[I] << endl;
cout << "\nPercentage = " << percentage << endl;
}
2
4
Define pop outside the Stack. In your definition take care of under flow condition. Function pop
should invoke error_rep to report under flow.
(c) Change the following infix expression into postfix expression.
3
(A+B)*C+D/E-F
(d) The array A[20][10] is stored in the memory with each element requiring one byte of storage if the
base address of A is C0, determine the location of A[10][5] when the arrayA is stored by column major.
3
(e) Considering the following key set : 42, 29, 74, 11, 65, 58, use insertion sort to sort the data in
ascending order and indicate the sequences of steps required.
3
Ans. (a) An array is a sequence of objects all of which have the same type. The objects are called elements of
the array and are numbered consecutively 0, 1, 2, ...... These numbers are called index values or
subscripts of the array.
A pointer is a variable that contains the memory address of an item rather its value. A pointer can
point to any type of data item or to a function.
(b) The function is :
void Stack :: pop( )
{
if (top == 0)
err_rep(1);
else
cout << stk[top];
}
(c) (A+B) * C + D / E - F
((((A+B) *C) + (D/E)) - F)
Input
Stack
Output
(
(
(
(
A
+
B
)
*
C
)
+
(
B
/
E
)
)
(
((
(((
((((
((((
((((+
((((+
(((
(((*
(((*
((
((+
((+(
((+(
((+(/
((+(/
((+
(
(
(
Empty
A
A
AB
AB+
AB+
AB+C
AB+C*
AB+C*
AB+C*
AB+C*D
AB+C*D
AB+C*DE
AB+C*DE/
AB+C*DE+
AB+C*DE+
AB+C*DE+F
AB+C*DE+F
F
)
Examination Paper
29
74
11
65
58
29
42
74
11
65
58
29
42
74
11
65
58
11
29
42
74
65
58
11
29
42
65
74
58
11
29
42
58
65
75
5. (a) Differentiate between Data Definition Language and Data Manipulation Language.
Given
the following Teacher relation : Write SQL command for question (b) to (h).
12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901
12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901
12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901
12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901
No
Name
Department
Dateofjoining
Salary
Sex
12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901
12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901
12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901
12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901
1.
Raja
Computer
21/05/98
8000
M
12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901
12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901
12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901
12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901
2.
Sangita
History
21/05/97
9000
F
12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901
12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901
12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901
12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901
3.
Ritu
Sociology
29/08/98
8000
F
12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901
12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901
12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901
12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901
4.
Kumar
Linguistics
13/06/96
10000
M
12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901
12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901
12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901
12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901
5.
Venkatraman
History
31/10/99
8000
M
12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901
12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901
12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901
12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901
12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901
6.
Sidhu
Computer
21/05/86
14000
M
12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901
12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901
12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901
12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901
7.
Aishwarya
Sociology
11/01/98
12000
F
12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901
(b)
(c)
(d)
(e)
(f)
(g)
(h)
Ans. (a)
(b)
(c)
(d)
(e)
(f)
(g)
(h)
6. (a)
(b)
(c)
(d)
(e)
Examination Paper
(f) Given the following truth table, write the product of sums form of the function F(x, y, z)
x
Output
Y+Z
XY
XZ
X(Y+Z)
XY+XZ
Both the columns X(Y+Z) and XY+YZ are identical, hence proved.
(b) L.H.S. = X.Y + Y.Z + Y'.Z
= X.Y + (Y.+Y')Z
= X.Y + 1.Z
= X.Y + Z = R. H. S.
(c) F = (2, 3, 6, 10, 11, 14)
YZ
WX
00
01
00
01
11
1
11
10
10
1
F = YZ' + X'Y
1
1
sum
carry
sum = x + y + z
carry = x . y + y . z + x . z
(e) (X+Y)(Y+Z)(X+Z)
Take the double complement.
= [(X+Y)(Y+Z)(X+Z)''
= ((X+Y) + (Y+Z) + (X+Z)']'
i.e.,
x
y
(x + y)'
y
z
(y + z)'
z
x
(z + x)'
(x + y) + (y + z) + (z + x)
Examination Paper
1
1
2
(d) Write two advantages and disadvantages of the following topologies in network :
1
(i) Bus
(ii) Ring
Ans. (a) A modem is a device which is used to convert data from digital bit strream into an analog signal and
vice versa.
(b) FTP. File Transfer Protocol
WAN. Wide Area Network
WWW. World Wide Web.
(c) Circuit Switching. In this technique, firstly the complete physical connection between two computers
is established and then data is transmitted from the source computer to the destination computer.
A Packet Switching network divides the data traffic into blocks called packets that have a maximum
length. Each packet of user data travels in a data envelope, which gives the destination address of
the packet and a variety of control information.
(d) Advantages of BUS topology :
(i) Short cable length Because there is single common data path connecting all nodes.
(ii) Easy to extend Additional nodes can be connected to an existing bus network at any point
along its length.
Disadvantages of BUS topology :
(i) Fault diagnosis is difficult Although the bus topology is very simple, but in this topology
fault detection is very difficult.
(ii) Nodes must be intelligent Each node on the network is directly connected to the central bus.
This means that some way of deciding who can use the network at any given time must be
performed in each node. It tends to increase the cost of the nodes irrespective of whether this
is performed in hardware or software.
Advantages of Ring topology :
(i) Short cable length In ring topology less connections will be needed which increases network
reliability.
(ii) The amount of cable needed in this topology is comparable to bus and relatively smallto star.
Disadvantages of Ring topology :
(i) Node failure causes network failure Since each node in this network is connected to its
neighbouring node and data travels through each node, there is one traffic flow until defective
node is removed.
(ii) Each node must handle the data being transferred on the ring.