Delhi 2002 PDF
Delhi 2002 PDF
Delhi 2002 PDF
[Delhi]
Maximum Marks : 70 Duration : 3 Hours
Note. All the questions are compulsory.
Programming Language : C++
Examination Paper 1
(c) The errors are :
#include<iostream.h>
void main( )
{
int x;
cin << x; // Error 1
for(int y=0; y<10; y++);
cout >> x+y; // Error 2
}
Error 1 : Illegal structure operation
Error 2 : Illegal structure operation
Corrected program :
#include<iostream.h>
void main( )
{
int x;
cin >> x;
for(int y=0; y<10; y++);
cout << x+y;
}
(d) 5, 7, 6, 6
(e) 4, 4
(f) The function is :
#include<iostream.h>
#include<conio.h>
double power(double n,int p = 2)
{
int s = 1;
for(int i = 1; i <= p; i++)
s = s*n;
return(s);
}
void main( )
{
double num, result;
int po;
clrscr();
cout << "Enter the number ";
cin >> num;
cout << "Enter the power to be calculated ";
cin >> po;
result = power(num,po);
cout << "\nResult when the power is given "<<result;
result = power(num);
cout << "\nResult when the power is not given "<<result;
}
2. (a) What do you understand about a base class and a derived class ? If a base class and a derived class
each include a member function with the same name and arguments, which member function will be
called by the object of the derived class if the scope operator is not used ? 2
(b) Considering the following specifications : 4
Structure name Data Type Size
Name first array of character 40
mid array of character 40
Examination Paper 3
(iii) The constructor is :
P_rec :: P_rec( )
{
cout << "Enter the first name ";
cin >> name.first;
cout << "Enter the middle name ";
cin >> name.mid;
cout << "Enter the last name ";
cin >> name.last;
cout << "Enter the area code ";
cin >> phone.area;
cout << "Enter the exchange ";
cin >> phone.exch;
cout << "Enter the number ";
cin >> phone.numb;
}
(iv) The member method is :
void P_rec::display_rec( )
{
cout << "The first name "<< name.first;
cout << "The middle name "<< name.mid;
cout << "The last name "<< name.last;
cout << "The area code "<< phone.area;
cout << "The exchange "<< phone.exch;
cout << "The number "<< phone.numb;
}
(c) (i) The name specifies the above class as SmallObj.
(ii) The data members are some and more and their access scope is private, i.e., they can be
available inside the class only.
(iii) The member functions are err_1( ) with private access and Xdata( ), Ydata( ) with public access,
i.e., err_1( ) is available inside the class only while Xdata( ) and Ydata( ) cane be call outside the
class also.
(iv) The member function of the SmallObj that sets data is Xdata( ).
3. (a) Define Queue and Stack. 2
(b) Given the following class : 4
char *msg[ ] = {"over flow", "under flow"};
class Stack
{
int top, //the stack pointer
stk[5]; //the elements
void err_rep(int e_num) { cout << msg[e_num]; } //report error message
public:
void init( ) { top = 0; } //intialize the stack pointer
void push(int); //put new value in stk
void pop( ); //get the top value
};
Define push outside the Stack. In your definition take care of overflow condition. Function push has
to invoke err_rep to report over flow.
(c) Use a stack to evaluate the following postfix expression and show the content of the stack after
execution of each operation. Don’t write any code. Assume as if you are using push and pop member
functions of the stack. 3
AB–CD+E*+ (whereA =5, B=3, C=5, D=4 and E=2)
Examination Paper 5
(9) +
20 Pop (18)
Pop (2)
Push (18+2)
(d) A[I][J] = B+W((I–L1)+M(J–L2))
B = C0
A[10][5] = C0 +1((10–1) + 20(5–1))
2000 = C0 +1(9+20 x 4)
2000 = C0 +89
C0 = 2000–89 = 1911
(e) Using bubble sort, the sequence of steps are :
1st iteration :
42 Swap 29 29
29 42 No 42
74 74 change 74 Swap
11 11 11
65 65 65
58 58 58
29 29 29
42 42 42
11 11 11
74 Swap 65 65
65 74 Swap 58
58 58 74
2nd iteration :
29 No 29 29 29
42 change 42 Swap 11 11
11 11 42 No 42
65 65 65 change 65 Swap
58 58 58 58
74 74 74 74
3rd iteration :
29 29 Swap 11
11 11 29
42 42 42
58 58 58
65 No 65 65
74 change 74 74
4. (a) What is the difference between get( ) and read( ) ? 1
Examination Paper 7
(iv) SELECT AVG(CostPerItem) FROM LAB WHERE DateofPurchase < {1/1/99}
Ans. (a) Relation. A relation is two-dimensional table.
Relational data model. In this model data is stored in conceptual tables in which rows are instances
and columns are fields. E.F.Codd of the IBM proposed the relational model.
(b) SELECT itemname FROM lab WHERE dateofpurchase > {31/10/97}
(c) SELECT itemname, costperitem, quantity FROM lab WHERE date( ) - dateofpurchase < warranty
(d) SELECT itemname FROM lab ORDER BY dateofpurchase WHERE quantity > 3
(e) SELECT itemname, costperitem, quantity FROM lab WHERE date( ) - dateofpurchase > warranty
(f) SELECT COUNT(*) FROM lab WHERE costperitem > 10000
(g) INSERT INTO lab VALUES(8, “VCR”, 10000, 2, {2/2/2000}, 1, 2)
(h) (i) 1 (ii) 1 (iii) 80000 (iv) 23800.00
6. (a) State the associative law and verify the law using truth table. 2
(b) Prove XY + YZ + YZ' = Y, algebraically. 2
(c) Obtain the simplified form of a Boolean expression using Karnaugh map. 1
F(x, y, z) = Σ(2, 3, 6, 7)
(d) Give truth table of Full Adder. Draw a logic circuit for Full Adder. 2
(e) Represent the Boolean expression X(Y'+Z) with the help of NOR gate only. 1
(f) Given the following truth table, write the sum of products form of the function F(x,y,z) 2
x y z F
0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1
Ans. (a) The associative law states that :
(i) X + (Y + Z) = (X + Y) +Z
(ii) X.(Y.Z) = (X.Y).Z
The truth tables are :
(i) X Y Z Y+Z X+Y X+(Y+Z) (X+Y)+Z
0 0 0 0 0 0 0
0 0 1 1 0 1 1
0 1 0 1 1 1 1
0 1 1 1 1 1 1
1 0 0 0 1 1 1
1 0 1 1 1 1 1
1 1 0 1 1 1 1
1 1 1 1 1 1 1
Hence proved.
8 Together with ® Computer Science (C++) – XII
(ii) X Y Z Y.Z X.Y X.(Y.Z) (X.Y).Z
0 0 0 0 0 0 0
0 0 1 0 0 0 0
0 1 0 0 0 0 0
0 1 1 1 0 0 0
1 0 0 0 0 0 0
1 0 1 0 0 0 0
1 1 0 0 1 0 0
1 1 1 1 1 1 0
Hence proved.
(b) L.H.S = XY + YZ + YZ' = XY + Y(Z+Z') [ X + X' = 1]
= XY + Y = Y(X + 1) = Y [ X + 1 = 1]
(c) F(x, y, z) = Σ(2, 3, 6, 7)
yz
x 00 01 11 10
0 1 1
1 1 1
F=Y
(d) The truth table of Full Adder is :
x y z sum carry
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
The logic circuit of Full Adder is :
x
y sum = x + y + z
z
carry = x . y + x . z + z . y
Examination Paper 9
(e) X(Y'+Z)
Take the double complement.
= [X(Y'+Z)]''
= [X'+(Y'+Z)']'
X'
i.e., Xy
F y
Y'
Yy
Z y (Y'+Z)'