Expected Answers
Expected Answers
(a)
Give the difference between the type casting and automatic type conversion.
Also, give a suitable C++ code to illustrate both.
Ans
Type Casting
Example:
float f=7.9;
int c=(int)f;
Cout<<c;
Example:
Char x=' A' ;
Int c=x;
Cout<<c;
Output:
Output
65
387
void main ( )
{
char TEXT [ ] = "Something";
cout << Remaining SMS Chars : <<160-atrlen (TEXT) << endl.;
}
Ans iostream.h/iomanip.h
string.h
( Mark for writing each correct header file)
Note: Marks should not be deducted for mentioning extra header files
in addition to the ones mentioned above
(c)
Rewrite the following program after removing the syntactical errors (if any).
Underline each correction.
#include <iostream.h>
Class 1tem
{
388
// C Capital
{
long IId,Qty;
public:
void Purchase ( ){cin>>IId>>Qty;}
Either the statement is removed
or header file included as
#include<iomanip.h>
void Sale ( )
{
389
}
} ;
void main ( )
{
Item I;
I.Purchase( );// Object missing
I. Sale ( ) ;
I. Sale ( ) ;
// ; is missing
}
( Mark for each of any four corrections out of five corrections shown
above)
OR
(1 Mark for only identifying any four errors)
Note: Marks should not be deducted for mentioning any other error/
correction
(d)
{
METRO M(5), T;
M. Trip () ;
M. StatusShow() ;
T. StatusShow() ;
M. Status Show () ;
}
Ans (Full 3 Marks)
(2 Marks)
(2 Marks)
5:1:20
5 1 20
1:1:50
1 1 50
5:2:50
5 2 50
391
Notes=Str;
while (L>=3)
{
Str[L]=(isupper(Str[L])?tolower(Str[L]):
toupper(Str[L]));
cout<<Notes<<endl;
L--;
Notes++;
}
}
Ans Full 2 Marks
1 Marks
(1 Marks)
(1 Marks)
vR2Good
vR2Good
vR2GooD
R2GoOd
vR2GoOd
R2GooD
2GOOd
vR2GOOd
2GooD
gOOd
vR2g00d
GooD
Observe the following program and find out, which output(s} out if (i) to
(iv) will not be expected from the program? What will be the minimum and the
maximum value assigned to the variable Chance?
#include <iostream.h>
#include <stdlib.h>
void main ( )
{
randomize( ) ;
int Arr[]={9,6}, N;
int Chanoe=random(2) + 10 ;
392
9#6#
(ii)
19#17#
(iii)
19#16#
(iv)
20#16#
Ans The outputs not expected from the program are (i), (ii) and (iv)
Minimum Value of Chance = 10
MaximumValue of Chance = 11
(1 Mark for writing correct option for output NOT expected)
( Mark for writing correct Minimum Value of Chance)
( Mark for writing correct Maximum Value of Chance)
2
(a)
What is the difference between the members in private visibility mode and the
members in protected visibility mode inside a class? Also, give a suitable C++
code to illustrate both.
Ans Option 1
Private Visibility
Protected Visibility
derived class
393
Example:
#include <iostream.h> #include<stdio.h>
const int Max=20;
class Hospital
Members in Private Visibility Mode, accessible
only to the member functions of same class
{
int Pno;
protected:
public:
void Register () {cinPno; gets (Name) ;}
void ShowStatus () {cout<<Pno<<N&me<<WardnO<<endl ; }
} ;
Option 2:
Members are private by default inside a class
Protected visibility must be specified for a member to be declared as protected
Option 3:
No difference in accessibility of the members of the two visibility modes inside a
class without inheritance
For Option 1:
(1 Mark for correct explanation)
OR
For Option 2 and 3:
(Full 2 Marks for writing any answer conveying same meaning)
OR
(Full 2 Marks for correct explanation OR example illustrating
accessibility of Protected Member(s) inside derived class member
function(s))
394
(b)
Answer the questions (i) and (ii) after going through the following class
class Travel
{
int PlaceCode; char Place[20] ; float Charges;
public:
Travel ()
//Function 1
{
PlaceCode=l;strcpy (Place, "DELHJ:") ; Charges = 1000;
}
void TravelPlan (float C)
//Function 2
{
cout<<PlaceCode<<":"<<Place":"<<Charges<<endl;
}
~Travel ( )
//Function 3
{
Cout<<"Travel Plan Cancelled"<<endl;
}
Travel (int PC, char P[], float C)
//Function 4
{
PlaceCode=PC;strcpy(Place,P); Charges=C;
}
};
(i)
Ans (i)
395
Constructor Overloading
OR
Overloaded Constructor
OR
Function Overloading
OR
Overloaded Functions
OR
Default Constructor and Parameterized Constructor
(1 Mark for writing the feature name correctly)
Note:
( mark for writing only "constructor(s)")
(ii)
Ans. (ii)
396
FType
Sticker
Vegetarian
GREEN
Contains Egg
YELLOW
Non-Vegetarian
RED
Public Members
z
A function ShowFood() to allow user to view the content of all the data
members.
}
void RESTRA::GetFood()
{
cin>>FoodCode;
gets (Food);
gets (FType) ;
GetSticker () ;
}
void RESTRA::ShowFood ()
{
cout<<FoodCode<<":"<<Food<<FType<<":"<<Sticker<<endl;
}
( Mark for correct syntax for class header)
(Mark for correct declaration of data members)
(1 Mark for correct definition of GetSticker())
(1 Mark for correct definition of GetFood() with proper invocation of
GetSticker() function)
(1 Mark for correct definition of ShowFood())
NOTE:
(d)
399
SHOP () ;
void Input( ) ;
void Output ( ) ;
} ;
(i)
Write the name of data members, which are accessible from member
functions of class SHOP.
Write the names of all the member functions, which are accessible from
objects belonging to class FACTORY.
Write the names of all the members, which are accessible from objects
of class SHOP
400
(a)
Write a function SWAP2BEST (int ARR[], int Size) in C++ to modify the
content of the array in such a way that the elements, which are multiples of 10
swap with the value present in the very next position in the array.
For example:
If the content of array ARR is
90, 56, 45, 20, 34, 54
The content of array ARR should become
56, 90, 45, 34, 20, 54
}
}
}
401
An array T[20][10] is stored in the memory along the column with each of the
elements occupying 2 bytes. Find out the memory location of T[10][5], if the
element T[2][9] is stored at the location 7600.
1 Mark to be awarded for writing only the correct answer (i.e. 7456)
403
(c)
//Book Title
};
Ans const int Max = 10;
void insert(Book B[], int &a, int F)
{
if ( (R+l) %Max! =F)
{
R= (R+l) %Max;
cin>>B [R] . Accno;
//cin>>B[R].Title OR cin.getline(B[R] .Title,20); OR
gets(B[R].Title) ;
}
else
cout<<"Queue Full";
}
OR
const intmax =10;
404
void insert( long newAC, char newTitle[], Book B [],int &F,int &R)
{
if ( (F = 0 && R=max-l) II (F=R+l))
cout<<"Queue Overflow";
else
{
if (R -1)
F=0; R=0;
else if (R = max-i)
R = 0;
else
R = R + 1;
B[R].Accno = newAC;//oR cin>>B[R].Accno;
strcpy(B[R].Title, newTitle);
// OR gets(B[R].Title); OR cin>>B[R].Title OR
//cin.getline(B[R].Title,20) ;
}
}
OR
Any other equivalent correct answer acceptable
(1 Mark for writing function header correctly)
(1 Mark for checking if Queue is Full)
(1 Mark for incrementing Rear)
(1 Mark for assigning Values to the Rear location of the Queue)
(d)
405
For example:
If the array is containing:
23
54
76
37
19
28
62
13
19
76
19
62
19
OR
Any other equivalent correct answer acceptable
(1 Mark for writing Correct loops starting for location [0] [0])
( Mark for logic of checking alternate elements)
( Mark for displaying the alternate elements)
(e)
Evaluate the following POSTFIX notation. Show status of Stack after every
step of evaluation (i.e. after each operator):
Stack Status
True
True
False
True, False
NOT
True, True
AND
True
False
True, False
True
OR
True, True
AND
True
(a)
Observe the program segment given below carefully and the questions that follow:
class Stock
407
{
int Ino, Qty ; char Item [20];
public:
void Enter() {cin>>Ino;qets(Item) ; cin>>Qty;}
void issue(int Q){Qty+=O;}
void Purchase(int Q){Q-=Q;}
int GetIno () {return Ino;}
};
void PurchaseItem(int Pino,int PQty)
{
fstream File;
File.open("STOCK.DAT", ios::binary|ios: :in|ios: :out);
Stock S;
int Success=O;
while (Success==O && File.read((char*)&S,sizeof(S)))
{
if (Pino==S. GetIno())
{
S.PurchaSe(PQ)
_________________
// Statement 1
_________________
// Statement 2
Success++;
}
}
}
if (Success=l)
408
Cout<<"Purchase Updated"<<endl;
else
Cout<<''Wronq Item No"<<endl;
File.close() ;
(i)
Write statement 1 to position the file pointer to the appropriate place so that
the data ucdation is done for the reauired item.
Write statement 2 to perform the write operation so that the updation is done
in the binary file.
Ans File.write((char*)&S,sizeof(S));
OR
File.write((char*)&S,sizeof(Stock));
( Mark for writing any of the above statements)
(b)
Write a function in C++ to read the content of a text file "DELHI.TXT' and
display all those lines on screen, which are either starting with 'D' or starting
with 'M'
409
{
if(Str[0]='D' || Str[0]='M')
coutStrendl;
}
File.close(); //Ignore
}
OR
Any other correct function definition performing the desired operation
( Mark for opening DELHI. TXT correctly)
( Mark for reading each Line (Whichever method adopted) from the file)
( Mark for checking lines starting with '0' or 'M' )
( Mark for displaying the lines)
NOTE:
Ignore case sensitivity while checking for 'D' or 'M'
(c)
Write a function in C++ to search for the details (Phone no and Calls) of
those Phones, which have more than 800 calls from a binary file "phones.dat"
Assuming that this binary file contains records/objects of class Phone, which
is defined below.
class Phone
{
char Phoneno [10] ; int Calls ;
public:
void Get 0 {gets (Phoneno) ; cin>>ea11s;)
void Bi11ing() {cout<<Phoneno<<"#"<<Ca11send1:}
int GetCa11s () {return Ca11s;}
} ;
Phone P;
Ignore
fstream fin;
fin. open ("phones. dat", ios: :binary| ios: :in);
whi1e (fin.read((char*) &P, sizeof (P)))
{
if(P.GetCa11s () > 800)
P.Billing () ;
}
fin.c1ose () ; // Ignore
}
OR
Any other correct function definition performing the desired operation
( Mark for declaration of object using fstream/ifstream)
( Mark for opening phones.dat correctly)
( Mark for reading record(s) from phones.dat)
( Mark for correct formation of/oop)
( Mark for checking if value returned by GetCalls ( ) > 800)
( Mark for displaying the matching record)
Note:
Marks not to be deducted for the comparison as >= 800
5
(a)
Give a suitable example of a table with sample data and illustrate Primary and
Alternate Keys in it.
Ans A table may have more than one such attribute/group of attribute that Identifies
a row/tuple uniquely, all such attribute(s} are known as Candidate Keys. Out
of the Candidate keys, one is selected as Primary Key. while the rest are the
Alternate Keys
411
CarName Make
Color
Capacity
Charges
501
A-Star
Suzuki
RED
14
503
Indigo
Tata
SILVER
12
502
Innova
Tovota
WHITE
15
509
SX4
Suzuki
SILVER
14
510
C Class
Mercedes
RED
35
Table: CUSTOMER
CCode
Cname
Ccode
1001
Hemant Sahu
501
1002
Raj Lal
509
1003
Feroza Shah
503
1004
Ketan Dhal
502
412
(b)
To display the customer name and the corresponding name of the cars hired
by them.
413
MIN (Charges)
35
12
Make
SUZUKJ:
TATA
TOYOTA
MERCEDES
414
OR
No Output
OR
Incorrect Syntax/Error/Query will not run
( Mark for writing any of the above or any answer conveying same meaning)
OR
( Mark to be awarded if any two outputs out of (i), (jj) and (iv) are correct.
(iv)
Ans CarName
Sx4
C Class
( Mark for correct output)
(a)
X,X' = 0
Ans X
X'
X . X'
6.
Verified
(1 Mark for correct verification)
OR
( Mark for any two correct columns)
(ii)
X+1=1
X
X +1
2
Verified
415
Write the equivalent Boolean expression for the following Logic Circuit:
(0, 2, 4, 7)
(d)
Ans
A'B'
C'D'
C'D
AB
AB'
1
CD
CD'
C'D'
C'D
OR
A'B'
A'B
CD
CD'
AB
AB'
(a)
What out of the following, will you use to have an audio-visual chat with an
expert sitting in a far-away place to fix-up a technical issue?
(i)
VolP
(ii)
(iii)
FTP
Ans (ii)
VolP
OR
None of the Options
(1 Mark for writing correct option)
417
(b)
Name one server side scripting language and one client side scripting language.
Ans Client side scripts: Java script / VB script / Peril Tcl/Tk / REXX.
Server side scripts: JSP / ASP / PHP / CGI / Perl
( Mark for writing one correct Client side scripting language name)
( Mark for writing one correct Server side scripting language name)
(c)
(ii)
(iii)
Ans (i)
(d)
Write one advantage of Bus Topology of network. Also, illustrate how 4 computers can be connected with each other using star topology of network.
Ans Cable length required for this topology is the least compared to other networks.
OR
Any other correct advantage of Bus Topology of network.
Illustration of 4 computers connected with each other using star topology of network.
418
(e)
Workalot Consultants are setting up a secured network for their office campus
at Gurgaon for their day-to-day office and web-based activities. They are
planning to have connectivity between 3 buildings and the head office situated
in Mumbai Answer the questions (i) to (iv) after going through the building
positions in the campus and other details, which are given below:
(i)
Suggest the most suitable place (Le. building) to house the server of
this organization. Also give a reason to justify your location.
419
OR
Gurgaon Campus
Switch
(2)
Repeater
420
Ans (1)
Switch:
In each of the buildings, since a network switch is a networking device
that joins multiple computers together within one local area network
(LAN).
(2)
Repeater:
For the Layout 1 drawn in (e2)- Between buildings "GREEN" and
"RED", since distance between these two buildings is greater than 70
m which will otherwise lead to loss of signal intensity for data to be
transferred.
For the Layout 2 drawn in (e2): Repeater is not needed, since distance
between both the buildings connected to "Ganga" is less than 70 m, not
leading to any signal loss
OR
Any other placement of Repeater with proper justification
Ans (i)
The organization is planning to provide a high speed link with its head
office situated in the MUMBAI 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
Optical Fibre
http://www.w3schools. com/htmlldefault.asp
OR
www.youtube.com
421
422