Computer Science Class 12 Question Bank Sol (2014-17)
Computer Science Class 12 Question Bank Sol (2014-17)
Teaching
&
Class XII Learning
Material
Question Bank (2014-2017)
With Solution
2015 Find the correct identifiers out of the following, which can be used for naming Variable,
Constants or Functions in a C++ program:
For, while, INT, NeW, delete, 1stName, Add+Subtract, name1
Ans For, INT, NeW, name1
2016 Out of the following, find those identifiers, which canno t be used for naming Variable,
Constants or Functions in a C++ program:
Total*Tax,double, Case, My Name,New,switch,Column31, _Amount
Ans Total*Tax ,double, My Name ,switch
2017 Write the type of C++ tokens (keywords and user defined identifiers) from the following:
(i) new
(ii) While
(iii) case
(iv) Num_2
Ans (i) new - Keyword
(ii) While - User defined Identifier
(iii) case - Keyword
(iv) Num_2 - User defined Identifier
(b) 1 Mark
2014 Observe the following C++ code and write the name(s) of the header file(s), which will be
essentially required to run it in a C++ compiler :
void main()
{
char CH,STR[20];
cin>>STR;
CH=toupper(STR[0]);
cout<<STR<<starts with<<CH<<endl;
}
Ans iostream.h , ctype.h
2015 Observe the following program very carefully and write the names of those header file(s),
which are essentially needed to compile and execute the following program successfully:
typedef char STRING[80];
void main ()
{
STRING Txt [] = "We love Peace";
int Count=0;
while (Txt[Count]!='\0') if(isalpha(Txt[Count]))
Txt[Count++]='@' ;
else
Txt[Count++]='#' ;
puts(Txt);
}
Ans ctype.h, stdio.h
2016 Ronica Jose has started learning C++ and has typed the following program. When she
compiled the following code written by her, she discovered that she needs to include some
header files to successfully compile and execute it. Write the names of those header files,
which are required to be included in the code.
void main()
{double X,Times,Result;
cin>>X>>Times;
Result=pow(X,Times);
cout<<Result<<endl;
}
Ans iostream.h OR iomanip.h , math.h
2017 Anil typed the following C++ code and during compilation he found three errors as follows:
(i) Function strlen should have prototype
(ii) Undefined symbol cout
(iii) Undefined symbol endl
On asking, his teacher told him to include necessary header files in the code. Write the
names of the header files, which Anil needs to include, for successful compilation and
execution of the following code
void main()
{
char Txt[] = "Welcome";
for(int C= 0; C<strlen(Txt); C++) Txt[C]
= Txt[C]+1;
cout<<Txt<<endl;
}
Ans string.h , iostream.h OR fstream.h OR iomanip.h
(C) 2 Marks
2014 Rewrite the following C++ code after removing all the syntax error(s), if present in the code.
Make sure that you underline each correction done by you in the code.
Important Note :
– Assume that all the required header files are already included.
– The corrections made by you do not change the logic of the program.
typedef char[80] STR;
void main()
{ Txt STR;
gets(Txt);
cout<<Txt[0]<<’\t<<Txt[2];
cout<<Txt<<endline;
}
Ans typedef char[80] STR;
void main()
{ STR Txt;
gets(Txt);
cout<<Txt[0]<<’\t’ <<Txt[2];
cout<<Txt<<endl;
}
2015 Observe the following C++ code very carefully and rewrite it after removing any/all
syntactical errors with each correction underlined.
Note: Assume all required header files are already being included in the program.
#Define float MaxSpeed =60.5;
void main()
{
int MySpeed
char Alert='N';
cin>> MySpeed;
if MySpeed > MaxSpeed
Alert='Y';
cout<<Alert<<endline;
}
Ans #define MaxSpeed 60.5 //Error 1(define),2(=),3 (;)
void main()
{
int MySpeed ; //Error 4
char Alert='N';
cin>>MySpeed;
if (MySpeed>MaxSpeed) //Error 5
Alert=’Y’;
cout<<Alert<< endl; //Error 6
}
2016 Rewrite the following C++ code after removing any/all syntactical errors with each correction
underlined.
Note: Assume all required header files are already being included in the program.
2017 Find and write the output of the following C++ program code:
Note: Assume all required header files are already included in the program.
#define Diff(N1,N2) ((N1>N2)?N1-N2:N2-N1)
void main()
{
int A,B,NUM[] = {10,23,14,54,32};
for(int CNT =4; CNT>0; CNT--)
{ A=NUM[CNT];
B=NUM[CNT-1];
cout<<Diff(A,B)<<'#';
}
}
Ans 22#40#9#13#
(e) 3 Marks
2014 Obtain the output of the following C++ program, which will appear on the screen after
its execution.
Note : All the desired header files are already included in the code, which are
required to run the code.
class Game
{ int Level, Score;
char Type;
public:
Game(char GType=’P’)
{Level=1;Score=0;Type=GType;}
void Play(int GS);
void Change();
void Show()
{cout<<Type<<”@”<<Level<<endl;
cout<<Score<<endl;
}
};
void main()
{ Game A(‘G’),B;
B.Show();
A.Play(11);
A.Change();
B.Play(25);
A.Show();
B.Show();
}
void Game::Change()
{
Type=(Type==’P’)?’G’:’P’;
}
void Game::Play(int GS)
{ Score+=GS;
if(Score>=30)
Level=3;
else if(Score>=20)
Level=2;
else
Level=1;
}
Ans P@1
0
P@1
11
P@2
25
2015 Write the output of the following C++ program code:
Note: Assume all required header files are already being included in the program.
class Eval
{
char Level;
int Point;
public:
Eval() {Level='E'; Point=0;}
void Sink(int L)
{ Level-= L;
}
void Float(int L)
{ Level += L;
Point++;
}
void Show()
{ cout<<Level<<"#"<<Point<<endl;
}
};
void main()
{ Eval E;
E.Sink(3);
E.Show();
E.Float(7);
E.Show();
E.Sink(2);
E.Show();
}
Ans B#0
I#1
G#1
2016 Find and write the output of the following C++ program code:
Note: Assume all required header files are already being included in the program.
class Share
{
long int Code; float
Rate; int DD;
public:
Share()
{Code=1000;Rate=100;DD=1;}
void GetCode(long int C,float R)
{Code=C; Rate=R;
}
void Update(int Change,int D)
{ Rate+=Change;
DD=D;
}
void Status()
{
cout<<”Date:”<<DD<<endl;
cout<<Code<<”#”<<Rate<<endl;
}
};
void main()
{
Share S,T,U;
S.GetCode(1324,350);
T.GetCode(1435,250);
S.Update(50,28);
U.Update(-25,26);
S.Status();
T.Status();
U.Status();
}
Ans Date:28 1324#400
Date:1 1435#250
Date:26 1000#75
2017 Find and write the output of the following C++ program code: Note: Assume
all required header files are already being included in the program.
void main()
{
int *Point, Score[]={100,95,150,75,65,120};
Point = Score;
for(int L = 0; L<6; L++)
{
if((*Point)%10==0)
*Point /= 2; else
*Point -= 2;
if((*Point)%5==0)
*Point /= 5; Point++;
}
for(int L = 5; L>=0; L--)
cout<<Score[L]<<"*";
}
Ans 12*63*73*15*93*10*
(f) 2 Marks
2014 Read the following C++ code carefully and find out, which out of the given options (i)
to (iv) are the expected correct output(s) of it. Also, write the maximum and
minimum value that can be assigned to the variable Taker used in the code :
void main()
{
int GuessMe[4]={100,50,200,20};
int Taker=random(2)+2;
for (int Chance=0;Chance<Taker;Chance++)
cout<<GuessMe[Chance]<<#;
}
(i) 100#
(ii) 50#200#
(iii) 100#50#200#
(iv) 100#50
void main()
{ randomize();
int VAL;
VAL=random(3)+2;
char GUESS[]="ABCDEFGHIJK";
for (int I=l;I<=VAL;I++)
{ for(int J=VAL;J<=7;J++)
cout«GUESS[J];
cout«endl;
}
}
(i) (ii)
(iii)
(iv)
BCDEFGH CDEFGH EFGH FGHI
BCDEFGH CDEFGH EFGH FGHI
EFGH FGHI
EFGH FGHI
Ans Possible Output (ii) and (iii)
Min Value of VAL = 2
Max Value of VAL = 4
2016 Look at the following C++ code and find the possible output(s) from the options (i) to (iv)
following it. Also, write the maximum and the minimum values that can be assigned to the
variable PICKER.
void main()
{
randomize();
int PICKER;
PICKER=1+random(3);
char COLOR[][5]={”BLUE”,”PINK”,”GREEN”,”RED”};
for(int I=0;I<=PICKER; I++)
{
for(int J=0; J<=I;J++)
cout<<COLOR[J];
cout<<endl;
}
}
(i) (ii) (iii) (iv)
PINK BLUE GREEN BLUE
PINKGREEN BLUEPINK GREENRED BLUEPINK
PINKGREENRED BLUEPINKGREEN BLUEPINKGREEN
BLUEPINKGREENRED
Ans Possible Output may be (ii) & (iv)
Minimum value of Picker =1
Maximum value of Picker= 3
2017 Look at the following C++ code and find the possible output(s) from the options (i) to (iv)
following it. Also, write the maximum values that can be assigned to each of the variables N
and M.
Note:
● Assume all the required header files are already being included in the code.
● The function random(n) generates an integer between 0 and n-1
void main()
{ randomize();
int N=random(3),M=random(4);
int DOCK[3][3] = {{1,2,3},{2,3,4},{3,4,5}};
for(int R=0; R<N; R++)
{
for(int C=0; C<M; C++)
cout<<DOCK[R][C]<<" ";
cout<<endl;
}
}
(I) Which specific concept of object oriented programming out of the following is
illustrated by Member Function 1 and Member Function 2 combined together?
● Data Encapsulation
● Polymorphism
● Inheritance
● Data Hiding
(II) How many times the message ”Book Discarded!” will be displayed after executing the
above C++ code? Out of Line 1 to Line 9, which line is responsible to display the message
”Book Discarded!”
Ans (i) Polymorphism
(ii) 2 times Line 9
2017 Observe the following C++ code and answer the questions (i) and (ii). Note: Assume all
necessary files are included.
class TEST
{
long TCode;
char TTitle[20]; float
Score;
public:
TEST() //Member Function 1
{
TCode=100;strcpy(TTitle,”FIRST Test”);Score=0;
}
TEST(TEST &T) //Member Function 2
{
TCode=E.TCode+1; strcpy(TTitle,T.TTitle);
Score=T.Score;
}
};
void main()
{
//Statement 1
//Statement 2
}
(i) Which Object Oriented Programming feature is illustrated by the Member
Function 1 and Member Function 2 together in the class TEST?
(ii) Write Statement 1 and Statement 2 to execute Member Function 1 and
Member Function 2 respectively.
Ans (i) Polymorphism OR Constructor overloading OR Function Overloading
(ii) TEST T1; //Statement 1
TEST T2(T1); //Statement 2
OR
TEST T2=T1; //Statement 2
(C) 4 Marks
2014 Define a class Tourist in C++ with the following specification :
Data Members
CNo - to store Cab No
CType - to store a character ‘A’, ‘B’, or ‘C’ as City Type
PerKM - to store per Kilo Meter charges
Distance - to store Distance travelled (in KM)
Member Functions
A constructor function to initialize CType as ‘A’ and CNo as
‘0000’
A function CityCharges( ) to assign PerKM as per the following
table :
CType PerKM
A 20
B 18
C 15
A function RegisterCab() to allow administrator to enter the
values for CNo and CType. Also, this function should call
CityCharges() to assign PerKM Charges.
A function Display() to allow user to enter the value of
Distance and display CNo, CType, PerKM, PerKM*Distance (as
Amount) on screen.
Ans class Tourist
{ char CNo[5];
char CType;
float PerKm;
float Distance;
void CityCharges()
{if (CType==’A’)
PerKm=20;
else if (CType==’B’)
PerKm=18;
else if (CType==’C’)
PerKm=15;
}
public:
Touris ()
{CType=’A’;
Strcpy(CNo,”0000”);
}
void RegisterCab()
{cout<< “Enter cab No.”;
cin>>CNo;
cout<<”Enter City Type (A/B/C)”;
cin>>CType;
CityCharges();
}
void Display()
{cout<<”Enter Distance”;
cin>> Distance;
cout<<”Cab No.:”<<CNo <<endl;
cout<<”City Type:”<<CType << endl;
cout << “Per KM charges :”<< PerKm <<endl;
cout <<”Amount :”<< (PerKm *Distance)<<endl;
}
};
2015 Write the definition of a class Photo in C++ with following description:
Private Members
Pno //Data member for Photo Number (an integer)
Category //Data member for Photo Category (a string)
Exhibit //Data member for Exhibition Gallery (a string)
FixExhibit // A member function to assign Exhibition Gallery
// as per Category as shown in the following table
Category Exhibit
Antique Zaveri
Modern Johnsen
Classic Terenida
Public Members
Register() //A function to allow user to enter values
//Pno,Category and call FixExhibit() function
ViewAll() //A function to display all the data members
Ans class Photo
{ int Pno;
char Category[20];
char Exhibit[20];
void FixExhibit();
public:
void Register();
void ViewAll();
};
void Photo::FixExhibit()
{if(strcmpi(Category,”Antique”)==0)
strcpy(Exhibit,”Zaveri”);
else if(strcmpi(Category,”Modern”)==0)
strcpy(Exhibit,”Johnsen”);
else if strcmpi(Category,”Classic”)==0)
strcpy(Exhibit,”Terenida”);
}
void Photo::Register()
{ cin>>Pno;
gets(Category);
FixExhibit();
}
void Photo:: ViewAll()
{ cout<<Pno<<Category<<Exhibit<<endl;
}
2016 Write the definition of a class CITY in C++ with following description:
Private Members
- Ccode //Data member for City Code (an integer)
- CName //Data member for City Name (a string)
- Pop //Data member for Population (a long int)
- KM //Data member for Area Coverage (a float)
- Density //Data member for Population Density (a float)
- DenCal() //A member function to calculate ---
//Density as Pop/KM
Public Members
- Record() //A function to allow user to enter values of
//Acode,Name,Pop,KM and call DenCal() function
- View() //A function to display all the data members
//also display a message ”Highly Populated City”
//if the Density is more than 10000
Ans class CITY
{ int Ccode;
char CName[20];
long int Pop;
float KM;
float Density;
void DenCal();
public:
void Record();
void View();
};
void CITY::Record()
{ cin>>Ccode;
gets(CName); //OR cin>>CName;
cin>>Pop;
cin>>KM; DenCal();
}
void CITY::View()
{ cout<<Ccode<<CName<<Pop<<KM<<Density; //Ignore endl
if(Density>10000)
cout<<”Highly Populated City”; //Ignore endl
}
void CITY::DenCal()
{ Density= Pop/KM;
}
2017 Write the definition of a class BOX in C++ with following description:
Private Members
- BoxNumber // data member of integer type
- Side // data member of float type
- Area // data member of float type
- ExecArea() // Member function to calculate and assign
// Area as Side * Side
Public Members
- GetBox() // A function to allow user to enter values of
// BoxNumber and Side. Also, this
// function should call ExecArea() to calculate
// Area
- ShowBox() // A function to display BoxNumber, Side
// and Area
Ans class BOX
{
int BoxNumber ; float
Side ; float Area ;
void ExecArea(){ Area=Side*Side;} public:
void GetBox(); void
ShowBox();
};
void BOX::GetBox()
{
cin>>BoxNumber>>Side; ExecArea();
}
void BOX::ShowBox()
{
cout<<BoxNumber<<” ”<<Side<<” ”<<Area<<endl;
}
(d) 4 Marks
2014 Consider the following C++ code and answer the questions from (i) to (iv) :
class University
{ long Id;
char City[20];
protected:
char Country[20];
public:
University();
void Register( );
void Display( );
};
class Department: private University
{ long DCode[10];
char HOD[20];
protected:
double Budget;
public:
Department();
void Enter();
void Show();
};
class Student: public Department
{ long RollNo;
char Name[20];
public:
Student();
void Enroll();
void View();
};
(i) Which type of Inheritance out of the following is illustrated in the above
example?
‐Single Level Inheritance
‐Multi Level Inheritance
‐Multiple Inheritance
(ii) Write the names of all the data members, which are directly accessible from the
member functions of class Painting.
(iii) Write the names of all the member functions, which are directly accessible from
an object of class Billing.
(iv) What will be the order of execution of the constructors,when an object of class
Billing is declared?
Ans (i) Multi Level Inheritance
(ii) WallArea, ColorCode,Type, Advance
(iii) Bill(), BillPrint(), PBook(), PView(), Book(), View()
(iv) Interior, Painting, Billing
2016 Answer the questions (i) to (iv) based on the following:
class ITEM
{ int Id;
char IName[20]; protected:
float Qty; public:
ITEM();
void Enter(); void View();
};
class TRADER
{ int DCode;
protected:
char Manager[20]; public:
TRADER();
void Enter(); void
View();
};
class SALEPOINT : public ITEM,private TRADER
{ char Name[20],Location[20];
public :
SALEPOINT();
void EnterAll(); void
ViewAll();
};
(i) Which type of Inheritance out of the following is illustrated in the above example?
- Single Level Inheritance
- Multi Level Inheritance
- Multiple Inheritance
(ii) Write the names of all the data members, which are directly accessible from the
member functions of class SALEPOINT.
(iii) Write the names of all the member functions, which are directly accessible by an
object of class SALEPOINT.
(iv) What will be the order of execution of the constructors, when an object of class
SALEPOINT is declared?
Ans (i) Multiple Inheritance
(ii) Name, Location, Manager, Qty
(iii) EnterAll(), ViewAll(), Enter(), View()
(iv) ITEM(), TRADER(), SALEPOINT()
The function should calculate the sum and display the following: Sum of Middle
Column: 15
Ans void SUMMIDCOL(int MATRIX[][10],int N,int M)
{ int mid=M/2; int sum=0;
for(int i=0; i<N; i++)
{sum=sum+MATRIX[i][mid];
}
cout<<” Sum of Middle Column”<<sum;
}
(b) 3 Marks
2014 An array A[20][30] is stored along the row in the memory with each element
requiring 4 bytes of storage. If the base address of array A is 32000, find out the
location of A[15][10]. Also, find the total number of elements present in this array.
Ans Loc(A[I][J]) =BaseAddress + W [( I – LBR)*C + (J – LBC)]
(where C is the number of columns, LBR = LBC = 0)
LOC(A[15][10]) = BaseAddress + W [ I*C + J]
= 32000 + 4[15*30 + 10]
= 32000 + 4[450 + 10]
= 32000 + 4 x 455
= 32000 + 1820
= 33820
Total Element in the Array = Row x Col = 20 x 30
= 600
2015 A two dimensional array ARR[50][20] is stored in the memory along the row with
each of its elements occupying 4 bytes. Find the address of the element RR[30][10],
if the element ARR[10] [5] is stored at the memory location 15000.
Ans Loc(ARR[I][J]) =BaseAddress + W [( I – LBR)*C + (J – LBC)]
(where C is the number of columns, LBR = LBC = 0
LOC(ARR[10][5])= BaseAddress + W [ I*C + J]
15000 = BaseAddress + 4[10*20 + 5]
= BaseAddress + 4[200 + 5]
= BaseAddress + 4 x 205
= BaseAddress + 820
BaseAddress = 15000-820
= 14180
LOC(ARR[30][10])= 14180 + 4[30 * 20 + 10]
= 14180 + 4 * 610
= 14180 + 2440
= 16620
2016 R[10][50] is a two dimensional array, which is stored in the memory along the
row with each of its element occupying 8 bytes, find the address of the
element R[5][15], if the element R[8][10] is stored at the memory location
45000.
Ans Loc(R[I][J]) = BaseAddress + W [( I – LBR)*C + (J – LBC)]
(where W=size of each element = 8 bytes,R=Number of Rows=10,
C=Number of Columns=50) Assuming LBR = LBC = 0
LOC(R[8][10])
45000 = BaseAddress + W[ I*C + J] 45000
= BaseAddress + 8[8*50 + 10]
BaseAddress = 45000 - 3280 = 41720
LOC(R[5][15])= BaseAddress + W[ I*C + J]
= 41720 + 8[5*50 + 15]
= 43840
2017 ARR[15][20] is a two-dimensional array, which is stored in the memory along the
row with each of its elements occupying 4 bytes. Find the address of the element
ARR[5][15], if the element ARR[10][5] is stored at the memory location 35000.
Ans ROW MAJOR:
Loc(ARR[I][J]) =BaseAddress + W [( I – LBR)*C + (J – LBC)]
where W=size of each element = 4 bytes, R=Number of
Rows=15, C=Number of Columns=20 )
Assuming LBR = LBC = 0
LOC(ARR[10][5])
35000 = BaseAddress + W(I*C + J)
35000 = BaseAddress + 4(10*20 + 5)
35000 = BaseAddress + 4(205)
35000 = BaseAddress + 820
BaseAddress = 35000 - 820
= 34180
LOC(ARR[5][15])= BaseAddress + W(I*C + J)
= 34180 + 4(5*20 + 15)
= 34180 + 4(100 + 15)
= 34180 + 4 x 115
= 34180 + 460
= 34640
(C) 4 Marks
2014 Write a function PUSHBOOK( ) in C++ to perform insert operation on a Dynamic
Stack, which contains Book_no and Book_Title. Consider the following definition of
NODE, while writing your C++ code.
struct NODE
{ int Book_No;
char Book_Title[20];
NODE *Next;
};
Ans //Assumed that top is global Node type pointer.
void PUSHBOOK( )
{ NODE *ptr;
ptr= new NODE;
cout<< “Enter Book Number:”;
cin>> ptr->Book_No;
cout<< “Enter Book Name:”;
gets(ptr->Book_Title);
if (top==NULL)
top=ptr;
else
{ ptr->next=top;
top=ptr;
}
}
2015 Write the definition of a member function PUSH() in C++, to add a new book in a
dynamic stack of BOOKS considering the following code is already included in the
program:
struct BOOKS
{ char ISBN[20], TITLE[80];
BOOKS *Link;
};
class STACK
{ BOOKS *Top;
public:
STACK()
{Top=NULL;}
void PUSH();
void POP();
~STACK();
};
Ans void STACK::PUSH()
{ BOOKS *Temp;
Temp=new BOOKS;
gets(Temp->ISBN);
gets(Temp->TITLE);
Temp->Link=Top;
Top=Temp;
}
2016 Write the definition of a member function DELETE() for a class QUEUE in C++, to
remove a product from a dynamically allocated Queue of products considering the
following code is already written as a part of the program.
struct PRODUCT
{int PID; char PNAME[20];
PRODUCT *Next;
};
class QUEUE
{PRODUCT *R,*F;
public:
QUEUE(){R=NULL;F=NULL;}
void INSERT();
void DELETE();
~QUEUE();
};
Ans void QUEUE::DELETE()
{ if(F!=NULL)
{ PRODUCT *T = F;
cout<<T>PID<<T>PNAME;
F=F>Next;
delete T;
if(F==NULL)
{R=NULL; }
}
else
cout<<”Queue Empty”;
}
2017 Write the definition of a member function PUSHGIFT() for a class STACK in C++,
to add a GIFT in a dynamically allocated stack of GIFTs considering the following
code is already written as a part of the program:
struct GIFT
{ int GCODE; //Gift Code
char GDESC[20]; //Gift Description GIFT
*Link;
};
class STACK
{
Gift *TOP; public:
STACK(){TOP=NULL;} void
PUSHGIFT(); void
POPGIFT();
~STACK();
};
Ans void STACK::PUSHGIFT()
{
GIFT *T = new GIFT; cin>>T->GCODE;
gets(T->GDESC);
T->Link = TOP; TOP = T;
}
(d) 3 Marks
2014 Write a user-defined function AddEnd2(int A[][4],int N,int M) in C++ to find and
display the sum of all the values, which are ending with 2 (i.e., units place is 2).
For example if the content of array is :
22 16 12
19 5 2
NOTE:
● The function should only alter the content in the same array.
● The function should not copy the altered content in another array.
● The function should not display the altered content of the array.
● Assuming, the Number of elements in the array are Even.
= PQR-/S*T+
2017 Convert the following Infix expression to its equivalent Postfix expression, showing
the stack contents for each step of conversion:
X - ( Y + Z ) / U * V
Ans
Question No. 4: (6 Marks)
(a) 2 Marks
2014 Fill in the blanks marked as Statement 1 and Statement 2, in the program segment
given below with appropriate functions for the required task.
class Agency
{int ANo; //Agent Code
char AName[20]; //Agent Name
char Mobile[12]; //Agent Mobile
public:
void Enter(); //Function to enter details of agent
void Disp(); //Function to display details of agent
int RAno(){return ANo;}
void UpdateMobile() //Function to update Mobile
{cout<<Updated Mobile:;
gets(Mobile);
}
};
void AgentUpdate()
{ fstream F;
F.open(“AGENT.DAT,ios::binary|ios::in|ios::out);
int Updt=0;
int UAno;
cout<<Ano (Agent No - to update Mobile):;
cin>>UAno;
Agency A;
while (!Updt && F.read((char*)&A,sizeof(A)))
{ if (A.RAno()==UAno)
{ //Statement 1: To call the function to Update Mobile No.
_______________________________________ ;
//Statement 2:To reposition file pointer to re-write
the updated object back in the file
_________________________________________ ;
F.write((char*)&A,sizeof(A));
Updt++;
}
}
if (Updt)
cout<<Mobile Updated for Agent<<UAno<<endl;
else
cout<<Agent not in the Agency<<endl;
F.close();
}
Ans Statement 1: A.UpdateMobile();
Statement 2: F.seekg (-1*sizeof(A), ios::cur);
2015 Write function definition for TOWER() in C++ to read the content of a text file
WRITEUP.TXT, count the presence of word TOWER and display the number of
occurrences of this word.
Note :
‐ The word TOWER should be an independent word
‐ Ignore type cases (i.e. lower/upper case)
Example:
If the content of the file WRITEUP.TXT is as follows:
Tower of hanoi is an interesting problem.Mobile phone tower is
away from here. Views from EIFFEL TOWER are amazing.
The function TOWER () should display the following:
3
Ans void TOWER()
{int count=0;
ifstream f("WRITEUP.TXT");
char s[20];
while (!f.eof())
{ f>>s;
if (strcmpi(s,”TOWER”)==0)
count++;
}
cout<<count;
f.close();
}
2016 Write function definition for DISP3CHAR() in C++ to read the content of a text file
KIDINME.TXT, and display all those words, which have three characters in it.
Example: If the content of the file KIDINME.TXT is as follows:
When I was a small child, I used to play in the garden with my
grand mom. Those days were amazingly fun ful and I remember all
the moments of that time.
The function DISP3CHAR() should display the following:
was the mom and all the
Ans void DISP3CHAR()
{ ifstream Fil;
Fil.open(“KIDINME.TXT”);
char W[20];
Fil>>W;
while(!Fil.eof()) // OR while(Fil)
{ if (strlen(W)) == 3)
cout<<W<< “ “;
Fil>>W;
}
Fil.close();
}
2017 Polina Raj has used a text editing software to type some text in an article. After saving the
article as MYNOTES.TXT, she realised that she has wrongly typed alphabet K in place of
alphabet C everywhere in the article.
Write a function definition for PURETEXT() in C++ that would display the corrected version
of the entire article of the file MYNOTES.TXT with all the alphabets “K” to be displayed as
an alphabet “C” on screen.
Note: Assuming that MYNOTES.TXT does not contain any C alphabet otherwise.
Example:
If Polina has stored the following content in the file MYNOTES.TXT:
STUDENT x TEACHER
SCODE SNAME TCODE TNAME
S1 Amit Kumar 1001 Raman Kumar
S1 Amit Kumar 1002 Mohan Chandra
S2 Anubhuti 1001 Raman Kumar
S2 Anubhuti 1002 Mohan Chandra
S3 John 1001 Raman Kumar
S3 John 1002 Mohan Chandra
2015 Observe the following table carefully and write the names of the most appropriate
columns, which can be considered as
(i) candidate keys and (ii) primary key.
RESULT
PNO NAME EVENTCODE EVENTNAME
1 Aruanabha Tariban 1001 IT Quiz
1 Aruanabha Tariban 1002 Group Debate
2 John Fedricks 1001 IT Quiz
2 John Fedricks 1002 Group Debate
3 Kanti Desai 1001 IT Quiz
3 Kanti Desai 1002 Group Debate
Ans Cartesian Product
Degree = 4
Cardinality = 6
2017 Observe the following table MEMBER carefully and write the name of the RDBMS
operation out of (i) SELECTION (ii) PROJECTION (iii) UNION (iv) CARTESIAN
PRODUCT, which has been used to produce the output as shown in RESULT. Also,
find the Degree and Cardinality of the RESULT.
Note: DOJ refers to date of joining and DOB refers to date of Birth of employees.
(i) To display Eno, Name, Gender from the table EMPLOYEE in ascending order of Eno.
Ans SELECT Eno,Name,Gender FROM Employee ORDER BY Eno;
(ii) To display the Name of all the MALE employees from the table EMPLOYEE.
Ans SELECT Name FROM Employee WHERE Gender=’MALE’;
(iii) To display the Eno and Name of those employees from the table EMPLOYEE w ho are
born between '1987‐01‐01' and '1991‐12‐01'.
Ans SELECT Eno,Name FROM Employee WHERE DOB BETWEEN ‘1987-01-01’
AND ‘1991-12-01’;
OR
SELECT Eno,Name FROM Employee WHERE DOB >=‘1987-01-01’
AND DOB <=‘1991-12-01’ ;
(iv) To count and display FEMALE employees who have joined after '1986‐01‐01'.
Ans SELECT count(*) FROM Employee
WHERE GENDER=’FEMALE’ AND DOJ > ‘19860101’;
(v) SELECT COUNT(*),DCODE FROM EMPLOYEE
GROUP BY DCODE HAVING COUNT(*)>1;
Ans COUNT DCODE
2 D01
2 D05
(vi) SELECT DISTINCT DEPARTMENT FROM DEPT;
Ans Department
INFRASTRUCTURE
MARKETING
MEDIA
FINANCE
HUMAN RESOURCE
(vii) SELECT NAME, DEPARTMENT FROM EMPLOYEE E, DEPT
D WHERE E.DCODE=D.DCODE AND EN0<1003;
Ans NAME DEPARTMENT
George K INFRASTRUCTURE
Ryma Sen MEDIA
(viii) SELECT MAX(DOJ), MIN(DOB) FROM EMPLOYEE;
Ans MAX(DOJ) MIN(DOB)
2014-06-09 1984-10-19
2016 Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii), which are based
on the tables
Table: VEHICLE
VCODE VEHICLETYPE PERKM
V01 VOLVO BUS 150
V02 AC DELUXE BUS 125
V03 ORDINARY BUS 80
V05 SUV 30
V04 CAR 18
Note: PERKM is Freight Charges per kilometer
Table: TRAVEL
CNO CNAME TRAVELDATE KM VCODE NOP
101 K.Niwal 2015-12-13 200 V01 32
103 Fredrick Sym 2016-03-21 120 V03 45
105 Hitesh Jain 2016-04-23 450 V02 42
102 Ravi Anish 2016-01-13 80 V02 40
107 John Malina 2015-02-10 65 V04 2
104 Sahanubhuti 2016-01-28 90 V05 4
106 Ramesh Jaya 2016-04-06 100 V01 25
● Km is Kilometers travelled
● NOP is number of passengers travelled in vehicle
(i) To display CNO, CNAME, TRAVELDATE from the table TRAVEL in descending order of CNO.
Ans SELECT CNO,CNAME,TRAVELDATE FROM TRAVEL ORDER BY CNO DESC;
(ii) To display the CNAME of all the customers from the table TRAVEL who are traveling
by vehicle with code V01 or V02.
Ans SELECT CNAME FROM TRAVEL WHERE VCODE=‘V01’ OR VCODE=’V02’;
(iii) To display the CNO and CNAME of those customers from the table TRAVEL who travelled
between ‘2015‐12‐31’ and ‘2015‐05‐01’.
Ans SELECT CNO, CNAME from TRAVEL WHERE TRAVELDATE >=
‘20150501’ AND TRAVELDATE <= ‘20151231’;
(iv) To display all the details from table TRAVEL for the customers, who have travel distance
more than 120 KM in ascending order of NOP.
Ans SELECT * FROM TRAVEL
WHERE KM > 120 ORDER BY NOP;
(v) SELECT COUNT(*),VCODE FROM TRAVEL GROUP
BY VCODE HAVING COUNT(*)>1;
Ans COUNT(*) VCODE
2 V01
2 V02
(vi) SELECT DISTINCT VCODE FROM TRAVEL;
Ans DISTINCT VCODE
V01
V02
V03
V04
V05
(vii) SELECT A.VCODE,CNAME,VEHICLETYPE FROM TRAVEL A,VEHICLE B
WHERE A.VCODE=B.VCODE AND KM<90;
Ans VCODE CNAME VEHICLETYPE
V02 Ravi Anish AC DELUXE BUS
V04 John Malina CAR
(viii) SELECT CNAME,KM*PERKM FROM
TRAVEL A,VEHICLE B
WHERE A.VCODE=B.VCODE AND A.VCODE=’V05’;
Ans CNAME KM*PERKM
Sahanubhuti 2700
2017 Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii), which
are based on the tables
(i) To display all details from the table MEMBER in descending order of ISSUEDATE.
Ans SELECT * FROM MEMBER ORDER BY ISSUEDATE DESC;
(ii) To display the DCODE and DTITLE of all Folk Type DVDs from the table DVD
Ans SELECT DCODE,DTITLE FROM DVD WHERE DTYPE=’Folk’;
(iii) To display the DTYPE and number of DVDs in each DTYPE from the table DVD
Ans SELECT COUNT(*),DTYPE FROM DVD GROUP BY DTYPE;
(iv) To display all NAME and ISSUEDATE of those members from the table MEMBER who
have DVDs issued (i.e ISSUEDATE) in the year 2017
Ans SELECT NAME, ISSUEDATE FROM MEMBER WHERE ISSUEDATE>=’2017-
01-01’ AND ISSUEDATE<=’2017-12-31’;
OR
SELECT NAME, ISSUEDATE FROM MEMBER WHERE ISSUEDATE BETWEEN
‘2017-01-01’ AND ‘2017-12-31’;
(v) SELECT MIN(ISSUEDATE) FROM MEMBER;
Ans MIN(ISSUEDATE)
2016-12-13
(vi) SELECT DISTINCT DTYPE FROM DVD;
Ans DISTINCT DTYPE
Folk
Classical
Rock
(vii) SELECT D.DCODE,NAME,DTITLE
FROM DVD D, MEMBER M WHERE D.DCODE=M.DCODE ;
Ans DCODE NAME DTITLE
R102 AGAM SINGH A day in life
F102 ARTH JOSEPH Universal Soldier
C101 NISHA HANS The Planets
(viii) SELECT DTITLE FROM DVD WHERE DTYPE NOT IN ("Folk", "Classical");
Ans DTITLE
A day in life
Question No.6: (8 Marks)
(a) 2 Marks
2014 Name the law shown below and verify it using a truth table.
X+X’.Y=X+Y
Ans X+X’.Y=X+Y is Absorption Law.
X Y X’ X’.Y X+Y X+X’.Y
0 0 1 0 0 0
0 1 1 1 1 1
1 0 0 0 1 1
1 1 0 0 1 1
Comparing column of X+Y and X+X’.Y, we find that both are
identical. Hence verified.
2015 Verify the following using Boolean Laws.
U’+ V= U’V’+U’.V +U.V
Ans R.H.S
=U’V’+U’.V +U.V
=U’.(V’+ V)+ U.V
=U’.1 + U.V
=U’+ U.V
=U’+ V
=L.H.S
2016 Verify the following using Boolean Laws.
X’+ Y’Z = X’.Y’.Z’+ X’.Y.Z’+ X’Y.Z+ X’.Y’.Z+ X.Y’.Z
Ans RHS
X’.Y’.Z’ + X’.Y.Z’ + X’.Y.Z + X’.Y’.Z + X.Y’.Z
= X’.Y’.Z + X’.Y’.Z’ + X’.Y.Z + X’.Y.Z’ + X.Y’.Z
= X’.Y’.(Z+Z’) + X’.Y.(Z+Z’) + X.Y’.Z
= X’.Y’ + X’.Y + X.Y’.Z
= X’.(Y’+Y) +X.Y’.Z
= X’ + X.Y’.Z
= (X’ + X).(X’ + Y’.Z)
= X’ + Y’.Z
= LHS
2017 State DeMorgan’s Laws of Boolean Algebra and verify them using truth table.
Ans (i) (A.B)'=A'+B'
(ii) (A+B)'=A'.B'
Truth Table Verification:
(i)
A B A.B (A.B)’ A’ B’ A’+B’
0 0 0 1 1 1 1
0 1 0 1 1 0 1
1 0 0 1 0 1 1
1 1 1 0 0 0 0
(ii)
A B A+B (A+B)’ A’ B’ A’.B’
0 0 0 1 1 1 1
0 1 1 0 1 0 0
1 0 1 0 0 1 0
1 1 1 0 0 0 0
(b) 2 Marks
2014 Obtain the Boolean Expression for the logic circuit shown below :
2016 Write the Boolean Expression for the result of the Logic Circuit as shown below:
(C) 1 Marks
2014 Write the Product of Sum form of the function F(X, Y, Z) for the following truth
table representation of F :
X Y Z F(X,Y,Z)
0 0 0 1
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 1
Ans F=(X+Y+Z’)(X+Y’+Z)(X’+Y+Z)(X’+Y+Z’)
OR F(X,Y,Z)= (1,2,4,5)
2015 Derive a Canonical POS expression for a Boolean function F, represented by the
following truth table:
A B C F(P,Q,R)
0 0 0 1
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1
A B C G(A,B,C)
0 0 0 1
0 0 1 0
0 1 0 1
0 1 1 0
1 0 0 0
1 0 1 0
1 1 0 1
1 1 1 1
Ans G(A,B,C) = A’.B’.C’ + A’.B.C’ + A.B.C’ + A.B.C
OR G(A,B,C) = (0,2,6,7)
2017 Derive a Canonical POS expression for a Boolean function G, represented by the
following truth table:
E(U,V,Z,W)=UZ’+V’Z+U’ZW’
Question No.7: (10 Marks)
(a) 1 Mark
2014 Write two characteristics of Wi-Fi.
Ans Wi-Fi is wireless network based on broadcast technology which is used to provide
Network or Internet Access in a home, building or campus wirelessly.
1. It works within 50m to 100m.
2. It is convenient to use and supports secure communication network.
2015 Illustrate the layout for connecting 5 computers in a Bus and a
Star topology of Networks.
Ans
Service ‐
● Better video clarity
● Better security
2017 Ms. Raveena Sen is an IT expert and a freelancer. She recently used her skills to
access the Admin password for the network server of Super Dooper Technology
Ltd. and provided confidential data of the organization to its CEO, informing him
about the vulnerability of their network security. Out of the following options (i)
to (iv), which one most appropriately defines Ms.Sen?
Justify the reason for your chosen option:
(i) Hacker
(ii) Cracker
(iii) Operator
(iv) Network Admin
Ans (i) Hacker
A Hacker is a person who breaks into the network of an organization without any
malicious intent.
(d) 1 Mark / (2 Mark-2017)
2014 Which type of network (out of LAN, PAN and MAN) is formed, when you connect two
mobiles using Bluetooth to transfer a video?
Ans PAN
2015 Out of the following, which is the fastest (i) wired and (ii) wireless medium of
communication?
Infrared, Coaxial Cable, Ethernet Cable, Microwave, Optical Fiber
Ans (i) Wired – Optical Fiber (ii) Wireless ‐ Microwave
2016 Write two characteristics of Web 2.0.
Ans ● Makes web more interactive through online social medias
● Supports easy online information exchange
● Interoperability on the internet
● Video sharing possible in the websites
2017 --
(e) 1 Mark / (2 Mark-2017)
2014 Write names of any two popular Open Source Software, which are used as
Operating Systems.
Ans Linux, Free DOS
2015 What is Trojan Horse?
Ans A Trojan Horse is a code hidden in a program, that looks safe but has hidden side effects
typically causing loss or theft of data, and possible system harm.
2016 What is the basic difference between Computer Worm and Trojan Horse?
2017 --
(f) 1 Mark /(2 Mark)
2014 Write any two important characteristics of Cloud Computing.
Ans (i)On demand access of Software/Applications Services
(ii) Wide range of network access and storage.
2015 Out of the following, which all comes under cyber crime?
(i) Stealing away a brand new hard disk from a showroom.
(ii) Getting in someone's social networking account without his consent and posting
on his behalf.
(iii) Secretly copying data from server of a organization and selling it to the other
organization.
(iv) Looking at online activities of a friends blog.
Ans (ii) & (iii)
2016 Categories the following under Client side and Server Side script category?
1) (1) Java Script (2) ASP
2) (3) VB Sript (4) JSP
Ans Client Side Script : Java Script, VB Script
Server Side Script : ASP, JSP
2017 --
(g) (4 Marks)
2014 Tech Up Corporation (TUC) is a professional consultancy company. The company is
planning to set up their new offices in India with its hub at Hyderabad.
As a network adviser, you have to understand their requirement and suggest to
them the best available solutions. Their queries are mentioned as (i) to (iv) below.
Block to Block Distance: (Mtrs) Number of Computers to be installed
Human Resource to Conference 60 Human Resource 125
Human Resource to Finance 120 Finance 25
Conference to Finance 80 Conference 60
(i) What will most appropriate block, where TUC should plan to install their server ?
Ans Human Resources Block
(ii) Draw a block to block cable layout to connect all the buildings in the most
appropriate manner for efficient communication.
Ans
(iii) What will be the best possible connectivity out of the following, you will suggest to
connect the new setup of offices in Bangalore with its London based office ?
Infrared
Satellite Link
Ethernet Cable
Ans Satellite Link
(iv) Which of the following devices will be suggested by you to connect each computer
in each of the buildings?
Gateway
Switch
Modem
Ans Switch
2015 Xcelencia Edu Services Ltd. is an educational organization. It is planning to set up
its India campus at Hyderabad with its head office at Delhi. The Hyderabad campus
has 4 main buildings ‐ ADMIN, SCIENCE, BUSINESS and MEDIA.
You as a network expert have to suggest the best network related solutions for
their problems raised in (i) to (iv), keeping in mind the distances between the
buildings and other given parameters.
Shortest distances between various locations: Number of Computers installed
ADMIN to SCIENCE 65 M ADMIN 100
ADMIN to BUSINESS 100M SCIENCE 85
ADMIN to ARTS 60M BUSINESS 40
SCIENCE to BUSINESS 75M ARTS 12
SCIENCE to ARTS 60M DELHI HEAD OFFICE 20
BUSINESS to ARTS 50M
DELHI Head Office to 1600KM
HYDERABAD Campus
(i) Suggest the most appropriate location of the server inside the HYDERABAD campus
(out of the 4 buildings), to get the best connectivity for maximum no. of
computers. Justify your answer.
Ans ADMIN (due to maximum number of computers)
OR
ARTS (due to shorter distance from the other buildings)
(ii) Suggest and draw the cable layout to efficiently connect various buildings 'within
the HYDERABAD campus for connecting the computers.
Ans
(iii) Which hardware device will you suggest to be procured by the company to be
installed to protect and control the Internet uses within the campus?
Ans Firewall OR Router
(iv) Which of the following will you suggest to establish the online face‐to‐face
communication between the people in the Admin Office of HYDERABAD campus and
DELHI Head Office?
(a) E‐mail (b) Text Chat (c) Video Conferencing (d) Cable TV
Ans Video Conferencing
2016 Intelligent Hub India is a knowledge community aimed to uplift the standard of skills
and knowledge in the society. It is planning to setup its training centers in multiple
towns and villages pan India with its head offices in the nearest cities. They have
created a model of their network with a city, a town and 3 villages as follows.
As a network consultant, you have to suggest the best network related solutions for
their issues/problems raised in (i) to (iv), keeping in mind the distances between
various locations and other given parameters.
Shortest distances between various locations: Number of Computers installed
VILLAGE 1 to YTOWN 2 KM YTOWN 100
VILLAGE 2 to YTOWN 1.5 KM VILLAGE 1 10
VILLAGE 3 to YTOWN 3 KM VILLAGE 2 15
VILLAGE 1 to VILLAGE 2 3.5 KM VILLAGE 3 15
VILLAGE 1 to VILLAGE 3 4.5 KM CITY OFFICE 5
VILLAGE 2 to VILLAGE 3 3.5 KM
CITY Head Office to YHUB 30 Km
Note: In Villages, there are community centers, in which one room has been given as
training center to this organization to install computers.
The organization has got financial support from the government and top IT
companies.
(i) Suggest the most appropriate location of the SERVER in the YHUB (out of the 4
locations), to get the best and effective connectivity. Justify your answer.
Ans Best location of the server is YTOWN . Justification:
● Since it has the maximum number of computers.
● It is closest to all other locations.
(ii) Suggest the best wired medium and draw the cable layout (location to location) to
efficiently connect various locations within the YHUB.
Ans Optical Fiber
(iii) Which hardware device will you suggest to connect all the computers within each location
of YHUB?
Ans Switch OR Hub
(iv) Which service/protocol will be most helpful to conduct live interactions of Experts from
Head Office and people at YHUB locations?
Ans Videoconferencing OR VoIP OR any other correct service/protocol
2017 Hi Standard Tech Training Ltd is a Mumbai based organization which is expanding
its office set-up to Chennai. At Chennai office compound, they are planning to
have 3 different blocks for Admin, Training and Accounts related activities. Each
block has a number of computers, which are required to be connected in a
network for communication, data and resource sharing.
As a network consultant, you have to suggest the best network related solutions
for them for issues/problems raised by them in (i) to (iv), as per the distances
between various blocks/locations and other given parameters.
(i) Suggest the most appropriate block/location to house the SERVER in the CHENNAI
Office (out of the 3 blocks) to get the best and effective connectivity. Justify
your answer.
Ans Training Block - Because it has maximum number of computers.
(ii) Suggest the best wired medium and draw the cable layout (Block to Block) to
efficiently connect various blocks within the CHENNAI office compound.
Ans Best wired medium: Optical Fibre OR CAT5 OR CAT6 OR CAT7 OR CAT8 OR Ethernet
Cable
(iii) Suggest a device/software and its placement that would provide data security for
the entire network of the CHENNAI office.
Ans Firewall - Placed with the server at the Training Block OR
Any other valid device/software name
(iv) Suggest a device and the protocol that shall be needed to provide wireless
Internet access to all smartphone/laptop users in the CHENNAI office
Ans Device Name: WiFi Router OR WiMax OR RF Router OR Wireless Modem OR RF
Transmitter
Protocol : WAP OR 802.16 OR TCP/IP OR VOIP OR MACP OR 802.11