Вы находитесь на странице: 1из 69

DAV PUBLIC SCHOOLS, ODISHA, ZONE-II

QUESTION BANK-2015-16
CLASS: XII-COMPUTER SCIENCE (083)

ALL THE BEST TO OUR BELOVED STUDENTS

0|Page

CHAPTER-I & II C++ REVISION TOUR & OOPS


1 Marks questions
1.

2.

Name the header files that shall be needed for the following code:
void main( )
{
char String[ ] = String;
cout << setw(2)<<String;
}
Which C++ header file(s) will be essentially required to be include to run/execute the following
C++ code:

3.

void main()
{
int Rno=24; char name[ ]=Alma Mater;
cout<<setw(10)<<Rno<<setw(20)<<name<<endl;
}
Name the header files that shall be needed for the following code:

4.

void main( )
{
char word[]=Board Exam;
cout<<setw(20)<<word;
}
Name the header file(s) that shall be needed for successful compilation of the following C++ code.

5.

6.

void main( )
{
char String[20];
gets(String);
strcat(String,CBSE);
puts(String);
}
Name the header file(s) that shall be needed for successful compilation of the following C++ code.
void main( )
{
char Text[40];
strcpy(Text,AISSCE);
puts(Text); }
Which C++ header file(s) will be essentially required to execute the following C++ code:
void main()
{
int x=8; float res;
res=sqrt(x);
cout<<setprecision(2)<<res;
}

1|Page

7.

8.

9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.

Name the header files required to execute the following code:


void main()
{
double d = 32.5;
char c = 3;
if(isalnum(c))
cout<<ceil(d);
}
Name the header file(s) , which are not necessary to run the following program segment :
#include<iostream.h>
#include<stdio.h>
#include<ctype.h>
#include<math.h>
void main( )
{ char ch=m , ch1 ;
if(islower(ch))
ch1=toupper(ch);
else
ch1=@ ;
cout<<ch<< turned to<<ch1<<endl; }
Write the name of the header files to which the following built in functions belong:
i) getc()
ii) isalnum()
Name the header file to which the following below:
(i) abs( )
(ii) isupper( )
Name the header file to which the following belong:
(i) pow ( )
(ii)random( )
Name the header files to which the following belong:
(i) abs( )
(ii) strcmp( )
Name the header files to which the following belong: [AI 2005]
(i) puts( )
(ii) isalnum( )
Write the names of the header files to which the following belong:
(i) gets( )
(ii) strcmp( )
(iii) abs( )
(iv) isalnum( )
Name the header file, to which the following built-in function belongs:
(i) strcmp( ) (ii)getc( )
Name the header files of C++ to which the following functions belong:
(i)get( )
(ii)open( )
(iii)abs( )
(iv)strcat( )
Name the header file to be included for the use of the following built in functions:
(i)getc( )
(ii)strcat()
Name the header file, to which following built in function belong:
(i) isupper( ) ( ii)setw()
(iii)exp( )
(iv)strcmp( )
Why main( ) function is so special. Give two reasons?
Name the header file of C++ to which following functions belong.
(i)strcat( )
(ii) scanf( )
(iii) getchar( )
(iv)clrscr( )
Name the header files, to which the following built in functions belongs to:
(i)cos( )
(ii)setw( )
(iii)toupper( )
(iv)strcpy( )
Name the header files, to which the following built in functions belongs to:
(i)cos( )
(ii)setw( )
(iii)toupper( )
(iv)strcpy( )
Name the header file to, which following built-in functions belong:
(i) strcpy()
(ii) isdigit()
(iii) log()
(iv) puts()

2|Page

2 Marks/ 3 Marks questions:


1.

2.

3.

4.

Rewrite the following program after removing the syntactical error(s) if any. Underline each
correction.
#include<iostream.h>
void main( )
{ F = 10, S = 20;
test(F;S);
test(S); }
void test(int x, int y = 20)
{ x=x+y;
count<<x>>y;}
Find the output of the following program:
#include<iostream.h>
void main( )
{ int U=10,V=20;
for(int I=1;I<=2;I++)
{ cout<<[1]<<U++<<&<<V 5 <<endl;
cout<<[2]<<++V<<&<<U + 2 <<endl; } }
Rewrite the following C++ program after removing the syntax error(s) if any. Underline each
correction.
include<iostream.h>
class FLIGHT
{
Long FlightCode;
Char Description[25];
public
void addInfo()
{
cin>>FlightCode; gets(Description);
}
void showInfo()
{
cout<<FlightCode<<:<<Description<<endl;
} };
void main( )
{ FLIGHT F;
addInfo.F();
showInfo.F; }
Rewrite the following program after removing the syntax error(s) if any. Underline each
correction.
#include<iostream.h>
void main( )
{ One=10,Two=20;
Callme(One,Two);
Callme(Two); }
void Callme(int Arg1,int Arg2)
{ Arg1=Arg1+Arg2;
count<<Arg1>>Arg2; }

3|Page

5.

6.

7.

8.

In the following program, find the correct possible output(s)from the options:
#include<stdlib.h>
#include<iostream.h>
void main( )
{ randomize( );
char City[ ][10]={DEL, CHN, KOL, BOM, BNG};
int Fly;
for(int I=0; I<3;I++) {
Fly=random(2) + 1;
cout<<City[Fly]<< :; } }
Outputs:
(i) DEL : CHN : KOL:
(ii) CHN: KOL : CHN:
(iii) KOL : BOM : BNG:
(iv) KOL : CHN : KOL:
In the following program, find the correct possible output(s)from the options:
#include<stdlib.h>
#include<iostream.h>
void main( )
{ randomize( );
char Area[ ][10]={ NORTH, SOUTH, EAST, WEST};
int ToGo;
for(int I=0; I<3;I++) {
ToGo=random(2) + 1;
cout<<Area[ToGo]<<:; } }
Outputs:
(i) SOUTH : EAST : SOUTH : (ii) NORTH : SOUTH : EAST :
(iii) SOUTH : EAST : WEST : (iv) SOUTH : EAST : EAST :
Rewrite the following program after removing the syntactical error(s) if any. Underline each
correction.
#include<iostream.h>
const int Max 10;
void main()
{ int Numbers[Max];
Numbers = {20,50,10,30,40};
for(Loc=Max-1;Loc>=10;Loc--)
cout>>Numbers[Loc]; }
Observe the following program RANDNUM.CPP carefully. If the value of VAL entered by the
User is 10, choose the correct possible output(s) from the options from i) to iv) and justify your
option.
#nclude<iostream.h>
#include<stdlib.h>
#include<time.h>
void main()
{
randomize();
int VAL, Rnd; int n=1;
cin>>VAL;
Rnd=8 + random(VAL) * 1;
while(n<=Rnd)
{
cout<<n<< \t;
n++;
}

4|Page

9.

10.

10.

}
output options:
i) 1 2 3 4 5 6 7 8 9 10 11 12 13
ii) 0 1 2 3
iii) 1 2 3 4 5
iv) 1 2 3 4 5 6 7 8
Observe the following program GAME.CPP carefully, if the value of Nu entered by the user is 5,
choose the correct possible output(s) from the options i to iv and justify your answer:
#include<stdlib.h>
#include<iostream.h>
void main()
{
randomize( );
int Nu, Rndnum;
cin>>Nu;
rndnum=random(Nu)+5;
for(int n=1; n<=Rndnum;n++)
cout<<n<< ;
}
i) 1 2 3 4
ii) 1 2 3 4 5 6 7 8 9
iii) 1 2
iv) 1 2 3
In the following program, find the correct possible output(s) from the options:
#include<stdlib.h> #include<iostream.h>
void main()
{
randomize();
char Area[][10]={NORTH,SOUTH,EAST,WEST};
int ToGo;
for(int I=0;I<3;I++)
{
ToGo=random(2)+1;
cout<<Area[ToGo]<<:;
}
}
a)
SOUTH:EAST:SOUTH:
b)
NORTH:SOUTH:EAST:
c)
SOUTH:EAST:WEST:
d)
SOUTH:EAST:EAST:
In the following C++ program what is expected value of myscore from options (i) to (iv) given
below.
#include<stdlib.h>
#include<iostream.h>
void main( )
{
randomize( );
int score[]={ 25, 20,34,56, 72, 63};
int myscore=score[2+random(2)];
cout<<myscore<<endl;
}
i) 25
ii) 34
iii) 20
iv) None of these

5|Page

11.

12.

13.

Find the output of the following program


#include<iostream.h>
void main( )
{ long NUM=1234543;
int F=0,S=0;
do
{ int R=NUM % 10;
if (R %2 != 0)
F += R;
else
S += R;
NUM / = 10;
} while (NUM>0);
cout<<F-S; }
Rewrite the following program after removing the syntactical error(s), if any. Underline each
correction.
#include<iostream.h>
const int Multiple 3;
void main( )
{ value = 15;
for(int Counter = 1;Counter = <5;Counter ++, Value -= 2)
if(Value%Multiple = = 0)
cout<<Value * Multiple;
cout<<end1;
else
cout<<Value + Multiple <<endl; }
Find the output of the following program
#include<iostream.h>
#include<string.h>
#include<ctype.h>
void Convert(char Str[ ],int Len)
{ for(int Count=0;Count<Len;Count++)
{ if(isupper(Str[Count]))
Str[Count]=tolower(Str[Count]);
else if (islower(Str[Count]))
Str[Count]=toupper(Str[Count]);
else if(isdigit(Str[Count]))
Str[Count]=Str[Count]+1;
else Str[Count]=.*.;
}}
void main( )
{ char Text[ ]=CBSE Exam 2005;
int Size = strlen(Text);
Convert(Text,Size);
cout<<Text<<endl;
for(int C=0,R=Size . 1;C<=Size/2;C++,R--)
{ char Temp=Text[C];
Text[C]=Text[R];
Text[R]=Temp; }
cout<<Text<<endl; }

6|Page

14.

15.

16.

17.

The following code is from a game, which generate a set of 4 random numbers. Praful is playing
this game, help him to identify the correct option(s) out of the four choices given below as the
possible set of such numbers generated from the program code so that he wins the game. Justify
your answer.
#include<iostream.h>
#include<stdlib.h>
const int LOW=25;
void main()
{ randomize();
int POINT=5, Number;
for(int I=1;I<=4;I++)
{ Number=LOW+random(POINT);
cout<<Number<<":" <<endl;
POINT--; } }
(i) 29:26:25:28:
(ii)24:28:25:26:
(iii) 29:26:24:28;
(iv)29:26:25:26:
Rewrite the following program after removing the syntactical errors (if any). Underline each
correction.
#include [iostream.h]
class MEMBER
{
int Mno;float Fees;
PUBLIC:
void Register(){cin>>Mno>>Fees;}
void Display{cout<<Mno<<" : "<<Fees<<endl;}
};
void main()
{
MEMBER M;
Register();
M.Display();
}
Find the output of the following program; [Delhi 2008]
#include<iostream.h>
#include<ctype.h>
void main( )
{ char Text[ ] = Mind@work!;
for(int I=0; Text[I]!=\0;I++)
{ if(!isalpha(Text[I]))
Text[I]=*;
else if(isupper(Text[I]))
Text[I]=Text[I]+1;
else
Text[I] = Text[I+1]; }
cout<<Text; }
Find the output of the following program:
#include<iostream.h>
#include<ctype.h>
void main( )
{ char Mystring[ ] = "what@OUTPUT!";

7|Page

18.

19.

20.

for(int I=0; Mystring[I]!=\0;I++)


{ if(!isalpha(Mystring[I]))
Mystring[I]=*;
else if(isupper(Mystring[I]))
Mystring[I]=Mystring[I]+1;
else
Mystring[I] =Mystring[I+1];
} cout<<Mystring; }
Find the output of the following program.
#include<iostream.h>
void Withdef(int HisNum=30)
{ for(int I=20;I<=HisNum;I+=5)
cout<<I<<,;
cout<<endl; }
void Control(int &MyNum)
{ MyNum+=10;
Withdef(MyNum); }
void main()
{ int YourNum=20;
Control(YourNum);
Withdef();
cout<<.Number=.<<YourNum<<endl; }
Find the output of the following program:
#include<iostream.h>
void Indirect(int Temp=20)
{ for(int I=10;I<=Temp;I+=5)
cout<<I<<,;
cout<<endl; }
void Direct(int &Num)
{ Num+=10;
Indirect(Num); }
void main( )
{ int Number=20;
Direct(Number);
Indirect( );
cout<<Number =<<Number<<endl; }
Find the output of the following program:
#include<iostream.h>
#include<ctype.h>
void Secret(char Msg[],int N);
void main( )
{ char SMS= rEPorTmE;
Secret(SMS,2);
cout<<SMS<<endl; }
void Secret(char Msg[],int N)
{ for(int c=10;Msg[]1=\0;c++) 15
if(c%2==0)
Msg[c]= Msg[c]+N;
else if (isupper(Msg[c]))

8|Page

21.

22.

23.

Msg[c]=tolower(Msg[c]);
else
Msg[c]= Msg[c]-N; }
Find the output of the following program: [CBSE 2010]
#include<iostream.h>
struct three_d
{ int x,y,z; };
void movein(three_d &t, int step=1)
{ t.x+=step;
t.y+=step;
t.z+=step; }
void moveout(three_d &t, int step=1)
{ t.x-=step;
t.y+=step;
t.z-=step; }
void main()
{ three_d t1={10,20,5},t2={30,10,40};
movein(t1);
moveout(t2,5);
cout<<t1.x<<","<<t1.y<<","<<t1.z<<endl;
cout<<t2.x<<","<<t2.y<<","<<t2.z<<endl;
movein(t2,10);
cout<<t2.x<<","<<t2.y<<","<<t2.z<<endl; }
Write the output of the following program:
#include<iostream.h>
int func(int &x,int y=10)
{ if(x%y==0) return ++x;else return y- -; }
void main( )
{ int p=20,q=23;
q=func(p,q);
cout<<p<<q<<endl;
p=func(q);
cout<<p<<q<<endl;
q=func(p);
cout<<p<<q<<endl; }
Find the output of the following program. [CBSE 2010]
#include<iostream.h>
#include<ctype.h>
void Mycode(char Msg[],char ch)
{ for(int cnt=0;Msg[cnt]!='\0';cnt++)
{ if(Msg[cnt]>='B'&& Msg[cnt]<='G')
Msg[cnt]=tolower(Msg[cnt]);
else
if(Msg[cnt]=='A'||Msg[cnt]=='a')
Msg[cnt]=ch;
else
if(cnt%2==0)
Msg[cnt]=toupper(Msg[cnt]);
else
Msg[cnt]=Msg[cnt-1];

9|Page

24.

25.

26.

27.

}}
void main()
{ char MyText[]="ApEACeDriVE";
Mycode(MyText,'@');
cout<<"NEW TEXT: "<<MyText<<" "<<endl; }
Rewrite the following program after removing the syntactical errors (if any). Underline each
correction.
#include [iostream.h]
class MEMBER
{
int Mno;float Fees;
PUBLIC:
void Register(){cin>>Mno>>Fees;}
void Display{cout<<Mno<<" : "<<Fees<<endl;}
};
void main()
{
MEMBER M;
Register();
M.Display();
}
Rewrite the following program after removing the error(s), if any. Underline each correction.
#include <iostream.h>
void main( )
{
int x, sum =0;
cin>>n;
for (x=1;x<100, x+=2)
if x%2=0
sum+=x;
cout<< sum= >>sum;
}
Rewrite the following codes after removing errors, if any, in the following snippet. Explain each
error.
#include<iostream.h>
void main( )
{
int x[5], *y, z[5]
for (i = 0; i < 5; i ++
{
x[i] = i;
z[i] = i + 3;
y = z;
x = y;
}
Rewrite the following program after removing the error(s), if any. Underline each correction.
#include <iostream.h>
void main( )
{
int x, sum =0;

10 | P a g e

28.

29.

30.

cin>>n;
for (x=1;x<100, x+=2)
if x%2=0
sum+=x;
cout<< sum= >>sum;
}
Rewrite the following program after removing the syntactical error(s), if any Underline each
correction:
#include <iostream.h>
void main( )
{
struct Book
{
char Book_name[20];
char Publisher_name[20];
int Price = 170;
} New Book;
gets(Book_name);
gets(Publisher_name);
}
Will the following program execute successfully? If no, state the reason(s) :
#include<iostream.h>
#include<stdio.h>
#define int M=3;
void main( )
{
const int s1=10;
int s2=100;
char ch;
getchar(ch);
s1=s2*M;
s1+M = s2;
cout<<s1<<s2 ;
}
Rewrite the following program after removing the syntactical errors (if any). Underline each
correction.
#include<iostream.h>
void main()
{
char arr{} = {12, 23, 34, 45};
int ptr = arr;
int val = *ptr; cout << *val << endl;
val = *ptr++; cout << val << endl;
val = *ptr : cout << val >> endl;
val = *++ptr; cout << val << endl;
}

11 | P a g e

CHAPTER III: FUNCTION OVERLOADING

2 Marks/ 3 Marks questions:


1.
2.
3.
4.

What do you understand by function overloading? Give an example illustrating its use in a C++
program.
What is operator overloading ? Explain with example.
Is function overloading possible with different return type but having the same arguments ?
Give the output of the following program :
#include <iostream.h>
void display(double d)
{
cout << "Real : " << d << endl;
}
void display(int i)
{
cout << "Integer : " << i << endl;
}
void display(char Ch)
{
cout << "Character : " << Ch << endl;
}
void display(char Ch[ ])
{
cout << "String : " << Ch << endl;
}
void main()
{
double F = 3.1416;
display(A);
display(F);
display("String");
display(45);
}

12 | P a g e

CHAPTER IV & V: CLASSES AND OBJECTS/CONSTRUCTOR & DESTRUCTOR


2 Marks questions:
1.
2.
3.

4.

What do you understand by constructor and destructor functions used in classes? How are these
functions different from other member functions ?
What do you understand by default constructor and copy constructor functions used in classes?
How are these functions different from normal constructors?
Given the following C++ code, answer the questions (i) & (ii).
class TestMeOut
{
public :
~TestMeOut() // Function 1
{ cout << "Leaving the examination hall " << endl; }
TestMeOut() // Function 2
{ cout << "Appearing for examination " << endl; }
void MyWork() // Function 3
{ cout << "Attempting Questions " << endl; }
};
(i) In Object Oriented Programming, what is Function 1 referred as and when does it get invoked
/ called?
(ii) In Object Oriented Programming, what is Function 2 referred as and when does it get invoked
/ called?
Answer the questions (i) and (ii) after going through the following class:
class Seminar
{
int Time;
public:
Seminar() //Function 1
{
Time=30;cout<<"Seminar starts now"<<end1;
}
void Lecture() //Function 2
{
cout<<"Lectures in the seminar on"<<end1;
}
Seminar(int Duration) //Function 3
{
Time=Duration;cout<<"Seminar starts now"<<end1;
}
~Seminar()
//Function 4
{
cout<<"Vote of thanks"<<end1;
}
};
i) In Object Oriented Programming, what is Function 4 referred as and when does it get invoked/
called?
ii) In Object Oriented Programming, which concept is illustrated by Function 1 and Function 3
together? Write an example illustrating the calls for these functions.

13 | P a g e

5.

6.

7.

Answer the questions (i) and (ii) after going through the following program
#include<iostream.h>
#include<string.h>
class Bazar
{
char Type[20];
char Product[20];
int Qty;
float Price;
Bazar() //Function 1
{
strcpy (Type,Electronic);
strcpy (Product,Calculator);
Qty = 10;
Price=225;
}
public:
void Disp( ) //Function 2
{
cout<<Type<<-<<Product<<:<<Qty <<@<<Price<<endl;
}
};
void main( )
{
Bazar B; //Statement 1
B.Disp(); //Statement 2
}
(i) Will Statement 1 initialize all the data members for object B with the values given in the Function
1? (Yes OR No). Justify your answer suggesting the correction(s) to be made in the above code.
(ii) What shall be the possible output when the program gets executed? (Assuming, if required the
suggested correction(s) are made in the program)
Given a class as follows:
class Match
{
int Time;
int Points;
public:
Match(int y, int p) //Conctructor1
{
Time=y;
Points =p;
}
Match(Match &M); // Constructor 2
};
(i) Create an object, such that it invokes Constructor 1.
(ii) Write complete definition for Constructor 2.
Answer the questions (i) and (ii) after going through the following class:
class player
{
int health;

14 | P a g e

int age;
public:
player() { health=7; age=17 } //Constructor1
player(int h, int a) {health =h; age = a ; } //Constructor2
player( player &p) { } //Constructor3
~player() { cout<<Memory Free; } //Destructor
};
void main(){
player p1(9,26); //Statement1
player p3 = p1; //Statement3
}
(i) When p3 object created specify which constructor invoked and why?
(ii) Write complete definition for Constructor3?

4 Marks questions:
1.

Define a class TEST in C++ with following description:


Private Members
TestCode of type integer
Description of type string
NoCandidate of type integer
CenterReqd (number of centers required) of type integer
A member function CALCNTR() to calculate and return the number of centers as
(NoCandidates/100+1)
Public Members
A function SCHEDULE() to allow user to enter values for TestCode, Description, NoCandidate &
call function CALCNTR() to calculate the number of Centres
A function DISPTEST() to allow user to view the content of all the data members

2.

Define a class in C++ with following description:


Private Members
A data member Flight number of type integer
A data member Destination of type string
A data member Distance of type float
A data member Fuel of type float
A member function CALFUEL() to calculate the value of Fuel as per the following criteria:
Distance
Fuel
<=1000 500
more than 1000 and <=2000 1100
More than 2000 2200
Public Members
" A function FEEDINFO() to allow user to enter values for Flight Number, Destination, Distance &
call function CALFUEL() to calculate the quantity of Fuel
" A function SHOWINFO() to allow user to view the content of all the data members
Define a class Clothing in C++ with the following descriptions:
Private Members:
Code of type string
Type of type string
Size of type integer

3.

15 | P a g e

4.

5.

Material of type string


Price of type float
A function Calc_Price() which calculates and assigns the value of Price as
follows: For the value of Material as COTTON
Type Price (Rs.)
TROUSER 1500
SHIRT 1200
For Material other than COTTON the above mentioned Price gets reduced by 25%.
Public Members:
A constructor to assign initial values of Code, Type and Material with the word NOT ASSIGNED
and Size and Price with 0. A function Enter () to input the values of the data members Code, Type,
Size and Material and invoke the CalcPrice() function. A function Show () which displays the content
of all the data members for a Clothing.
Define a class Travel in C++ with the description given below:
Private Members:
T_Code of type string
No_of_Adults of type integer
No_of_Children of type integer
Distance of type integer
TotalFare of type float
Public Members:
A constructor to assign initial values as follows :
T_Code with the word NULL
No_of_Adults as 0
No_of_Children as 0
Distance as 0
TotalFare as 0
A function AssignFare( ) which calculates and assigns the value of the data member TotalFare as
follows :
For each Adult
Fare (Rs) For Distance (Km)
500 >=1000
300 <1000 & >=500
200 <500
For each Child the above Fare will be 50% of the Fare mentioned in the above table.
For example :
If Distance is 750, No_of_Adults = 3 and No_of_Children = 2
Then TotalFare should be calculated as
No_of_Adults * 300 + No_of_Children * 150
i.e. 3 * 300 + 2 * 150 = 1200
A function EnterTraveK ) to input the values of the data members T_Code, No_of_Adults,
No_of_Children and Distance; and invoke the AssignFare( ) function.
A function ShowTraveK) which displays the content of all the data members for a Travel
Define a class Book with following specifications :
Private members of the class Book are
Book_no
integer
Book_title
20 character
Price
float

16 | P a g e

Total_cost( )

6.

7.

8.

9.

A function to calculate the total cost for N number of copies, where N is


passed to the function as argument.
Public members of the class Book are
Input( )
Function to read Book_no, Book_title and price
Purchase( )
Function to ask the user to input the number of copies to be purchased. It
invokes Total_cost( ) and prints the total cost to be paid by the user.
Define a class RESORT with the following specification :
Private members:
rno
to store room no between 101 and 909
name
to store customer name
charges
to store per day charges
days
to store number of days of stay
compute( )
a function to calculate and rerurn amount as days * charges and if the value
of days*charges is more than 11000 then as 1.02 * days * charges
Public members of class worker
get_info( )
a function to accept values for rno, name, charges, days.
disp_info( )
a function to display rno, name, charges, days and amount(amount to be
displayed by calling function compute( )
Define a class named admission in C++ with the following descriptions:
Private Members:
Ad_no
integer(Ranges 10 2000)
Name
string
Class
string
Fees
Float
Public Members:
Function Read_data( ) to read an object of admission type
Function Display( ) to display the details of an object
Function Draw_nos( ) to choose 2 students randomly and display the details. Use random function
to generate admission nos. to match with ad_no.
Define a class employee with the following specifications :
private members of class employee
empno integer
ename 20 characters
basic, hra, da float
netpay float
calculate() A function to calculate basic + hra + da with float return type
public member function of class employee
havedata() function to accept values for empno, sname, basic, hra, da and invoke
calculate() to calculate netpay.
dispdata() function to display all the data members on the screen.
Define a class Student with the following specifications :
private members :
roll_no integer
name 20 characters
class 8 characters
marks[5] integer
percentage float
Calculate() a function that calculates overall percentage of marks and return the percentage
of marks.
public members :

17 | P a g e

10.

11.

12.

Readmarks() a function that reads marks and invoke the Calculate function.
Displaymarks() a function that prints the marks.
Define a class report with the following specification:
Private members:
adno 4 digit admission number
name 20 characters
marks an array of 5 floating point values
average average marks obtained
getavg() to compute the average obtained in five subjects
Public members :
readinfo() function to accept values for adno, name, marks, and invoke the function
getavg().
displayinfo() function to display all data members on the screen you should give function
definitions.
Declare a class to represent bank account of 10 customers with the following data members. Name
of the depositor, Account number, Type of account (S for Savings and C for Current), Balance
amount. The class also contains member functions to do the following:
(i) To initialize data members
(ii) To deposit money
(iii) To withdraw money after checking the balance (minimum balance is Rs. 1000)
(iv) To display the data members
[Note: You are also required to give detailed function definitions.]
Define a class Play in C++ with the following specifications :
private members of class Play
Playcode integer
Playtitle 25 character
Duration float
Noofscenes integer
public member function of class Play
A constructor function to initialise Duration as 45 and Noofscenes as 5.
NewPlay( ) function to accept values for Playcode and Playtitle.
Moreinfo( ) function to assign the values of Duration and Noofscenes with the help of
corresponding values passed as parameters to this function.
Shoplay( ) function to display all the data members on the screen.

18 | P a g e

CHAPTER VI: INHERITANCE


2 Marks questions:
1.
2.
3.
4.
5.

What is the difference between members in private visibility mode members in protected visibility
in a class? Also, give a suitable C++ code to illustrate the both.
Define multilevel and multiple inheritance in context to object oriented programming. Give a
suitable example to illustrate the same.
What is Inheritance? Give an example in C++ to show its implementation in C++.
How inline member function is different from other member function of a class ?
Differentiate between Multiple and Hierarchical inheritance .

4 Marks questions:
1.

2.

Consider the following declarations and answer the questions given below :
class living_being {
char name[20];
protected:
int jaws;
public:
void inputdata(char, int);
void outputdata();
}
class animal : protected living_being {
int tail;
protected:
int legs;
public:
void readdata(int, int);
void writedata();
};
class cow : private animal {
char horn_size;
public:
void fetchdata(char);
void displaydata();
};
(i) Name the base class and derived class of the class animal.
(ii) Name the data member(s) that can be accessed from function displaydata.
(iii) Name the data member(s) that can be accessed by an object of cow class.
(iv) Is the member function outputdata accessible to the objects of animal class.
Consider the following declarations and answer the questions given below :
class WORLD
{
int H;
protected :
int S;
public :
void INPUT(int);
void OUTPUT();

19 | P a g e

};
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 the objects of class STATE.
(iv) Is the member function OUTPUT() accessible by the objects of the class COUNTRY ?
3.

Consider the following and answer the questions given below :


class A
{
void anyval();
protected :
int x, y;
public :
void getvalA();
void putvalA();
};
class B : protected A
{
int a, b;
protected :
int c, d;
public :
void putvalB( );
};
class C : public B
{
int P;
protected :
int q;
void getval( );
public :
void showval( );
};
(i) Name all the member functions, which are accessible by the objects of class C.
(ii) Name all the protected members of class B.

20 | P a g e

4.

5.

(iii) Name the base class and derived class of class B.


(iv) Name the data members, which are accessible from member functions of class C.
Consider the following and answer the questions given below :
class MNC
{
char Cname[25]; // Company name
protected :
char Hoffice[25]; // Head office
public :
MNC( );
char Country[25];
void EnterDate( );
void DisplayData( );
};
class Branch : public MNC
{
long NOE; // Number of employees
char Ctry[25]; // Country
protected:
void Association( );
public :
Branch( );
void Add( );
void Show( );
};
class Outlet : public Branch
{
char State[25];
public :
Outlet();
void Enter();
void Output();
};
(i) Which classs constructor will be called first at the time of declaration of an object of class
Outlet?
(ii) How many bytes an object belonging to class Outlet require ?
(iii) Name the member function(s), which are accessed from the object(s) of class Outlet.
(iv) Name the data member(s), which are accessible from the object(s) of class Branch.
Answer the questions (i) to (iv) based on the following code :
class CUSTOMER
{
int Cust_no;
char Cust_Name[20];
protected:
void Register();
public:
CUSTOMER();
void Status();
};
class SALESMAN

21 | P a g e

6.

{
int Salesman_no;
char Salesman_Name[20];
protected:
float Salary;
public:
SALESMAN();
void Enter();
void Show();
};
class SHOP : private CUSTOMER , public SALESMAN
{
char Voucher_No[10];
char Sales_Date[8];
public:
SHOP();
void Sales_Entry();
void Sales_Detail();
}
(iii) Write the names of data members which are accessible from objects belonging to class
CUSTOMER.
(iv) Write the names of all the member functions which are accessible from objects belonging to
class SALESMAN.
(v) Write the names of all the members which are accessible from member functions of class SHOP.
(iv) How many bytes will be required by an object belonging to SHOP?
Answer the questions (i) to (iv) based on the following:
class PUBLISHER
{
char Pub[12];
double Turnover;
protected:
void Register();
public:
PUBLISHER();
void Enter();
void Display();
};
class BRANCH
{
char CITY[20];
protected:
float Employees
public:
BRANCH();
void Haveit();
void Giveit();
};
class AUTHOR : private BRANCH , public PUBLISHER
{
int Acode;

22 | P a g e

7.

char Aname[20];
float Amount;
public:
AUTHOR();
void Start();
void Show();
};
(i) Write the names of data members, which are accessible from objects belonging to class
AUTHOR.
(ii) Write the names of all the member functions which are accessible from objects belonging to
class BRANCH.
(iii) Write the names of all the members which are accessible from member functions of class
AUTHOR.
(iii) How many bytes will be required by an object belonging to class AUTHOR?
Answer the questions (i) to (iv) based on the following code:
class Dolls
{
char DCode[5];
protected:
float Price ;
void CalcPrice(float);
public:
Dolls( );
void DInput( );
void DShow( );
};
class SoftDolls: public Dolls
{
char SDName[20];
float Weight;
public:
SoftDolls( );
void SDInput( );
void SDShow( );
};
class ElectronicDolls: public Dolls
{
char EDName[20];
char BatteryType[10];
int Battieries;
public:
ElectronicDolls ( );
void EDInput( );
void EDShow( );
};
(i) Which type of Inheritance is shown in the above example?
(ii) How many bytes will be required by an object of the class ElectronicDolls?
(iii) Write name of all the data members accessible from member functions of the class SoftDolls.
(iv) Write name of all the member functions accessible by an object.

23 | P a g e

8.

9.

Consider the following class declaration and answer the question below :
class university {
int noc;
protected;
char uname[25];
public:
university();
char state[25];
void enterdata();
void displaydata();
};
class college:public university{
int nod;
char cname[25];
protected:
void affiliation();
public:
college();
void enrol(int ,int);
void show();
};
class department:public college{
char dname[25];
int nof;
public:
department();
void display();
void input();
};
(i) Which classs constructor will be called first at the time of declaration of an object of class
department?
(ii) How many bytes does an object belonging to class department require?
(iii)Name the member function(s), which are accessed from the object of class department.
(iv) Name the data member, which are accessible from the object of class college.
Answer the questions(i) to (iv) based on the following :
class cloth
{
char category[5];
char description[25];
protected:
float price;
public:
void Entercloth( );
void dispcloth( );
};
class Design : protected cloth
{
char design[21];
protected:
float cost_of_cloth;

24 | P a g e

10.

public:
int design_code;
Design( );
void Enterdesign( );
void dispdesign( );
};
class costing : public cloth
{
float designfee;
float stiching;
float cal_cp( );
protected:
float costprice;
float sellprice;
public:
void Entercost( );
void dispcost( );
costing ( ) { };
};
(i) Write the names of data members which are accessible from objects belonging to class cloth.
(ii) Write the names of all the members which are accessible from objects belonging to class Design.
(iii) Write the names of all the data members which are accessible from member functions of class
costing.
(iv) How many bytes will be required by an object belonging to class Design?
Answer the questions(i) to (iv) based on the following :
class Regular
{
char SchoolCode[10];
public:
void InRegular( );
void OutRegular( );
};
class Distance
{
char StudyCentreCode[5];
public:
void InDistance( );
void OutDistance( );
};
class Course : public Regular, private Distance
char Code[5];
float Fees;
int Duration;
public:
void InCourse( );
void OutCourse( );
};
(i) Which type of Inheritance is shown in the above example?
(ii) Write names of all the member functions accessible from Outcourse function of class Course.
(iii) Write name of all the members accessible through an object of the Class Course.

25 | P a g e

(iv) Is the function InRegular( ) accessible inside the function InDistance ( )? Justify your answer.
11.

12.

Answer the questions (i) to (iv) based on the following:


class Book
{
int year_publication;
char title[25];
float price;
public:
Book( );
void input_data( );
void output_data( );
};
class Tape
{
char comp_name[20];
protected:
char comp_addr[35];
public:
Tape( );
void read_data( );
void show_data( );
};
class Publication : private Book , public Tape
{
int no_copies;
public:
Publication( );
void Pub_Entry( );
void Pub_Detail( );
};
(i) Write the names of data members which are accessible from objects belonging to class
Publication.
(ii) Write the names of all the member functions which are accessible from objects belonging to
class Tape.
(iii) Write in which order the constructors will be invoked when an object of class Publication is
created .
(iv) How many bytes will be required by an object belonging to class Publication?
Answer the questions (i) to (iv) based on the following code:
class vehicle
{
int wheels;
protected:
int passenger;
public:
void inputdata( );
void outputdata( );
};
class heavyvehicle : protected vehicle
{

26 | P a g e

13.

14.

int diesel_petrol;
protected:
int load;
public:
void readdata(int, int);
void writedata( );
};
class bus : private heavyvehicle
{
char make[20];
public:
void fetchdata( );
void displaydata( );
};
i) Name the base class and derived class of heavyvehicle class.
ii) Name the data member(s) that can be accessed from the function displaydata().
iii) How many bytes will be required by an object of vehicle and heavyvehicle classes respectively?
iv) Is the member function outputdata( ) accessible to the objects of the class heavyvehicle?
Consider the following declarations and answer the questions given below:
class Animal
{
int leg:
protected:
int tail;
public:
void INPUT (int );
void OUT ( );
};
class wild : private Animal
{
int carniv;
protected:
int teeth;
Public:
void INDATA (int, int )
void OUTDATA( );
};
class pet : public Animal
{
int herbiv;
public:
void Display (void);
};
(i) Name the base class and derived class of the class wild.
(ii) Name the data member(s) that can be accessed from function Display ( ).
(iii) Name the member function(s), which can be accessed from the objects of class pet.
(iv) Is the member function OUT ( ) accessible by the objects of the class wild?
Answer the questions (i) to (iv) based on the following class declaration:
class Medicine
{ char category[10];

27 | P a g e

15.

char Date_of_Manufacture[10];
char Date_Of_Expiry[10];
protected:
char company[20];
public:
int x,y;
Medicine( );
void Enter( );
void Show( );
};
class Tablet :protected Medicine
{
protected:
char tablet_name[30];
char volume_label[20];
void disprin( );
public:
float price;
Tablet( );
void enterdet( );
void showdet( );
};
class PainReliever : public Tablet
{
int Dosage_units;
long int tab;
char effects[20];
protected:
int use_within_Days;
public :
PainReliever( );
void enterpr( );
showpr( );
};
(i) How many bytes will be required by an object of class Drug and an object of class PainReliever
respectively.
(ii) Write names of all the data members which are accessible from the object of class PainReliever.
(iii) Write names of all member functions which are accessible from objects of class PianReliever.
(iv) Write the names of all the data members which are accessible from the functions enterpr().
Answer the questions (i) to (iv) based on following code:
class World
{
int H;
protected
int s;
public:
void INPUT(int);
void OUTPUT( );
};
class Country : private World

28 | P a g e

{
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 that can be accessed from function DISPLAY( )
(iii) Name the member functions, which can be accessed from the objects of class State.
(iv) Is the member function OUTPUT() accessible by the objects of the class Country ?

CHAPTER VII: DATA FILE HANDLING


1 Marks questions:
1.
2.

Differentiate between ifstream class and ofstream class.


Observe the program segment carefully and answer the question that follows:
class member
{
int member_no;
char member_name[20];
public:
void enterDetails( );
void showDetail( );
int getMember_no( ){ return member_no;}
};
void update(member NEW )
{
fstream File;
File.open( member.dat, ios::binary|ios::in|ios::out) ;
member i;
while(File .read((char*) & i , sizeof (i)))
{
if(NEW . getMember_no( ) = = i . getMember_no( ))
{
File.seekp( _________ , ios::cur ) //Paremeter Missing
File.write((char*) &NEW , sizeof (NEW));
}
}
File.close() ;
}
If the function update( ) is supposed to modify a record in the file member.dat with the values
of member NEW passed as argument, write the appropriate parameter for the missing parameter
in the above code, so as to modify record at
its proper place.

29 | P a g e

3.

4.

Observe the program segment given below carefully, and answer the question that follows:
class Applicant
{
long AId; //Applicants Id
char Name[20]; //Applicants Name
float Score; //Applicants Score
public:
void Enroll();
void Disp();
void MarksScore(); //Function to change Score
long R_Aid() {return Aid;}
};
void ScoreUpdate(long Id)
{
fstream File;
File.open(APPLI.DAT,ios::binary|ios::in|ios::out);
Applicant A;
int Record=0,Found=0;
while (!Found&&File.read((char*)&C, sizeof(c)))
{
if (Id==A.R_Aid())
{
cout<<Enter new Score;
cin>>A.MarksScore();
_________________ //statement 1
_________________ //statement 2
Found = 1;
}
Record++;
}
if(Found==1) cout<<Record Updated;
File.close();
}
Write the Statement1 to position the File Pointer at the beginning of the Record for which the
Applicants Id matches with the argument passed, and Statement2 to write the updated Record at
that position.
Observe the program segment carefully and answer the question that follows:
class student
{
int student_no;
char student_name[20];
int mark;
public:
void enterDetail( );
void showDetail( );
void change_mark( ); //Function to change the mark
int getStudent_no( ){ return student_no;}
};
void modify( int y )
{

30 | P a g e

5.

fstream File;
File.open( student.dat, ios::binary|ios::in|ios::out) ;
student i;
int recordsRead = 0, found = 0;
while(!found && File .read((char*) & i , sizeof (i)))
{
recordsRead++;
if(i . getStudent_no( ) = = y )
{
i . change_mark( );
_________________________//Missing statement 1
_________________________//Missing statement 2
found = 1;
}
}
if( found = = 1)
cout<<Record modified ;
File.close() ;
}
If the function modify( ) is supposed to change the mark of a student having student_no y in the file
student.dat, write the missing statements to modify the student record.
Observe the program segment carefully and answer the question that follows:
class item
{
int item_no;
char item_name[20];
public:
void enterDetail( );
void showDetail( );
int getItem_no( ){ return item_no;}
};
void modify(item x, int y )
{
fstream File;
File.open( item.dat, ios::binary | ios::in | ios::out) ;
item i;
int recordsRead = 0, found = 0;
while(!found && File.read((char*) &i , sizeof (i)))
{
recordsRead++;
if(i . getItem_no( ) = = y )
{
_________________________//Missing statement
File.write((char*) &x , sizeof (x));
found = 1;
}
}
if(! found)
cout<<Record for modification does not exist ;
File.close() ;

31 | P a g e

6.

7.

}
If the function modify( ) is supposed to modify a record in the file item.dat ,which item_no is y,
with the values of item x passed as argument, write theappropriate statement for the missing
statement using seekp( ) or seekg( ),whichever is needed, in the above code that would write the
modified record at its proper place.
Observe the program segment carefully and answer the question that follows:
class member
{
int member_no;
char member_name[20];
public:
void enterDetail( );
void showDetail( );
int getMember_no( ){ return member_no;}
};
void update(member NEW )
{
fstream File;
File.open( member.dat, ios::binary|ios::in|ios::out) ;
member i;
while(File .read((char*) & i , sizeof (i)))
{
if(NEW . getMember_no( ) = = i . getMember_no( ))
{
_________________________//Missing statement
File.write((char*) &NEW , sizeof (NEW));
}
}
File.close() ;
}
If the function update( ) is supposed to modify the member_name field of a record in the file
member.dat with the values of member NEW passed as argument, write the appropriate
statement for the missing statement using seekp( ) or seekg( ), whichever is needed, in the above
code that would write the modified record at its proper place.
Observe the program segment carefully and answer the question that follows:
class item
{
int item_no;
char item_name[20];
public:
void enterDetails( );
void showDetail( );
int getItem_no( ){ return item_no;}
};
void modify(item x )
{
fstream File;
File.open( item.dat, _______________ ) ; //parameter missing
item i;
while(File .read((char*) & i , sizeof (i)))

32 | P a g e

8.

9.

{
if(x . getItem_no( ) = = i . getItem_no( ))
{
File.seekp(File.tellg( ) sizeof(i));
File.write((char*) &x , sizeof (x));
}
else
File.write((char*) &i , sizeof (i));
}
File.close() ;
}
If the function modify( ) modifies a record in the file item.dat with the values of item x passed
as argument, write the appropriate parameter for the missing parameter in the above code, so as
to modify record at its proper place.
Observe the program segment carefully and answer the question that follows:
class item
{
int item_no;
char item_name[20];
public:
void enterDetail( );
void showDetail( );
int getItem_no( ){ return item_no;}
};
void modify(item x )
{
fstream File;
File.open( item.dat, ios::binary|ios::in|ios::out ) ;
item i;
while(File .read((char*) & i , sizeof (i)))//Statement 1
{
if(x . getItem_no( ) = = i . getItem_no( ))
{
File.seekp(File.tellg( ) sizeof(i));
File.write((char*) &x , sizeof (x)); }
}
File.close() ;
}
If the function modify( ) modifies a record in the file item.dat with the values of item x passed as
argument, rewrite statement 1 in the above code using eof( ) ,so as to modify record at its proper
place.
Observe the program segment given below carefully and fill the blanks marked as Statement 1
and Statement 2 using seekp() and seekg() functions for performing the required task.
#include <fstream.h>
class Item
{
int Ino;char Item[20];
public:
//Function to search and display the content from a particular record number
void Search(int );

33 | P a g e

//Function to modify the content of a particular record number


void Modify(int);
};
void Item::Search(int RecNo)
{
fstream File;
File.open("STOCK.DAT",ios::binary| ios::in);
______________________ //Statement 1
File.read((char*)this,sizeof(Item));
cout<<Ino<<"==>"<<Item<<endl;
File.close();
}
void Item::Modify(int RecNo)
{
fstream File;
File.open("STOCK.DAT",ios::binary|ios::in|ios::out);
cout>>Ino;
cin.getline(Item,20);
______________________ //Statement 2
File.write((char*)this,sizeof(Item));
File.close();
}

2 Marks questions:
1.
2.
3.

4.

5.

6.
7.
8.

Write a user defined function in C++ to read the content from a text file NOTES.TXT, count and
display the number of blank spaces present in it.
Write a user defined function in C++ to read the content from a text file STORY.TXT, count and
display the number of alphabets present in it.
Assuming that a text file named First.TXT contains some text written into it, write a function named
Vowel words, that reads the file FIRST.TXT and creates a new file named SECOND.TXT, to contain
only those words from the file FIRST.TXT which start with a lowercase vowel (i.e., with a, e, i,
o, u). For example if the file FIRST.TXT contains
Carry umbrella and overcoat when it rains
Then the file SECOND.TXT shall contain
Umbrella and overcoat it 3
Write a function in C++ to print the count of the word the as an independent word in a text file
STORY.TXT. For example, if the content of the file STORY.TXT is There was a monkey in the zoo.
The monkey was very naughty. Then the output of the program should be 2.
Assume a text file coordinate.txt is already created. Using this file create a C++ function to count
the number of words having first character capital.
Example: Do less Thinking and pay more attention to your heart. Do Less Acquiring and pay more
Attention to what you already have. Do Less Complaining and pay more Attention to giving. Do Less
criticizing and pay more Attention to Complementing. Do less talking and pay more attention to
SILENCE.
Output will be : Total words are 16
Write a function in C++ to count the number of lines present in a text file STORY.TXT.
Write a function in C++ to count the number of alphabets present in a text file NOTES.TXT.
Write a function in C++ to write the characters entered through the keyboard into the
filemyfile.txt, until a # character is entered.

34 | P a g e

9.

10.

11.
12.

Assume that a text file named text1.txt already contains some text written into it, write a function
named vowelwords(), that reads the file text1.txt and create a new file named text2.txt, which shall
contain only those words from the file text1.txt which dont start with an uppercase vowel
(i.e., with A,E,I,O,U). for example if the file text1.txt contains:
Take One Apple And one glass milk daily.
Then the file text2.txt shall contain :
Take one glass milk daily.
Assume a text file Test.TXT is already created. Using this file, create a function to create three
files LOWER.TXT which contains all the lowercase vowels and UPPER.TXT which contains all the
uppercase vowels and DIGIT.TXT which contains all digits.
Write a function in C++ to calculate the average word size in a text file Report.txt, each word is
separated by single space or full stop.
Create a function FileLowerShow() in c++ which take file name(text files)as a argument and display
its all data into lower case.

3 Marks questions:
1.

2.

Given a binary file PHONE.DAT, containing records of the following structure type
class Phonlist
{
char Name[20];
char Address[30];
char AreaCode[5];
char PhoneNo[15];
public:
void Register();
void Show();
int CheckCode(char AC[ ])
{
return strcmp(AreaCode,AC);
}
};
Write a function TRANSFER ( ) in C++, that would copy all those records which are having AreaCode
as DEL from PHONE.DAT to PHONBACK.DAT.
Given a binary file TELEPHON.DAT, containing records of the following class Directory:
class Directory
{
char Name[20];
char Address[30];
char AreaCode[5];
char Phone_No[15];
public:
void Register();
void Show();
int CheckCode(char AC[])
{
return strcmp(AreaCode,AC[]);
}
};

35 | P a g e

3.

4.

5.

6.

Write a function COPYABC in C++ that would copy only those records having AreaCode as 123
from TELEPHON.DAT to TELEBACK.DAT.
Given a binary file SPORTS.DAT, containing records of the following structure type :
struct Sports
{
char Event[20];
char Participant[10][30];
};
Write a function in C++ that would read contents from the file SPORTS.DAT and creates a file
named ATHLETIC.DAT copying only those records from SPORTS.DAT where the event name is
Athletics.
Write a function in C++ to search for a BookNo from a binary file BOOK.DAT, assuming the binary
file is containing the objects of the following class.
class BOOK
{
int Bno;
char Title[20];
public:
int RBno(){return Bno;}
void Enter(){cin>>Bno;gets(Title);}
void Display(){cout<<Bno<<Title<<endl;}
};
Write a function in C++ to add new objects at the bottom of a binary file
STUDENT.DAT, assuming the binary file is containing the objects of the
following class.
class STUD
{
int Rno;
char Name[20];
public:
void Enter()
{
cin>>Rno;gets(Name);
}
void Display(){cout<<Rno<<Name<<endl;}
};
Write a function in C++ to read and display the detail of all the members whose membership type is
L or M from a binary file CLUB.DAT. Assuming the binary file CLUB.DAT is containing
objects of class CLUB, which is defined as follows:
class CLUB
{
int Mno.
char Mname[20];
char Type; //Member Type: L Life Member M Monthly member G Guest
public:
void Register( );
void Display( );
char whatType( ) { return type; }
};

36 | P a g e

7.

8.

9.

Assuming the class DRINKS defined below, write functions in C++ to perform the following :
(i) write the objects of DRINKS to binary file.
(ii) Read the objects of DRINKS from binary file and display them on screen when Dname has value
-Pepsi.
class DRINKS
{
int DCode;
char DName[13];
int Dsize; // size in litres.
float Dprice; }
public:
void getdrinks( )
{ cin>>DCode>>DName>>Dsize>>Dprice;}
void showdrinks( )
{ cout<< DCode<<DName<,Dsize<,Dprice;}
char *getname()
{ return Dname;}
};
Assuming the class Computer as follows:
class Computer
{
char chiptype[10];
int speed;
public:
void getdetails() {
gets(chiptype);
cin>>speed;
}
void showdetails() {
cout<<"Chip"<<chiptype<<"Speed = "<<speed;
}
};
Write a function readfile() to read all the records present in an already existing binary file SHIP.DAT
and display them on the screen, also count the number of records present in the file.
Assuming a binary file FUN.DAT is containing objects belonging to a class LAUGHTER(as defined
below). Write a user defined function in C++ to add more objects belonging to class LAUGHTER at
the bottom of it.
class LAUGHTER
{
int Idno; // Identification number
char Type[5]; // LAUGHTER Type
char Desc[255]; // Description
public :
void Newentry()
{ cin>>Idno; gets(Type); gets(Desc); }
void Shownscreen()
{ cout<<Idno<<":"<<Type<<endl<<Desc<<endl; }
};

37 | P a g e

10.

Assuming a binary file JOKES.DAT is containing objects belonging to a class JOKE(as defined
below). Write a user defined function in C++ to add more objects belonging to class JOKE at the
bottom of it.
class JOKE
{
int Jokeid; // Joke Identification number
char Type[5]; // Joke Type
char Jokedesc[255]; // Joke Description
public :
void Newjokeentry()
{cin>>Jokeid; gets(Type); gets(Jokedesc); }
void Showjoke()
{cout<<Jokeid<< ":"<<Type<<endl<<Jokedesc<<endl; }
};

CHAPTER VIII: POINTERS


2 Marks/ 3 Marks questions:
1.

2.

3.

Predict the output of the following code:


# include<iostream.h>
#include<conio.h>
void main()
{
int arr[] = {12, 23, 34, 45};
int *ptr = arr;
int val = *ptr; cout << val << endl;
val = *ptr++; cout << val << endl;
val = *ptr; cout << val << endl;
val = *++ptr; cout << val << endl;
}
Find the output of the following code.
#include<iostream.h>
#include<conio.h>
void main()
{
int arr[] = {12, 23, 34, 45};
int *ptr = arr;
int val = *ptr; cout << val << endl;
val = *ptr++; cout << val << endl;
val = *ptr; cout << val << endl;
val = *++ptr; cout << val << endl;
val = ++*ptr; cout << val << endl;
}
Find the output of the following code
#include<iostream.h>
#include<conio.h>
void main()
{
int arr[] = {12, 23, 34, 45};

38 | P a g e

4.

5.

6.

7.

int *ptr = arr;


int val = *ptr; cout << val << endl;
val = (*ptr)++; cout << val << endl;
val = *ptr; cout << val << endl;
val = *++ptr; cout << val << endl;
}
Write the output of the following program:
#include<iostream.h>
#include<conio.h>
void main( )
{
clrscr( );
int a =32;
int *ptr = &a;
char ch = A;
char *cho=&ch;
cho+=a; // it is simply adding the addresses.
*ptr + = ch;
cout<< a << <<ch<<endl;
}
Write the output of the following program:
#include<iostream.h>
#include<conio.h>
void main( )
{
clrscr( );
int a =32;
int *ptr = &a;
char ch = A;
char *cho=&ch;
*cho+=a; // it is adding the values.
cout<< a << <<ch<<endl;
}
Give the output of the following program :
char *NAME = "CoMPutER";
for (int x = 0; x < strlen(NAME); x++)
if (islower(NAME[x]))
NAME[x] = toupper(NAME[x]);
else
if (isupper(NAME[x]))
if (x%2==0)
NAME[x] = tolower(NAME[x]);
else
NAME[x] = NAME[x-1];
puts(NAME);
Give the output of the following program segment(Assume all required header files are included in
the program) :
char *s = "GOODLUCK";
for (int x = 0;x<strlen(s)1 ; x>=0; x)
{

39 | P a g e

8.

9.

10.

11.

for ( int y=0; y<=x; y++) cout<<s[y];


cout<<endl;
}
Identify the syntax error(s), if any, in the following program. Also give reason for errors.
void main()
{
const int i = 20;
const int * const ptr = &i;
(*ptr)++;
int j = 15;
ptr = &j;
}
Give the output of the following program segment. (Assuming all required header files are included
in the program) :
void main()
{
int a = 32, *X = &a;
char ch = 65, &eco = ch;
cho += a;
*X += ch;
cout << a << ',' << ch << endl;
}
Write the output of the following program:
#include <iostream.h>
static int i = 100;
void Print(char *P) {
p = "Press"; cout <, "value is : " << p << endl;
}
void main() {
char *q = "Best of Luck";
Print(q); cout << "New value is : " << q;
}
Give the output of the following program segment :
char *Text[2] = {Two, six};
for (int C=0;C<2;C++) {
for (int D=0; D<strlen(Text[0]); D++)
if (islower(Text[C][D]))
cout<<(char)toupper(Text[C][D]);
else
if (isupper(Text[C][D]) && (D%2 ==0))
cout<<(char)tolower(Text[C][D]);
else
cout<<Text[C][D];
cout<<D<<endl;
}

40 | P a g e

CHAPTER IX: ARRAYS


2 Marks/ 3 Marks questions:
1.
2.

3.

Write a user-defined function in C++ to display the sum of row elements of a two dimensional array
R[5][6] containing integers.
Write the user-defined function in C++ to display those elements of a two dimensional array T[4][4]
which are divisible by 100. Assume the content of the array is already present and the function
prototype is as follows :
void Showhundred (int T[4][4]);
Write a function in C++ to find the sum of diagonal elements from a 2 dimensional array of type
float. Use the array and its size as parameters with float as its return type.

4.

Write a function in C++ which accepts an integer array and its size as arguments and replaces elements
having even values with its half and elements having odd values with twice its value

5.

Write a function in C++ which accepts an integer array and its size as argument and exchanges the
value of first half side elements with the second half side elements of the array.
Example : If an array of eight elements has initial content as 2,4,1,6,7,9,23,10 The function should
rearrange the array as 7,9,23,10,2,4,1,6.
Write a function in c++ to find and display the sum of each row and each column of 2 dimensional
array. Use the array and its size as parameters with int as the data type of the array.
Write a function in C++, which accepts an integer array and its size as parameters and rearrange the
array in reverse. Example if an array of five members initially contains the elements as 6,7,8,13,9,19
Then the function should rearrange the array as 19,9,13,8,7,6
Write a function in C++, which accept an integer array and its size as arguments and swap the
elements of every even location with its following odd location.
Example : if an array of nine elements initially contains the elements as 2,4,1,6,5,7,9,23,10 Then the
function should rearrange the array as 4,2,6,1,7,5,23,9,10
Write a function in C++ which accepts an integer array and its size as arguments and replaces
elements having odd values with thrice and elements having even values with twice its value.
Example : If an array of five elements initially contains the elements 3,4,5,16,9
Then the function should rearrange the content of the array as 9,8,15,32,27
Write function SORTPOINTS() in c++ to sort an array of structure Game in descending order of
points using Bubble Sort Note: Assume the following definition of structure Game
struct Game
{
long PNo; // Player Number
char PName[20];
long points;
};
Write a c++ function to shift all the negative numbers to left and positive number in the right side.
Define a function SWPCOL() in C++ to swap ( interchange) the first column elements with the last
column elements, for a two dimensional array passed as the argument of the function.
Example : if the two dimensional array contains
2149
1377
5863
7212
After swapping of the content of 1st and last column, it should be
9142
7371
3865

6.
7.

8.

9.

10.

11.
12.

41 | P a g e

13.

14.

15.

16.

17.

2217
Define a function SWPROW() in C++ to swap ( interchange) the first row elements with the last row
elements, for a two dimensional array passed as the argument of the function.
Example : if the two dimensional array contains
2149
1377
5863
7212
After swapping of the content of the array will be
80
7212
5863
1377
2149
Write a function in C++ to print the product of each column of a 2D integer array passed as the
argument of the function Example : if the two dimensional array contains
2149
1377
5863
7212
Then the output should appears as
Product of Column1 = 70
Product Column2 = 48
Product of column3= 168
Product of Column4=378
Write a function in C++ to print the product of each row of a 2D integer array passed as the
argument of the function
Example : if the two dimensional array contains
2149
1377
5863
7212
Then the output should appears as
Product of Row1 = 72
Product Row2 = 147
Product of Row3= 720
Product of Row4=28
Write a function which accept 2D array of integers and its size as arguments and displays the sum of
elements which lie on diagonals.
[Assuming the 2D array to be a square matrix with odd dimension ie 3 x 3 , 4 x 4 etc ]
Example of the array content is
543
678
129
Output through the function should be
Diagonal One Sum : 21
Diagonal Two: 11
Write a function in C++ which accepts a 2D array of integers and its size as arguments and displays
the elements of middle row and the elements of middle column.

42 | P a g e

18.

19.

20.

21.
22.
23.
24.

25.

[Assuming the 2D array to be a square matrix with odd dimension ie 3 x 3 , 5 x 5, 7 x 7 etc ]


Example of the array content is
543
678
129
Output through the function should be
Middle row: 6 7 9
Middle Column 4 7 2
Write a function in C++ which accepts an integer array and its size as arguments and assign the
elements into a two dimensional array of integers in the following format
If the array is 1,2,3,4,5,6 if the array is 1,2,3
The resultant 2D array is The resultant 2D array is
123456123
123450120
123400100
123000
120000
100000
Write a function in C++ which accepts an integer array and its size as arguments and assign the
elements into a two dimensional array of integers in the following format
If the array is 1,2,3,4,5,6 if the array is 1,2,3
The resultant 2D array is The resultant 2D array is
123456123
012345012
001234001
000123
000012
000001
Write a function in C++ which accepts an integer array and its size as arguments and assign the
elements into a two dimensional array of integers in the following format
If the array is 1,2,3,4,5,6 if the array is 1,2,3
The resultant 2D array is The resultant 2D array is
100000100
120000120
123000123
123400
123450
123456
Write a user defined function named upperhalf() which takes a 2D array A, with size n rows and n
cols as arguments and print the upper half of the matrix
Write a user defined function lowerhalf() which takes a 2D array, with size n rows and n cols as
argument and prints the lower half of the matrix
Write the function to find the largest and second largest number from a two dimensional array. The
function should accept the array and its size as argument.
Write a function in C++ to merge the contents of two sorted arrays A & B into third array C.
Assuming array A is sorted in ascending order, B is sorted in descending order, the resultant array is
required to be in ascending order.
An array S[10][15] is stored in the memory with each element requiring 4 bytes of storage. If the
base address of S is 1000, determine the location of S[8][9] when the array is S stored by
(i) Row major (ii) Column major.

43 | P a g e

26.

27.

28.

29.

30.

31.

32.

33.

34.
35.

36.

37.

38.

Suppose an array ARR containing float is arranged in ascending order. Write a user defined
function in C++ to search for one float from ARR with the help of binary search method. The
function should return an integer 0 to show absence of the number and integer 1 to showpresence
of the number in the array. The function should have the parameters as (i) an array ARR (ii) the
number DATA to be searched (iii) number of elements N.
Suppose X, Y, Z are arrays of integers of size M,N and M+N respectively. The numbers in array X
and Y appear in descending order. Write a user defined function in C++ to produce third array Z by
merging arrays X and Y in descending order.
An array DATA[1..10][1..10] requires 8 bytes of storage. If the base address of array DATA is 1500,
determine the location of DATA [4][5], when the array DATA is stored
(i)
Row Wise (ii) Column wise.
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 array A is stored by column
major.
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.
An array X[30][10] is stored in the memory with each element requiring 4 bytes of storage. If the
base address of X is 4500, find out memory locations of X[12][8] and X[2][14], if the content is
stored along the row.
An Array Val[1..15][1..10] is stored in the memory with each elements requiring 4 bytes of storage.
If the base address of array Val is 1500, determine the location of Val [12][9] when the array Val is
stored (i) row wise (ii) column wise.
A 2-d array defined as A[4..7, -1..3] requires 2 words of storage space for each element. calculate
the address of A[6,2], given the base address as 100, also calculate the address of A[7,0 If the array
is stored in row major order
If an array B[11][8] is stored as column wise and B[2][2] is stored at 1024 and B[3][3] at 1084. Find
out the base address, size of an element and address of B[5]3].
An array ARR[35][15] is stored in the memory along the row with each of its element occupying 4
bytes. Find out the base address and the address of an element ARR[20][5], if the location ARR[2][2]
is stored at the address 3000.
An array S[40][30] is stored in the memory along the row with each of the element occupying 4
bytes, find out the memory location for the element S[15][5], if an element s[20][10] is stored at
memory location 5700
An array ARR[10][20] is stored in the memory with each element occupying 2 bytes of space.
Assuming the base address of ARR to be 800,compute the address of ARR[9][11], when the array is
stored as :
i) Row wise
ii) Column wise
Assume an array E containing elements of structure Employee is required to be arranged in
descending order of Salary. Write a C++ function to arrange the same with the help of bubble sort,
the array and its size is required to be passed as parameters to the function. Definition of structure
Employee is as follows :
struct Employee
{
int Eno;
char Name[25];
float Salary;
};

44 | P a g e

39.

40.

Define a function SwapArray(int [], int) that would accept a one dimensional integer array
NUMBERS and its size N. The function should rearrange the array in such a way that the values of
alternate locations of the array are exchanged ( Assume the size of the array to be even)
Example :
If the array initially contains
{2, 5, 9, 14, 17, 8, 19, 16},
then after rearrangement the array should contain
{5, 2, 14, 9, 8, 17, 16, 19}
An array ARR[5][5] is stored in the memory with each element occupying 2 bytes of space.
Assuming the base address of ARR to be 1500, computer the address of ARR[2][4], when the array
is stored :
(i) Row Wise (ii) Column Wise

CHAPTER X: LINKED LIST, STACK AND QUEUES


2 Marks questions:
1.

2.

3.
4.

5.
6.

7.

Obtain the postfix notation for the following infix notation of expression showing the contents of
the stack and postfix expression formed after each step of conversion :
A * B + ( C D/F)
Evaluate the following postfix expression using a stack and show the contents of stack after
execution of each operation :
20, 45, +, 20, 10, , 15, +, *
Change the following infix expression into postfix expression.
(A+B)*C+D/E-F
Evaluate the following Postfix notation of expression, show status of stack for each operations :
500, 20, 30, +, 10, *, +
Convert the expression (TRUE && FALSE) ||! (FALSE || TRUE) to postfix expression. Show the
contents of the stack at every step.
Evaluate the following postfix expression using a stack and show the Contents of stack after
execution of each operation:
(i)
50,40,+, 18,14,-,4,*,+
(ii)
100,40,8,+,20,10,-,+,*
(iii)
5,6,9,+,80,5,*,-,/
(iv)
120,45,20,+,25,15,-,+,*
(v)
20,45,+,20,10,-,15,+,*
(vi)
TRUE,FALSE, TRUE FALSE, NOT, OR, TRUE , OR,OR,AND
Give postfix form of the following expression:
(i)
A*(B+(C+D)*(E+F)/G)*H
(ii)
A+[(B+C)*(D+E)*F]/G
(iii)
A*(B+D)/E-F-(G+H/K)
(iv)
((A-B)*(D/E))/(F*G*H)
(v)
(True && false) || !(false||true)

45 | P a g e

4 Marks questions:
1.

2.

3.

4.

5.

Write a function in C++ to perform a PUSH operation in a dynamically allocated stack considering
the following :
struct Node
{ int X,Y;
Node *Link; };
class STACK
{ Node * Top;
public:
STACK( ) { TOP=NULL;}
void PUSH( );
void POP( );
~STACK( ); };
Define function stackpush( ) to insert nodes and stackpop( ) to delete nodes, for a linked list
implemented stack having the following structure for each node:
struct Node
{ char name[20];
int age;
Node *Link; };
class STACK
{ Node * Top;
public:
STACK( ) { TOP=NULL;}
void stackpush( );
void stackpop( );
~STACK( ); };
Write a function in C++ to perform a PUSH operation in a dynamically allocated stack considering
the following:
struct node
{ int x,y;
Node *Link;};
Write a function in C++ to perform a DELETE operation in a dynamically allocated queue considering
the following description:
struct Node
{ float U,V;
Node *Link; };
class QUEUE
{
Node *Rear, *Front;
public:
QUEUE( ) { Rear =NULL; Front= NULL;}
void INSERT ( );
void DELETE ( );
~QUEUE ( );
};
Define member functions queins() to insert and quedel() to delete nodes of the linked list
implemented class queue, where each node has the following structure:
struct node
{

46 | P a g e

6.

7.

8.

char name[20];
int age;
node * Link;
};
class queue
{
node *rear, *front;
public :
queue() { rear = NULL; front = NULL};
void queins();
void quedel();
};
Consider the following portion of a program, which implements passengers Queue for a train. Write
the definition of function Insert (whose prototype is shown below); to insert a new node in the
queue with required information :
struct NODE
{
long Ticketno;
char PName[20]; //Passenger Name
NODE * NEXT;
};
class Queueoftrain
{
NODE *Rear, *Front;
public :
Queueoftrain( ) { Rear = NULL, Front = NULL;}
void Insert( );
void Delete( );
~Queueoftrain( );
};
Given the following class,
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_enum]; } //report error message
public:
void init( ) { top = 0; } //initialize the stack pointer
void push(int); //put new value in stk
void pop( ); //get the top value
};
Define pop outside the Stack. In your definition take care of under flow condition. Function pop
should invoke error_rep to report under flow.
Define functions stackpush() to insert nodes and stackpop() to delete nodes, for a linked list
implemented stack having the following structure for each node :
struct node {
char name[20];
int age;
node *Link;

47 | P a g e

9.

10.

11.

};
class stack {
node *top;
public:
stack() { top = NULL;};
void stackpush();
void stackpop();
};
Write a function in C++ to perform a DELETE operation in a dynamically allocated queue considering
the following description:
Struct Node
{
float U,V;
Node *Link;
};
class QUEUE
{
Node *Raer, *Front;
Public:
QUEUE( ) { Rear =NULL; Front= NULL;}
Void INSERT ( );
Void DELETE ( );
~QUEUE ( );
}
Define function stackpush( ) to insert nodes and stackpop( ) to delete nodes, for a linklist
implemented stack having the following structure for each node:
Struct Node
{
char name[20];
int age;
Node *Link;
};
class STACK
{
Node * Top;
Public:
STACK( ) { TOP=NULL;}
Void stackpush( );
Void stackpop( );
~STACK( );
};
Consider the following portion of a program which implements passengers Queue for a bus.
Write the definition of function Insert , to insert a new node in the queue with required
information.
Struct Node
{
float U,V;
Node *Link;
};
class QUEUE
{
Node *Raer, *Front;
Public:
QUEUE( ) { Rear =NULL; Front= NULL;}
Void INSERT ( );
Void DELETE ( );
~QUEUE ( );
};

48 | P a g e

CHAPTER XI: DATABASE CONCEPTS


2 Marks questions:
1.
2.
3.
4.
5.

What are DDL and DML ?


What do you understand by normalization ? what is First Normal Form ?
What is a primary key in a table? Define first normal form.
What is relation? Define the relational data model.
What is relation? What is the difference between a tuple and an attribute?

6.

Observe the following table WORKER carefully and write its (i) Degree and Cardinality and (ii) most
appropriate column, which can be considered as Primary Key.

7.
8.
9.
10.
11.

What do you understand by selection and projection operation in relation algebra.


Define : (i) Candidate key
(ii) Alternate Key
What is Foreign Key ?
What do you mean by Data Independence ?
What do you mean by data redundancy ?

CHAPTER XII: SQL


6 Marks Questions :
1.

Write the SQL commands from (i) to (iv) and output from (v) to (viii) for the following on the basis
of tables HOSPITAL .

49 | P a g e

2.

3.

(i) To show all information about the patients of cardiology department.


(ii) To list the names of female patients who are in ENT department.
(iii) To list names of all patients with their date of admission in ascending order.
(iv) The display Patients Name, charges, age for female patients only.
(v) Select COUNT (DISTINCT Charges) from HOSPITAL;
(vi) Select MIN (Age) from HOSPITAL where Sex = F;
(vii) Select SUM(Charges) from HOSPITAL where Department = ENT;
(viii) Select AVG (Charges) from HOSPITAL where Dateofadm < {12/02/98};
Write the SQL commands from (a) to (d) and output from (e) to (h) for the following on the basis of
tables GARMENT and FABRIC
Table: GARMENT
Table: FABRIC
GCODE DESCRIPTION
PRICE FCODE READYDATE
FCODE TYPE
10023

PENCIL SKRIT

1150

F03

19-DEC-08

F04

POLYSTER

10001

FORMAL SHIRT

550

F01

07-MAR-07

F02

COTTON

10012

BABY TOP

300

F02

11-SEP-09

F03

SILK

10024

EVENING GOWN 545

F04

05-JAN-08

F01

TERELENE

10090

FROCK

F01

03-OCT-07

575

(a) To display gcode and description of each garment in descending order of gcode.
(b) To display the details of all the garments which have readydate in between 08-dec-07 and 16nov-08(inclusive of both dates)
(c) To display the average price of all the garments fcode wise.
(d) To display gcode, description, price from garment table and type from fabric table.
(e) SELECT SUM(PRICE) FROM GARMENT WHERE FCODE=F01;
(f) SELECT DESCRIPTION, TYPE FROM GARMENT,FABRIC WHERE GARMENT.FCODE = FABRIC.FCODE
AND GARMENT.PRICE= 1150;
(g) SELECT MAX(PRICE) FROM GARMENT;
(h) SELECT COUNT(FCODE) FROM GARMENT;
Consider the following tables PRODUCT and CLIENT. Write SQL commands for the statements (a) to
(d) and give outputs for SQL queries (e) to (h).
Table: PRODUCT

50 | P a g e

P_ID

PRODUCTNAME

MANUFACTURER PRICE

TP01

TALCOM POWDER LAK

40

FW05

FACE WASH

ABC

45

BS01

BATH SOAP

ABC

55

SH06

SHAMPOO

XYZ

120

FW12

FACE WASH

XYZ

95

Table: CLIENT
C_ID

CLIENTNAME

CITY

P_ID

01

COSMETIC SHOP

DELHI

FW05

06

TOTAL HEALTH

MUMBAI

BS01

12

LIVE LIFE

DELHI

SH06

15

PRETTY WOMAN

DELHI

FW12

16

DREAMS

BANGALORE

TP01

(a) To display the details of those clients whose city is Delhi.


(b) To display the clientname, city from table client and productname and price from table product
with their corresponding matching p_id.
(c) To display the manufacturer of FACE WASH.
(d) To increase the price of all products by 10.
(e) SELECT DISTINCT CITY FROM CLIENT;
(f) SELECT MANUFACTURER, MAX(PRICE), MIN(PRICE), COUNT(*) FROM PRODUCT GROUP BY
MANUFACTURER;
(g) SELECT CLIENTNAME, MANUFACTURER FROM PRODUCT, CLIENT WHERE CLIENT.P_ID =
PRODUCT.P_ID;
4.

Consider the following tables PRODUCT and CLIENT. Write SQL commands for the statements (a) to
(f) and give outputs for SQL queries (g).
Table : SchoolBus
Rtno Area_overed

Capacity

Noofstudents

Distance Transporter

Charges

Vasant kunj

100

120

10

Shivamtravels

100000

Hauz Khas

80

80

10

Anand travels

85000

Pitampura

60

55

30

Anand travels

60000

Rohini

100

90

35

Anand travels

100000

Yamuna Vihar

50

60

20

Bhalla Co.

55000

Krishna Nagar

70

80

30

Yadav Co.

80000

Vasundhara

100

110

20

Yadav Co.

100000

Paschim Vihar

40

40

20

Speed travels

55000

Saket

120

120

10

Speed travels

100000

10

Jank Puri

100

100

20

Kisan Tours

95000

(b) To show all information of students where capacity is more than the no of student in order of rtno.
51 | P a g e

(c) To show area_covered for buses covering more than 20 km., but charges less then 80000.
(d) To show transporter wise total no. of students traveling.
(e) To show rtno, area_covered and average cost per student for all routes where average cost per
student is - charges/noofstudents.
(f) Add a new record with following data:
(11, Moti bagh,35,32,10, kisan tours , 35000)
(g) Give the output considering the original relation as given:
(i) select sum(distance) from schoolbus where transporter= Yadav travels;
(ii) select min(noofstudents) from schoolbus;
(iii) select avg(charges) from schoolbus where transporter= Anand travels;
(iv) select distinct transporter from schoolbus;
5.
S.NO
1
2
3
4
5
6
7
8
9
10

(e)

6.

NAME
KARAN
DIWAKAR
DIVYA
REKHA
ARJUN
SABINA
JOHN
ROBERT
RUBINA
VIKAS

TABLE : GRADUATE
STIPEND
SUBJECT
400
PHYSICS
450
COMP. Sc.
300
CHEMISTRY
350
PHYSICS
500
MATHS
400
CEHMISTRY
250
PHYSICS
450
MATHS
500
COMP. Sc.
400
MATHS

AVERAGE
68
68
62
63
70
55
64
68
62
57

DIV.
I
I
I
I
I
II
I
I
I
II

(a) List the names of those students who have obtained DIV 1 sorted by NAME.
(b) Display a report, listing NAME, STIPEND, SUBJECT and amount of stipend received in a year
assuming that the STIPEND is paid every month.
(c) To count the number of students who are either PHYSICS or COMPUTER SC graduates.
(d) To insert a new row in the GRADUATE table:
11,KAJOL, 300, computer sc, 75, 1
Give the output of following sql statement based on table GRADUATE:
(i) Select MIN(AVERAGE) from GRADUATE where SUBJECT=PHYSICS;
(ii) Select SUM(STIPEND) from GRADUATE WHERE div=2;
(iii) Select AVG(STIPEND) from GRADUATE where AVERAGE>=65;
(iv) Select COUNT(distinct SUBDJECT) from GRADUATE;
Write SQL command for (i) to (vii) on the basis of the table SPORTS
Table: SPORTS

Student NO
10
11
12
13
14
15
52 | P a g e

Class
7
8
7
7
9
10

Name
Sammer
Sujit
Kamal
Venna
Archana
Arpit

Game1
Cricket
Tennis
Swimming
Tennis
Basketball
Cricket

Grade
B
A
B
C
A
A

Game2
Swimming
Skating
Football
Tennis
Cricket
Atheletics

Grade2
A
C
B
A
A
C

(a) Display the names of the students who have grade C in either Game1 or
Game2 or both.
(b) Display the number of students getting grade A in Cricket.
(c) Display the names of the students who have same game for both Game1 and Game2.
(d) Display the games taken up by the students, whose name starts with A.
(e) Assign a value 200 for Marks for all those who are getting grade B or grade A in both Game1 and
Game2.
(f) Arrange the whole table in the alphabetical order of Name.
(g) Add a new column named Marks.
7.
Employees
Empid

Firstname

Lastname

Address

City

010

Ravi

Kumar

Raj nagar

GZB

105

Harry

Waltor

Gandhi nagar

GZB

152

Sam

Tones

33 Elm St.

Paris

215

Sarah

Ackerman

440 U.S. 110

Upton

244

Manila

Sengupta

24 Friends
street

New Delhi

300

Robert

Samuel

9 Fifth Cross

Washington

335

Ritu

Tondon

Shastri Nagar

GZB

400

Rachel

Lee

121 Harrison
St.

New York

441

Peter

Thompson

11 Red Road

Paris

EmpSalary
Empid

Salary

Benefits

Designation

010

75000

15000

Manager

105

65000

15000

Manager

152

80000

25000

Director

215

75000

12500

Manager

244

50000

12000

Clerk

300

45000

10000

Clerk

335

40000

10000

Clerk

400

32000

7500

Salesman

53 | P a g e

Write the SQL commands for the following :


(i)
(ii)
(iii)

To show firstname,lastname,address and city of all employees living in paris


To display the content of Employees table in descending order of Firstname.
To display the firstname,lastname and total salary of all managers from the tables Employee
and empsalary , where total salary is calculated as salary+benefits.
(iv)
To display the maximum salary among managers and clerks from the table Empsalary
Give the Output of following SQL commands:
(i)
Select firstname,salary from employees ,empsalary where designation = Salesman and
Employees.empid=Empsalary.empid;
(ii)
Select count(distinct designation) from empsalary;
(iii)
Select designation, sum(salary) from empsalary group by designation having count(*) >2;
(iv)
Select sum(benefits) from empsalary where designation =Clerk;

CHAPTER XIII: BOOLEAN ALGEBRA


1 Mark Questions
1.

Write the Product of sum form of the function G(U, V, W). Truth table representation of G is as
follows:

2.
3.

Write the dual of the Boolean expression (x+y).(x'+y').(y+z).


Write sum of product form of the following F(x, y, z). The truth table representation for the function
F is given below :

4.

State and prove the absorption law algebraically.

54 | P a g e

5.

Given the following truth table, derive a sum of product(SOP) and Product of Sum(POS) form of
Boolean expression from it :

6.

Write SOP and POS forms of function F(A, B, C) whose truth table is given below.
A

2 Marks Questions
1.
2.
3.
4.
5.
6.

State and prove INVOLUTION LAW of Boolean algebra.


Implement the following Boolean expression.
Y= A.B.C+A.B.C+A.BC+A.B.C with minimum number of gates.
Convert the following Boolean expression into its equivalent Canonical Sum of Products form
(SOP): (X+Y+Z) (X+Y+Z) (X+Y+Z) (X+Y+Z)
State and prove the following theorems
(a) DeMorgans Theorem
b) Absorption Theorem
State and verify Associative Law in Boolean algebra.
Write the equivalent Boolean expression for the following Logic Circuit.
A B

55 | P a g e

7.
8.
9.
10.
11.
12.
14.

Find the complement of (AB) + (AB)


Obtain a simplified form for the boolean expression given below(using K-map):
F(a, b, c, d) = (0, 1, 2, 4, 5, 8, 10, 12, 13)
Draw the logic circuit diagram of the following expression using only NAND gates only.
a + bc + cd
Give the duals of XYZ + (XY + 1)
Convert X + XY +XY to canonical SOP form.
Verify XYZ + XYZ + XYZ = XY + YZ algebraically.
Given the following circuit.

What is the output if(i) both inputs are FALSE (ii) one is FALSE and the other is TRUE.
15.

Interpret the following Logic Circuit as Boolean Expression :

16.

(a) Implement the following Boolean expression using NOR gates only.
F(A, B, C) = A.B.C + A.B.C + A.B.C in POS form..
(b) Find the complement of (A+B) + (A+B)
State Absorption Laws. Verify one of the Absorption Laws using a truth table.
Prove X + Y'Z = (X + Y' + Z')(X + Y' + Z)(X + Y + Z) algebraically.
State and prove Distributive Law .
Convert the following Boolean expression into its equivalent Canonical Sum of
Product Form((SOP)
(X+Y+Z).(X+Y+Z).(X+Y+Z).(X+Y+Z)
Convert the following Boolean expression into its equivalent Canonical Product
of Sum form (POS):
A.B.C + A.B.C +A.B.C
Draw a Logical Circuit Diagram for the following Boolean Expression:
A.(B+C)
Write the equivalent Boolean Expression F for the following circuit diagram :
Prove that XY+YZ+YZ=Y algebraically
Express the F(X,Z)=X+XZ into canonical SOP form.
Write the equivalent Boolean Expression for the following Logic Circuit.
Interpret the following logical circuit as Boolean expression
Design (A+B).(C+D) using NAND Gate
Simplify the following Boolean Expression using Boolean postulates and laws of
Boolean Algebra.
Z=(a+a).b.c+a.b.c+a.b.(c+c)
Prove x.y+y.z = xyz+xyz+xyz+xyz algebraically.

17.
18.
19.
20.

21.

22.
23.
24.
25.
26.
27.
28.
29.

30.

56 | P a g e

3 Marks Questions
1.
2.
3.
4.
5.
6.
7.
8.
9.

If F(a,b,c,d)= (0,2,4,5,7,8,10,12,13,15), obtain the simplified form using K-Map.


If F(a,b,c,d) = (0,1,3,4,5,7,8,9,11,12,13,15), obtain the simplified form using KMap
Obtain a simplified form for a boolean expression
F(U,V,W,Z)= (0,1,3,5,6,7,10,14,15)
Reduce the following boolean expression using K-Map
F(A,B,C,D) = (5,6,7,8,9,12,13,14,15)
Reduce the following Boolean expression using K-Map:
F(A,B,C,D)= (0,1,2,4,5,8,9,10,11)
Reduce the following Boolean expression using K Map
F (A, B, C, D) = (0,2,3,4,6,7,8,10,12)
Reduce the following Boolean Expression using K-Map:
F(A,B,C,D)= (0,1,2,4,5,6,8,10)
Obtain a simplified form for a Boolean expression :
F(x, y, z, w) = (0, 1, 3, 5, 7, 9, 10, 11, 13, 15) using Karnaugh map.
Obtain simplified from for a Boolean expression
F(X, Y, Z, W) = (0, 1, 4, 5, 7, 8, 9, 12, 13, 15) using K Map method.

CHAPTER XIV: COMMUNICATION AND NETWORK CONCEPTS


1 Mark Questions
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.

What is the purpose of using a repeater in the context of networking ?


Write an advantage and a disadvantage of using optical fibre cables.
What is the difference between MAN and WAN ?
Define Packet Switching.
Explain the following terms in short :
(i) FTP
(ii) URL
What is the difference between Video Conferencing and Chat.
Write one characteristics each for 2G and 3G Mobile Technologies.
Which type of network (out of LAN, PAN and MAN) is formed, when you connect to mobiles using
Bluetooth to transfer a picture file.
Write two characteristics of Wi-Fi.
Write any two characteristics of Cloud Computing
Expand the following:
i) GSM
ii) GPRS
How firewall protect our Network?
Expand the following:
SMS, URL, WLL, PPP, TCP/IP, FSF, FLOSS, FTP, SMTP, POP, SLIP, FTP, OSS
Write one advantage and disadvantage of various network topologies
Write short notes for the following
Hub, switch, server, modem, repeater
What are OSS and FLOSS ?
What is a network ? Why is it needed ?
What are cookies ?
How is a hacker different from a crackers ?
What do you understand by Cyber Law ?
What is Web Hosting ?
How Trojan Horses are different from Worms? Mention any one difference.
Name one server side scripting language and one client side scripting language.

57 | P a g e

24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.

What are Bridge, Gateway and Router ?


Differentiate between Freeware and Shareware?
What is Ethernet ?
Which media have the ability to communicate over oceans?
What is the difference between microwave and radiowave transmission?
Which is the special case of microwave relay system?
What is bleeding of signal?
Which communication medium is to be suggested for very effective and fast communication in
guided medium?
In harsh industrial environment which cable would you like to use?
Which transmission medium is useful for sparsely populated areas?
In which transmission medium Bandwidth allocation is limited?
What is baud?
Which network is easy to expand?
In which network there is no server?
In Ethernet card which connection is used for coaxial cable or twisted pair or for both?
Which device filter the data and which device can handle different protocol?
Which device do not control broadcast , filter traffic and filter collision?
Which networking device is used for less no. of nodes or which is for more no. of nodes?

42.
43.

What do you mean by Spam Mails? How can you protect your mailbox from Spam?
What do you understand by the terms, Hackers and Crackers?

4 Marks Questions
1. Kanganalay Cosmetics is planning to start their offices in four major cities in Uttar Pradesh to provide
cosmetic product support in its retail fields. The company has planned to set up their offices in
Lucknow at three different locations and have named them as Head office, Sales office, & Prod
office. The companys regional offices are located at Varanasi, Kanpur & Saharanpur. A rough layout
of the same is as follows.

UP

LUCKNOW
Sales
offic e

Head
offic e

Prod
offic e

Varanasi
offic e

Saharanpur
offic e

Kanpur
offic e

An approximate distance between these offices as per network survey team is as follows:
58 | P a g e

Place from

Place to

Distance

Head office

Sales office

15 KM

Head office

Prod office

8 KM

Head office

Varanasi Office

295 KM

Head office

Kanpur Office

195 KM

Head office

Saharanpur office

408 KM

Number of computers :
Head office

156

Sales office

25

Prod office

56

Varanasi Office

85

Kanpur Office

107

Saharanpur office

105

(i) Suggest the cable layout(s) for connecting the offices.


(ii) Name the branch where the server should be installed. Justify your answer.
(iii) Suggest the device to be procured by the company for connecting all the computers within each
of its offices out of the following devices:
Modem

Telephone

Switch/Hub

iv) The company is planning to link its head office situated in Lucknow with the office at
Saharanpur. Suggest an economic way to connect it; the company is ready to compromise on the
speed of connectivity. Justify your answer.
2.

Bhartiya Connectivity Association is planning to spread their offices in four major cities in India
to provide regional IT infrastructure support in the field of Education & Culture. The company has
planned to setup their head office in New Delhi in three locations and have named their New Delhi
offices as Front Office, Back Office and Work Office. The company has three more regional
offices as South Office, East Office and West Office located in other three major cities of India.
A rough layout of the same is as follows :

59 | P a g e

INDIA

New Delhi
Back Office
Front Office
Work Office

West Office

3.

East Office

South Office

Approximate distances between these offices as per network survey team is


as follows:
Place From Place To Distance
BackOffice Front Office 10KM
Back Office Work Office 70 Meter
Back Office East Office 1291 KM
BackOffice West Office 790 KM
Back Office South Office 1952 KM
In continuation of the above, the company experts have planned to install the
following number of computers in each of their offices :Back Office 100 Front Office 20Work
Office 50 East Office 50 West Office 50 South Office 50
(i)
Suggest network type (out of LAN, MAN, WAN) for connecting each of the following set
of their offices :
Back Office and Work Office
Back Office and South Office
(ii)
Which device you will suggest to be procured by the company for connecting all the
computers with in each of their offices out of the following devices?
Switch/Hub
Modem
Telephone
(iii)
Which of the following communication medium, you will suggest to be procured by the
company for connecting their local offices in New Delhi for very effective and fast
communication?
Telephone Cable
Optical Fiber
Ethernet Cable
(iv)
Suggest a cable/wiring layout for connecting the companys local offices located in New
Delhi. Also, suggest an effective method/technology for connecting the companys regional
offices-East Office, West Office and
South Office with offices located in New Delhi.
Lantastic corporation caters to many high profile clients , and has 6 building where it
runs its operation .

Pro

50mtr

Grey

30mtr

Wizard

65mtr
120mtr

45mtr

35mtr
30mtr

Robo

Master
40mtr

60 | P a g e

The distance between buildings are shown through in above diagram . The number in [ ] ,
indicate number of computers in each buildings .
a) Buildings Pro has 55 computers .
b) Buildings Gray has 185 computers .
c) Buildings Wizard has 60 computers .
d) Buildings Master has 70 computers .
e) Buildings Ribo has 55 computers .
Answer the following questions on the basic of above given information .
a) suggest the possible cable layouts for the buildings .
b) Where would you suggest the placement of server .
c) Suggest the cable type that should be used .
d) The management wants that the network traffic should be minimized . for this which networks
devices and why ?
(i) hub
(ii) bridge
(iii) repeater .
4. Hindustan Connecting World Association is planning to start their offices in four major cities in India
to provide regional IT infrastructure support in the field of Education & Culture. The company has
planned to set up their head office in New Delhi in three locations and have named their New Delhi
offices as Sales Office, Head Office and Tech Office. The companys regional offices are located
at Coimbatore, Kolkata and Ahmedabad.
A rough layout of the same is as follows:
Approximate distances between these offices as per network survey team is as follows:
Place From
Place To
Distance
Head Office
Sales Office
10 KM
Head Office
Tech Office
70 Meter
Head Office
Kolkata Office
1291 KM
Head Office
Ahmedabad Office
790 KM
Head Office
Coimbatore Office
1952 KM
In continuation of the above, the company experts have planned to install the following number of
computers in each of their offices:
Head Office
100
Sales Office
20
Tech Office
50
Kolkata Office
50
Ahmedabad Office
50
Coimbatore Office
50
(i) Suggest network type (out of LAN, MAN, WAN) for connecting each of the following set of their
offices:
- Head Office and Tech Office
- Head Office and Coimbatore Office
(ii) Which device will you suggest to be procured by the company for connecting all the computers
within each of their offices out of the following devices?
- Modem
- Telephone
- Switch/ Hub
(iii) Which of the following communication media, will you suggest to be procured by the company for
connecting their local offices in New Delhi for ver effective and fast communication?
- Ethernet Cable
- Optical Fiber
- Telephone Cable
(iv) Suggest a cable/ wiring layout for connecting the companys local offices located in New Delhi. Also,
suggest an effective method/ technology for connecting the companys regional offices at Kolkata,
Coimbatore and Ahmedabad.
61 | P a g e

5.

62 | P a g e

6.

7.

8.

63 | P a g e

(e) Granuda Consultants are setting up a secured network for their office campus at Faridabad for their
day to day office and web based activities. They are planning to have connectivity between 3
building and the head office situated in Kolkata. Answer the questions (e1) to (e4) after going
through the building positions in the campus and other details, which are given below.
[4]

64 | P a g e

9.

(e1) Suggest the most suitable place (i.e. block) to house the server of this organization. Also give a
reason to justify your suggested location.
(e2) Suggest a cable layout of connections between the building inside the campus.
(e3) Suggest the placement of the following devices with justification
(i) Switch
(ii) Repeater
(e4) The organization is planning to provide a high speed link with its head office situated in the
KOLKATA using a wired connection. Which of the following cable will be most suitable for this job?
(i) Optical Fibre
(ii) Co-axial Cable
(iii) Ethernet Cable
10.
Freshminds University of India is starting its Campus in Ana Nagar of South India with its center
admission office in Kolkata. The university has 3 major blocks comprising of Office Block, Science
Block and Commerce Block in the 5 km area Campus.
As a network expert, you need to suggest the network plan as per (i) to (iv) to the authorities
keeping in mind the distance and other given parameters.

Freshminds University
Ana Nagar Campus

65 | P a g e

Kolkata Admission

Office

Office

Block

Commerce
Block
Science
Block

Expected Wire distance between various locations:


Office Block to Science Block
Office Block to Commerce Block
Science Block to Commerce Block
Kolkata Admission office to Ana Nagar Campus

90 m
80 m
15 m
2450 km

Expected numbers of Computers to be installed at various locations in the University


are as follow:
Office Block
Science Block
Commerce Block
Kolkata Admission Office

10
140
30
8

e1. Suggest the authorities, the cable layout amongst various blocks inside university campus for
connecting the blocks.
e2. Suggest the most suitable place (i.e., block) to house the server of university with a suitable reason.
e3. Suggest an efficient device from the following to be installed in each of the blocks to connect all the
computers:

MODEM

SWITCH

GATEWAY
e4. Suggest the most suitable (very high speed) service to provides data connectivity between
admission
Office located in Kolkata and the campus located in Ana Nagar from the following options:

Telephone Line

Fixed-Line Dial-up connection

Co-axial cable network

GSM

Leased line

Satellite Connection
11.

Vidya for All is an educational NGO. It is setting up its new campus at Jaipur for its web
Based activities. The campus has four buildings as shown in diagram below:

Main
Building

Training
Building

66 | P a g e

Resource
Building

Accounts
Building

Center to center distances between various buildings as per architectural drawings (in meters) is as
follows:
Main Building to Resource Building

120m

Main Building to Training Building

40m

Main Building to Accounts Building

135m

Resource Building to Training Building

125m

Resource Building to Accounts Building

45m

Training Building to Accounts Building

110m

Expected number of Computers in each building is as follows:


Main Building

15

Resource Building

25

Training Building

250

Accounts Building

10

(i)
(ii)

Suggest a cable layout of connection between the buildings.


Suggest the most suitable place ( i.e building) to house the server of this NGO.
Also provide a suitable reason for your suggestion.
(iii) Suggest the placement of the following devices with justification:
i.
Repeater
ii.
Hub/Switch
(iv) The NGO is planning to connect its International office situated in Delhi. Which out of
following wired communication links, will you suggest for very high speed connectivity?
i) Telephone Analog Line ii) Optical Fibre
iii) Ethernet Cable
12.

The Reliance Info Sys has set up its Branch at Srinagar for its office and web based activities. It has 4
Zone of buildings as shown in the diagram:

67 | P a g e

Zone Z

Zone Y

Zone X

Zone U

Center to center distances various blocks

Number of computer

Zone X to Zone Z

40 m

Zone X

50

Zone Z to Zone Y

60 m

Zone Z

130

Zone Y to Zone X

135 m

Zone Y

40

Zone Y to Zone U

70 m

Zone U

15

Zone X to Zone U

165 m

Zone Z to Zone U

80 m

(e1)

Suggest a most suitable cable layout of connections between the Zones and topology.

(e2)

Suggest the most suitable place (i.e., Zone) to house the server of this organization with a
suitable reason, with justification.
1

(e3)

Suggest the placement of the following devices with justification:

(e4)

(1) Repeater
(2) Hub / Switch
The organization id planning to link its head office situated in Mumbai at the offices at
Srinager. Suggest an economic way to connect it; the company is ready to compromise on
the speed of connectivity. Justify your answer.

***************

68 | P a g e

Вам также может понравиться