Documente Academic
Documente Profesional
Documente Cultură
[Delhi]
Maximum Marks : 70 Duration : 3 Hours
Note. All the questions are compulsory.
Programming Language : C++
1. (a) Encapsulation is one of the major properties of OOP. How is it implemented in C++ ? 2
(b) Name the header file to be included for the use of following built-in functions.
(i) frexp() (ii) toupper() 1
(c) Identify the syntax error(s), if any (giving reason for error) :
class ABC
{
int x = 10;
float y;
ABC( ) {y = 5; }
~ABC() { }
};
void main()
{
ABC a1, a2;
} 2
(d) Give the output of the following program (Assume all required header files are included in the
program) :
void main()
{
int array[] = {2, 3, 4, 5};
int *arptr = array;
int value = *arptr; cout << value << '\n';
value = *arptr++; cout << value << '\n';
value = *arptr; cout << value << '\n';
value = *++arptr; cout << value << '\n';
} 2
(e) Give the output of the following program :
#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';
} 3
(f) Write a function named SUMFUN(), with arguments n and N, which returns the sum of the following
series : x2 x3 x4 x5 x6 xn 4
1– + – + – +.....+
2 3 4 5 6 N
Examination Paper 1
Ans. (a) OOP encapsulates data (attributes) and functions (behaviour) into packages called objects; the data
and functions of an object are intimately tied together. Objects have the property of information
hiding.
(b) (i) math.h (ii) ctype.h
(c) The errors are :
class ABC
{
int x = 10; // Error 1
float y;
ABC( ) {y = 5; }
~ABC() { }
};
void main()
{
ABC a1, a2; // Error 2
}
Error 1 : Cannot initialize a class member here
Error 2 : ABC::ABC() is not accessible
Destructor for ABC is not accessible
a1 is assigned a value that is never used.
(d) The output is as :
2
2
3
4
(e) The output is as :
3, 30
7, 3
4, 40
4, 3
(f) // Function to find the sum of series
float SUMFUN(int x, int N)
{
float s = 1, t = 0, t1, t2;
int i,j=1;
for(i=2;i<(N+1);i++)
{
t = pow(-1,j);
t1 = pow(x,i)/i;
t2 = t * t1;
s = s + t2;
j++;
}
return(s);
}
2. (a) Illustrate the use of “self-referential structures” with the help of an example. 4
(b) Define a class BOOK with the following specifications :
Private members of the class BOOK are
BOOK_NO integer type
BOOK_TITLE 20 characters
PRICE float (price per copy)
Examination Paper 3
public:
void INPUT();
void PURCHASE();
};
float BOOK::TOTAL_COST(int N)
{
return(PRICE*N);
}
void BOOK::INPUT()
{
cout<<"Enter the book number ";
cin>>BOOK_NO;
cout<<"Enter the book title ";
gets(BOOK_TITLE);
cout<<"Enter the price of the book ";
cin>>PRICE;
}
void BOOK::PURCHASE()
{
int N;
cout << "Input the number of copies to be purchased ";
cin>>N;
cout<<"The Total cost to be paid is "<<TOTAL_COST(N);
}
(c) The output is as :
Name :KALU
Age :40
Name :RAJU
Age :53
3. (a) Given two arrays of integers A and B of sizes M and N respectively. Write a function named MIX()
which will produce a third array named C, such that the following sequence is followed.
(1) All even numbers of A from left to right are copied into C from left to right.
(2) All odd numbers of A from left to right are copied into C from right to left.
(3) All even numbers of B from left to right are copied into C from left to right.
(4) All odd numbers of B from left to right are copied into C from right to left.
A, B and C are passed as arguments to MIX().
e.g., A is {3, 2, 1, 7, 6, 3} and B is {9, 3, 5, 6, 2, 8, 10}
the resultant array C is {2, 6, 6, 2, 8, 10, 5, 3, 9, 3, 7, 1, 3} 4
(b) An array X[7][20] is stored in memory with each element requiring 2 bytes of storage. If the base
address of the array is 2000, calculate the location of X[3][5] when the array X is stored in Column
major order. 2
Note : X[7][20] means valid row indices are 0 to 6 and valid column indices are 0 to 19.
(c) Write a user defined function named Upper_half() which takes a two dimensional array A, with sizeN
rows and N columns as argument and print the upper half of the array. 3
e.g.,
2 3 1 5 0 2 3 1 5 0
7 1 5 3 1 1 5 3 1
If A is 2 5 7 8 1 The output will be 7 8 1
0 1 5 0 1 0 1
3 4 9 1 5 5
Examination Paper 5
(c) // Function Upper_half() which produces the upper half of an array.
void Upper_half(int A[10][10],int n)
{
int k = 0, j, row = 8, col = 1;
for(int i=0;i<n;i++)
{
col = i+1;
row++;
for( j=i;j<n;j++)
{
gotoxy(col,row);
cout<<A[i][j]<< " ";
col++;
}
}
}
(d) The stack operation is :
Operation Stack Status Output
( (
TRUE ( TRUE
&& (&&
FALSE (&& TRUE FALSE
) – TRUE FALSE &&
| | TRUE FALSE &&
! || ! TRUE FALSE &&
( || ! ( TRUE FALSE &&
FALSE || ! ( TRUE FALSE && FALSE
| || ! ( || TRUE FALSE && FALSE
TRUE || ! ( || TRUE FALSE && FALSE TRUE
) || ! TRUE FALSE && FALSETRUE ||
| TRUE FALSE && FALSETRUE || !
Empty stack TRUE FALSE && FALSETRUE || ! ||
(e) // The structure, PUSH() and POP() function of the stack.
// Declares a stack structure
struct node
{
int roll;
int age;
node *link;
};
// Function body for add stack elements
node *push(node *top, int val,int tage)
{
node *temp;
temp = new node;
temp->roll = val;
temp->age = tage;
temp->link = NULL;
if(top ==NULL)
top = temp;
else
Examination Paper 7
void BUS :: Write(BUS F)
{
fstream Ffile;
Ffile.open("Bus.dat",ios::app);
Ffile.write((char *)&F,sizeof(BUS));
Ffile.close();
}
void BUS::Show()
{
cout << "\n Flight No : "<<bus_no;
cout << "\n Destination : "<<destination;
cout << "\n Distance : "<<distance;
}
5. (a) What are DDL and DML ? 2
(b) Write SQL commands for (i) to (vii) on the basis of the table STUDENT
Table : STUDENT
1234567890123456789012345678901212345678901234567890123456789012123456789012345678901234567890121234
1234567890123456789012345678901212345678901234567890123456789012123456789012345678901234567890121234
1234567890123456789012345678901212345678901234567890123456789012123456789012345678901234567890121234
1234567890123456789012345678901212345678901234567890123456789012123456789012345678901234567890121234
Student No. Class Name GAME Grade SUPW Grade
1234567890123456789012345678901212345678901234567890123456789012123456789012345678901234567890121234
1234567890123456789012345678901212345678901234567890123456789012123456789012345678901234567890121234
1234567890123456789012345678901212345678901234567890123456789012123456789012345678901234567890121234
1234567890123456789012345678901212345678901234567890123456789012123456789012345678901234567890121234
1234567890123456789012345678901212345678901234567890123456789012123456789012345678901234567890121234
10 7 Sameer Cricket B Photography A
1234567890123456789012345678901212345678901234567890123456789012123456789012345678901234567890121234
1234567890123456789012345678901212345678901234567890123456789012123456789012345678901234567890121234
1234567890123456789012345678901212345678901234567890123456789012123456789012345678901234567890121234
1234567890123456789012345678901212345678901234567890123456789012123456789012345678901234567890121234
11 8 Sujit Tennis A Gardening C
1234567890123456789012345678901212345678901234567890123456789012123456789012345678901234567890121234
1234567890123456789012345678901212345678901234567890123456789012123456789012345678901234567890121234
1234567890123456789012345678901212345678901234567890123456789012123456789012345678901234567890121234
1234567890123456789012345678901212345678901234567890123456789012123456789012345678901234567890121234
12 7 Kamal Swimming B Photography B
1234567890123456789012345678901212345678901234567890123456789012123456789012345678901234567890121234
1234567890123456789012345678901212345678901234567890123456789012123456789012345678901234567890121234
1234567890123456789012345678901212345678901234567890123456789012123456789012345678901234567890121234
1234567890123456789012345678901212345678901234567890123456789012123456789012345678901234567890121234
13 7 Veena Tennis C Cooking A
1234567890123456789012345678901212345678901234567890123456789012123456789012345678901234567890121234
1234567890123456789012345678901212345678901234567890123456789012123456789012345678901234567890121234
1234567890123456789012345678901212345678901234567890123456789012123456789012345678901234567890121234
1234567890123456789012345678901212345678901234567890123456789012123456789012345678901234567890121234
14 9 Archana Basketball A Literature A
1234567890123456789012345678901212345678901234567890123456789012123456789012345678901234567890121234
1234567890123456789012345678901212345678901234567890123456789012123456789012345678901234567890121234
1234567890123456789012345678901212345678901234567890123456789012123456789012345678901234567890121234
1234567890123456789012345678901212345678901234567890123456789012123456789012345678901234567890121234
15 10 Arpit Cricket A Gardening C
1234567890123456789012345678901212345678901234567890123456789012123456789012345678901234567890121234
1234567890123456789012345678901212345678901234567890123456789012123456789012345678901234567890121234
(i) Display the names of the students who are getting grade ‘C’ in either GAME or SUPW. 1
(ii) Display the number of students getting grade ‘A’ in Cricket. 1
(iii) Display the different games offered in the school. 1
(iv) Display the SUPW taken up by the students, whose name starts with ‘A’. 1
(v) Add a new column named ‘Marks’. 1
(vi) Assign a value 200 for Marks for all those who are getting grade ‘B’ or above in GAME. 1
(vii) Arrange the whole table in the alphabetical order of SUPW. 1
(c) If R1 is a relation with 5 rows and R2 is a relation with 3 rows, how many rows will the Cartesian
product of R1 and R2 have ? 1
Ans. (a) DDL. DDL is the part of SQL. It stands for data definition language. It provides statements for
creation and deletion of the database. For example, CREATE TABLE, ALTER TABLE.
DML. DML is also the part of the SQL. It stands for data manipulation language. It provides statements
for manipulating the database. It includes commands to insert, delete and modify tuples in the
database. For example, INSERT INTO, DELETE FROM, UPDATE.
(b) (i) SELECT name FROM student WHERE grade = ‘C’ OR grade1 = ‘C’
(ii) SELECT COUNT(grade) FROM student WHERE grade = ‘A’AND game = ‘Cricket’
(iii) SELECT DISTINCT game FROM student
(iv) SELECT supw FROM student WHERE name LIKE ‘A%’
(v) ALTER TABLE studentADD (marks NUMBER(3))
(vi) UPDATE student SET marks = 200 WHERE grade IN (‘A’, ‘B’)
(vii) SELECT * FROM student ORDER BY supw
(c) 15
6. (a) State and verify Involution law. 2
Examination Paper 9
Ans. (a) On Internet it is not necessary that all the packets will follow the same path from source to destination.
A special machine called router tries to load balance between various paths that exist on networks.
(b) When we connect number of LANs to from one WAN the network, which is used as a backbone to
connect the LANs is called backbone network.
(c) The two switching circuits are : Circuit switching and Message switching.
Circuit Switching : In this technique, first complete physical connection between two computers is
established and then data is transmitted from the source computer to the destination computer.
(d) The circular topology has :
Short cable length. In circular topology less connections will be needed which increase network
reliability. The amount of cable needed in this topology is comparable to bus and small relative to star
topologies.
The star topology has : One Device per connection and Long cable length.