SlideShare a Scribd company logo
XII CBSE
Previous Year
Question Paper
QUESTION NO
2 (c)
4 Marks
(c) Define a class named ADMISSION in C++ with the
following descriptions :
Delhi 2006 4
Private members :
AD_NO integer (Ranges 10 - 2000)
NAME Array of characters(String)
CLASS Character
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.
(c) class ADMISSION
{
int AD_NO;
char NAME[20]; //or any constant size
char CLASS;
float FEES;
public:
void Read_Data()
{
do
{
cin>>AD_NO;
}while (AD_NO<10 || AD_NO>2000);
gets(NAME);
cin>>CLASS;
cin>>FEES;
}
void Display()
{
cout<<AD_NO;
cout<<NAME;
cout<<CLASS;
cout<<FEES;
}
void Draw_Nos();
};
(1 mark for proper syntax of class definition
with correct class name and a semicolon to
end the class definition)
(1 mark for proper declaration of private
members)
(1 mark for proper definition of Read_Data())
(1 mark for proper definition of Display())
Note: No marks should be deducted for
Not checking the range for AD_NO Not
declaring or defining Draw_Nos(). (Mentioned
as Draw- Nos() in the question paper)
(c) Define a class named HOUSING in C++
with the following descriptions :
Outside Delhi 2006 4
Private members
REG_NO integer(Ranges 10 - 1000)
NAME Array of characters(String)
TYPE Character
COST Float
(c) Define a class named HOUSING in C++
with the following descriptions :
Outside Delhi 2006 4
Public Members
• Function Read_Data() to read an object of
HOUSING type
• Function Display() to display the details of an
object
• Function Draw_Nos()to choose and display
the details of 2 houses selected randomly
from an array of 10 objects of type HOUSING.
Use
random function to generate the registration
(c)
class HOUSING
{
int REG_NO;
char NAME[20];
char TYPE;
float COST;
public:
void Read_Data();
void Display();
void Draw_Nos(HOUSING S);
};
(c)
void HOUSING::Read_Data()
{
cin>>REG_NO; //Validation not required
cin>>NAME; //OR gets(NAME);
cin>>TYPE; cin>>COST;
}
void HOUSING::Display()
{
cout<<REG_NO<<NAME<<TYPE<<COST<<
endl;
}
(c)
void HOUSING::Draw_Nos();//Ignore
(1/2 mark for proper syntax of class
definition with correct class name and a
semicolon to end the class definition)
(1/2 mark for mentioning the proper
visibility modes (private / public))
(1 mark for proper declaration of private
data members)
(1 mark for proper definition of Read_Data() with
user entry for data members OR declaring a local
object and entering the values of data members of
this object )
(1 mark for proper definition of Display())
Note: As language of Third part of this question
has ambiguity, it is required to be ignored.
Moreover, if anyone has partially attempted the
third part (i.e., Draw_nos function) and not
attempted/not correctly
attempted Read/Display function, he/she should
be given 2 Marks for Third part taking into
consideration the marks for this question should
not exceed the max. marks allocated (i.e. 4 marks)
to this question 2 (c).
(c) Define a class Travel in C++ with the
description given below :
Delhi 2007 4
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
(c) Define a class Travel in C++ with the
description given below :
Delhi 2007 4
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
(c) Define a class Travel in C++ with the
description given below :
Delhi 2007 4
• 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
(c) Define a class Travel in C++ with the
description given below :
Delhi 2007 4
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
(c) Define a class Travel in C++ with the
description given below :
Delhi 2007 4
• 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.
(c) class Travel
{
char TCode[5]; //OR char *Tcode;
int No_of_Adults;
int No_of_Children;
int Distance;
float TotalFare;
public:
Travel();
void AssignFare();
void EnterTravel();
void ShowTravel();
};
Travel::Travel()
{
strcpy(TCode,”NULL”);// OR TCode[0]=’0’ OR
strcpy(TCode,”0”)
// OR TCode=NULL if TCode is declared as
char pointer
No_of_Adults = 0;
No_of_Children = 0;
Distance = 0;
TotalFare = 0;
}
void Travel::AssignFare()
{
if(Distance>=1000)
TotalFare =
500*No_of_Adults+250*No_of_Children;
else
if (Distance >= 500)
TotalFare =
300*No_of_Adults+150*No_of_Children;
else
TotalFare =
200*No_of_Adults+100*No_of_Children;
}
void Travel::EnterTravel()
{
gets(TCode); // or cin >> TCode;
cin>>No_of_Adults>>No_of_Children>>Dista
nce;
AssignFare();
}
void Travel::ShowTravel()
{
cout<<TCode<<No_of_Adults<<No_of_Childr
en
<<Distance<<TotalFare<<endl;
}
(½ Mark for correct syntax of class header)
(½ Mark for correct declaration of data
members)
(1 Mark for correct definition of
constructor)
(1 Mark for checking all three conditions
and calculating TotalFare in AssignFare( ))
(½ Mark for correct EnterTravel( ) with
proper invocation of AssignFare( ))
(½ Mark for displaying all data Members
including TotalFare inside ShowTravel( ))
(c) Define a class Tour in C++ with the
description given below :
Outside Delhi 2007 4
Private Members :
TCode of type string
NoofAdults of type integer
NoofKids of type integer
Kilometres of type integer
TotalFare of type float
(c) Define a class Tour in C++ with the
description given below :
Outside Delhi 2007 4
Public Members :
• A constructor to assign initial values as
follows :
TCode with the word “NULL”
NoofAdults as 0
NoofKids as 0
Kilometres as 0
TotalFare as 0
(c) Define a class Tour in C++ with the
description given below :
Outside Delhi 2007 4
• A function AssignFare ( ) which calculates
and assigns the value of
the data member TotalFare as follows
For each Adult
Fare(Rs) For Kilometres
500 >=1000
300 <1000&>=500
200 <500
(c) Define a class Tour in C++ with the
description given below :
Outside Delhi 2007 4
For each Kid the above Fare will be 50% of
the Fare mentioned in the
above table
For example :
If Kilometres is 850, NoofAdults = 2 and
NoofKids = 3
Then TotalFare should be calculated as
NumofAdults * 300 + NoofKids * 150
i.e. 2*300 + 3*150=1050
(c) Define a class Tour in C++ with the
description given below :
Outside Delhi 2007 4
• A function EnterTour( ) to input the values of
the data members
TCode, NoofAdults, NoofKids and Kilometres;
and invoke the
Assign Fare( ) function.
• A function ShowTour( ) which displays the
content of all the data
members for a Tour.
(c) class Tour
{
char TCode[10]; //OR char *Tcode;
int NoofAdults;
int NoofKids;
int Kilometres;
float TotalFare;
public:
Tour()
{
strcpy(TCode,”NULL”); //OR TCode[0]=’0’OR
strcpy(TCode,”0”)
//OR TCode=NULL if TCode is declared as
char pointer
NoofAdults = 0;
NoofKids = 0;
Kilometres = 0;
TotalFare = 0;
}
void AssignFare();
void EnterTour();
void ShowTour();
};
void Tour::AssignFare()
{
if(Kilometres>=1000)
TotalFare = 500*NoofAdults+250*NoofKids;
else if (Kilometres >= 500)
TotalFare = 300*NoofAdults+150*NoofKids;
else
TotalFare = 200*NoofAdults+100*NoofKids;
}
void Tour::EnterTour()
{
gets(TCode); // or cin >> TCode;
cin>>NoofAdults>>NoofKids>>Kilometres;
AssignFare( );
}
void Tour::ShowTour()
{
cout<<TCode<<NoofAdults<<NoofKids<<Kilo
metres<<TotalFare<<endl;
}
(½ Mark for correct syntax for class header)
(½ Mark for correct declaration of data
members)
(1 Mark for correct definition of constructor)
(½ Mark for condition checking in
AssigFare())
(½ Mark for calculation of correct TotalFare
for each condition)
(½ Mark for correct EnterTour() with proper
invocation of AssignFare())
(½ Mark for displaying all data Members
including TotalFare inside ShowTour())
(c) Define a class Garments in C++ with the
following descriptions:
Delhi 2008 4
Private Members:
GCode of type string
GType of type string
GSize of type integer
GFabric of type string
GPrice of type float
A function Assign ( ) which calculates and
assigns the value of GPrice as follows
(c) Define a class Garments in C++ with the
following descriptions:
Delhi 2008 4
For the value of GFabric as “COTTON”,
GType GPrice(Rs)
TROUSER 1300
SHIRT 1100
For GFabric other than “COTTON” the above
mentioned GPrice gets reduced by 10%.
(c) Define a class Garments in C++ with the
following descriptions:
Delhi 2008 4
Public Members:
A constructor to assign initial values of GCode,
GType and GFabric with the word “NOT
ALLOTTED” and GSize and GPrice with 0
A function Input ( ) to input the values of the
data members GCode,
GType, GSize and GFabric and invoke the
Assign ( ) function.
A function Display ( ) which displays the
content of all the data members for a Garment.
Ans:
class Garments
{
char GCode[10];
char GType[10];
int GSize;
char GFabric[10] ;
float GPrice;
void Assign( ) ;
public:
Garments( )
{
strcpy(GCode,”NOT ALLOTTED”) ;
strcpy(GType,”NOT ALLOTTED”) ;
strcpy (GFabric, “NOT ALLOTTED”) ;
GSize=0;
GPrice=0;
}
void Input( ) ;
void Display( ) ;
} ;
void Garments::Assign( )
{
if (strcmp(GFabric,“COTTON”)==0)
//if (!strcmp(GFabric, “COTTON”))
{
if (strcmp(GType,“TROUSER”) ==0)
GPrice=1300;
else if (strcmp(GType,“SHIRT”)==0)
GPrice=1100;
}
else
{
if (strcmp(GType,”TROUSER”) = =0)
GPrice=1300*0.9; // 10% reduction
else if (strcmp(GType,“SHIRT”)= =0)
GPrice=1100*0.9; // 10% reduction
}
}
void Garments::Input( )
{
gets(GCode) ; // or cin >> GCode;
gets(GType) ; // or cin >> GType;
cin>>Gsize;
gets(GFabric) ;// or cin >> GFabric;
Assign( ) ;
}
void Garments::Display( )
{
cout<<GCode<<GType<<GSize<<GFabric<<G
Price<<endl;
}
(½ Mark for correct syntax for class header)
(½ Mark for correct declaration of data
members)
(½ Mark for correct definition of
constructor)
(1 Mark for correct definition of Assign( ))
(1 Mark for correct definition of Input( ) with
proper invocation of Assign( ) function)
(½ Mark for correct definition of Display( ))
NOTE:
Deduct % Mark if Assign( ) is not invoked
properly inside Input( ) function
(c) Define a class Clothing in C++ with the
following descriptions:
Outside Delhi 2008 4
Private Members:
Code of type string
Type of type string
Size of type integer
Material of type string
Price of type float
A function Calc_Price( ) which calculates and
assigns the value of Price as follows:
(c) Define a class Clothing in C++ with the
following descriptions:
Outside Delhi 2008 4
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%.
(c) Define a class Clothing in C++ with the
following descriptions:
Outside Delhi 2008 4
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
Ans: class Clothing
{
char Code[25];
char Type[25];
int Size;
char Material[30];
float Price;
Public:
Clothing() ;
void Calc_Price() ;
void Enter() ;
void Show() ;
};
Clothing::Clothing()
{
strcpy(Code,”NOT ASSIGNED”);
strcpy(Type,”NOT ASSIGNED”);
Size=0;
strcpy (Material, “NOT ASSIGNED”);
Price=0;
}
void Clothing:: Calc_Price()
{
if (strcmp(Type, “TROUSER”) ==0 && strcmp
(Material,“COTTON”)==0)
Price=1500;
else if (strcmp(Type, “SHIRT”) ==0 &&
strcmp(Material,”COTTON”)==O)
Price=1200;
else if (strcmp(Type, “TROUSER”) ==0 &&
strcmp(Material,”COTTON”)!=O)
Price=1500*0.75;
void Clothing:: Calc_Price()
{
if (strcmp(Type, “TROUSER”) ==0 && strcmp
(Material,“COTTON”)==0)
Price=1500;
else if (strcmp(Type, “SHIRT”) ==0 &&
strcmp(Material,”COTTON”)==O)
Price=1200;
else if (strcmp(Type, “TROUSER”) ==0 &&
strcmp(Material,”COTTON”)!=O)
Price=1500*0.75;
else if (strcmp(Type,”SHIRT”)==0) &&
strcmp(Material,”COTTON”)!= 0)
Price=1200*0.75;
}
void Clothing::Enter()
{
gets(Code) ; // or cin >> Code;
gets(Type) ; // or cin >> Type;
cin>>Size;
gets(Material) ;// or cin >> Material;
Calc_Price() ;
}
void Clothing::Show()
{
cout<<Code<<Type<<Size<<Material<<Price<
<endl;
}
(½ Mark for correct syntax for class header)
(½ Mark for correct declaration of data
members)
(½ Mark for correct definition of function
Calc_price())
(½ Mark for constructor)
(1 Mark for calculation of correct Price for each
condition)
(½ Mark for correct Enter() with proper
invocation of Calc_Price())
(½ Mark for displaying all data Members in
function Show())
(c) Define a class RESORT in C++ with
following description:
Delhi 2009 4
Private Members
Rno //Data member to store Room No
Name //Data member to store customer name
Charges //Data member to store per day
charges
Days //Data member to store number of days
of stay
COMPUTE( ) //A function to calculate’ and
return Amount as
(c) Define a class RESORT in C++ with
following description:
Delhi 2009 4
Days*Charges and if the value of
Days*Charges is more than 11000
then as 1.02*Days*Charges
Public Members
Getinfo ( ) //A function to enter the content
Rno, Name, Charges and Days
Dispinfo ( ) //A function to display Rno, Name,
Charges,Days and Amount (Amount to be
displayed by calling function COMPUTE ( ) )
Ans class RESORT
{
int Rno;
char Name [20];
float Charges;
int Days;
float COMPUTE();
public:
void Getinfo() ;
void Dispinfo();
};
void RESORT::Getinfo()
{
cin>>Rno;
gets (Name);
cin>>Charges;
cin>>Days;
}
void RESORT::Dispinfo()
{
cout<<Rno<<” “<<Name<<“ “<<Charges<<”
“<<Days<<
COMPUTE()<<endl;
}
float RESORT::COMPUTE()
{
float Amount = Charges*Days;
if (Amount>11000)
Amount = 1.02*Days*Charges;
return Amount;
}
(½ Mark for correct syntax for class header)
(½ Mark for correct declaration of data
members)
(1 Mark for correct definition of COMPUTE ( )) .
(1 Mark for correct definition of Dispinfo( ) with
proper invocation of COMPUTEO function)
(1 Mark for correct definition of Getinfo( ))
NOTE: Deduct ½ Mark if COMPUTE( ) is not
invoked properly inside Dispinfo( ) function
(c) Define a class HOTEL in C++ with the
following description:
Outside Delhi 2009 4
Private Members:
Rno //Data member to store Room No
Name //Data member to store customer name
Tariff //Data member to store per day charges
NOD //Data member to store number of days of
stay
CALC( ) //A function to calculate and return
Amount as NOD*Tariff and if the value of
NOD*Tariff is more than 10000 then as
1.05*NOD*Tariff
(c) Define a class HOTEL in C++ with the
following description:
Outside Delhi 2009 4
Public Members
Checkin ( ) / / A function to enter the content
Rno, Name, Tariff and NOD
Checkout( ) / / A function to display Rno,
Name, Tariff,NOD and Amount (Amount to be
displayed by calling function CALC( ))
Ans class HOTEL
{
int Rno;
char Name[20];
float Tariff;
int NOD;
float CALC() ;
public:
void Checkin() ;
void Checkout() ;
} ;
float HOTEL::CALC()
{
float Amount = Tariff*NOD;
if (Amount>10000)
Amount = 1.05*NOD*Tariff;
return Amount;
}
void HOTEL::Checkin()
{
cin>>Rno;
gets (Name);
cin>>Tariff;
cin>>NOD; }
void HOTEL::Checkout()
{
cout<<Rno<<” “<<Name<<“ “<<Tariff<<”
“<<NOD<<
CALC ()<<endl;
}
(½ Mark for correct syntax for class header)
(½ Mark for correct declaration of data
members)
(1 Mark for correct definition of CALC( ))
(1 Mark for correct definition of Checkout( )
with proper invocation of CALC( ) function)
(1 Mark for correct definition of Checkin())
NOTE: Deduct ½ Mark if CALC() is not
invoked properly inside Checkout( )
function
(c) Define a class ITEM in C++ with following
description:
Delhi 2010 4
Private Members
Code of type integer (Item Code)
Iname of type string (Item Name)
Price of type float (Price of each item)
Qty of type integer (Quantity of item in stock)
Offer of type float (Offer percentage on the
item)
(c) Define a class ITEM in C++ with following
description:
Delhi 2010 4
A member function GetOffer() to calculate
Offer percentage as per the
following rule:
If Qty<=50 Offer is 0
If 50<Qty<=100 Offer is 5
If Qty>100 Offer is 10
(c) Define a class ITEM in C++ with following
description:
Delhi 2010 4
Public Members
A function GetStock() to allow user to enter
values for Code, Iname,
Price, Qty and call function GetOffer() to
calculate the offer
A function ShowItem() to allow user to view
the content of all the data
members
Ans. class ITEM
{
int Code;
char Iname [20] ;
float Price;
int Qty;
float Offer;
void GetOffer() ;
public:
void GetStock ()
{
cin>>Code;
gets (Iname) ; // OR cin.getline (Iname, 80) ;
OR cin>>Iname;
cin>>Price>>Qty;
GetOffer() ;
}
void ShowItern ( )
{
cout<<Code<<Iname<<Price<<Qty<<Offer;
};
void ITEM: : GetOffer ()
{
if (Qty<=50)
Offer = 0;
else if (Qty <=100)
Offer = 5; / /OR Offer = 0.05;
else
Offer = 10; / /OR Offer = 0.1;
}
(½ Mark for correct syntax for class header)
(½ Mark for correct declaration of data
members)
(1 Mark for correct definition of GetOffer())
(1 Mark for correct definition of GetStock () with
proper invocation of GetOffer()
function)
(1 Mark for correct definition of Showltem())
NOTE:
Deduct ½ Mark if GetOffer() is not invoked
properly inside GetStock()function
(c) Define a class STOCK in C++ with
following description:
OUTSIDE DELHI 2010 4
Private Members
ICode of type integer (Item Code)
Item of type string (Item Name)
Price of type float (Price of each item)
Qty of type integer (Quantity in stock)
Discount of type float (Discount percentage
on the item)
(c) Define a class STOCK in C++ with
following description:
OUTSIDE DELHI 2010 4
A member function FindDisc() to calculate
discount as per the following rule:
If Qty<=50 Discount is 0
If 50<Qty<=100 Discount is 5
If Qty>100 Discount is 10
(c) Define a class STOCK in C++ with
following description:
OUTSIDE DELHI 2010 4
Public Members
A function Buy() to allow user to enter values
for ICode, Item, Price,
Qty and call function FindDisc() to calculate
the Discount.
A function ShowAll( ) to allow user to view the
content of all the data
members.
Ans. class STOCK
{
int ICode,Qty;
char Item[20];
float Price,Discount;
void FindDisc();
public:
void Buy();
void ShowAll();
} ;
void STOCK::Buy()
{
cin>>ICode;
gets(Item);
cin>>Price;
cin»Qty;
FindDisc();
}
void STOCK::FindDisc()
{
if (Qty<=50)
Discount=0;
else if (Qty<=100)
Discount=5; // =0.05;
else
Discount=10; // =0.1;
}
void STOCK::ShowAll()
{
cout<<ICode<<’t’<<Item<<’t’<<Price<<’t’<<Q
ty
<<’t’<<Discount<<endl;
}
(½ Mark for correct syntax for class header)
(½ Mark for correct declaration of data
members)
(1 Mark for correct definition of FindDisc())
(1 Mark for correct definition of Buy() with
proper invocation of FindDisc() function)
(1 Mark for correct definition of ShowAll())
NOTE:
Deduct ½ Mark if FindDisc() is not invoked
properly inside Buy() function
(c) Define a class Candidate in C++ with
following description:
Delhi 2011 4
Private Members
A data member RNo (Registration Number) of
type long
A data member Name of type string
A data member Score of type float
A data member Remarks of type string
A member function AssignRem( ) to assign
Remarks as per the Score obtained by a
candidate. Score range and the respective
Remarks are shown as follows:
(c) Define a class Candidate in C++ with
following description:
Delhi 2011 4
Score Remarks
>=50 Selected
less than 50 Not selected
Public Members
A function ENTER ( ) to allow user to enter
values for RNo, Name, Score & call function
AssignRem( ) to assign the remarks.
A function DISPLAY ( ) to allow user to view
the content of all the data members.
Ans class Candidate
{
long RNo;
char Name[20];
float Score;
char Remarks[20];
void AssignRem( ) ;
public:
void Enter( );
void Display( );
} ;
void Candidate: :AssignRem( )
{
if (Score>=50)
strcpy (Remarks,"Selected") ;
else
strcpy(Remarks,"Not Selected") ;
}
void Candidate: : Enter ( )
{
cin>>RNo ;
gets (Name) ; cin>>Score;
AssignRem( ) ;
}
void Candidate: :Display()
{
cout<<RNo<<Name<<Score<<Remarks<<endl;
}
(½ Mark for correct syntax for class header)
(½ Mark for correct declaration of data
members)
(1 Mark for correct definition of AssignRem())
(1 Mark for correct definition of Enter() with
proper invocation of AssignRem() function)
(1 Mark for correct definition of Display())
NOTE:
Deduct ½ Mark to be deducted if
Assignrem() is not invoked properly inside
Enter( ) function
No marks to be deducted if member function
definitions are writteninside the class
(c) Define a class Applicant in C++ with
following description:
OUTSIDE DELHI 2011 4
Private Members
A data member ANo (Admission Number) of
type long
A data member Name of type string
A data member Agg (Aggregate Marks) of type
float
A data member Grade of type char
A member function GradeMe() to find the
(c) Define a class Applicant in C++ with
following description:
OUTSIDE DELHI 2011 4
Grade as per the Aggregate Marks obtained by
a student. Equivalent Aggregate Marks range
and the respective Grades are shown as
follows:
Aggregate Marks Grade
>=80 A
less than 80 and >=65 B
less than 65 and >=50 C
less than 50 D
(c) Define a class Applicant in C++ with
following description:
OUTSIDE DELHI 2011 4
Public Members
A function ENTER() to allow user to enter
values for ANo, Name, Agg & call function
GradeMe() to find the Grade.
A function_RESULT( ) to allow user to view
the content of all the data members.
Ans class Applicant
{
long ANo;
char Name [20] ;
float Agg;
char Grade;
void Grademe ( ) ;
public:
void Enter ( ) ;
void Result ( ) ;
} ;
void Applicant: :GradeMe( )
{
if (Agg>=80)
Grade=' A' ;
else if(Agg>=65)
Grade=' B' ;
else if(Agg>=50)
Grade=' C' ;
else
Grade=' D' ;
}
void Applicant: :Enter ( )
{
cin>>ANo;
gets (Name) ;
cin>>Agg;
GradeMe() ;
}
void Applicant: :Result ( )
{
cout<<ANo<<Name<<Agg<<Grade<<end1;
}
(½ Mark for correct syntax for class header)
(½ Mark for correct declaration of data
members)
(1 Mark for correct definition of GradeMe( ))
(1 Mark for correct definition of Enter() with
proper invocation of GradeMe( ) function)
(1 Mark for correct definition of Result())
NOTE:
½ mark to be deducted if Grademe() is not
invoked within Enter()
No marks to be deducted if member function
definitions are inside the Class
(c) Define a class TEST in C++ with following
description:
SAMPLE PAPER 2010 SET I 4
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)
(c) Define a class TEST in C++ with following
description:
SAMPLE PAPER 2010 SET I 4
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
(c) class TEST
{
int TestCode;
char Description[20];
int NoCandidate,CenterReqd;
void CALCNTR();
public:
void SCHEDULE();
void DISPTEST();
};
void TEST::CALCNTR()
{
CenterReqd=NoCandidate/100 + 1;
}
void TEST::SCHEDULE()
{
cout<<"Test Code :";cin>>TestCode;
cout<<"Description :";gets(Description);
cout<<"Number :";cin>>NoCandidate;
CALCNTR();
}
void TEST::DISPTEST()
{
cout<<"Test Code :"<<TestCode<<endl;
cout<<"Description :"<<Description<<endl;
cout<<"Number :"<<NoCandidate<<endl;;
cout<<"Centres :"<<CenterReqd<<endl;;
}
(½ Mark for correct syntax for class header)
(½ Mark for correct declarations of data
members)
(1 Mark for appropriate definition of function
CALCNTR())
(1 Mark for appropriate definition of
SCHEDULE() with a call for CALCNTR())
(1 Mark for appropriate definition of
DISPTEST())
(c) Define a class FLIGHT in C++ with
following description:
SAMPLE PAPER 2010 SET II 4
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
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
(c) class FLIGHT
{
int Fno;
char Destination[20];
float Distance, Fuel;
void CALFUEL();
public:
void FEEDINFO();
void SHOWINFO();
};
void FLIGHT::CALFUEL()
{
if (Distance<=1000)
Fuel=500;
else
if (Distance<=2000)
Fuel=1100;
else
Fuel=2200;
}
void FLIGHT::FEEDINFO()
{
cout<<"Flight No :";cin>>Fno;
cout<<"Destination :";gets(Destination);
cout<<"Distance :";cin>>Distance;
CALFUEL();
}
void FLIGHT::SHOWINFO()
{
cout<<"Flight No :"<<Fno<<endl;
cout<<"Destination :"<<Destination<<endl;
cout<<"Distance :"<<Distance<<endl;;
cout<<"Fuel :"<<Fuel<<endl;;
}
(½ Mark for correct syntax for class header)
(½ Mark for correct declarations of data
members)
(1 Mark for appropriate definition of function
CALFUEL())
(1 Mark for appropriate definition of
FEEDINFO() with a call for CALFUEL())
(1 Mark for appropriate definition of
SHOWINFO())
SAMPLE PAPER 2012 SET I 4
SAMPLE PAPER 2012 SET I 4
SAMPLE PAPER 2012 SET II 4
SAMPLE PAPER 2012 SET II 4
SAMPLE PAPER 2012 SET II 4
THAN
K
YOU

More Related Content

What's hot

Cs101 endsem 2014
Cs101 endsem 2014Cs101 endsem 2014
Cs101 endsem 2014
RamKumar42580
 
A quick introduction to R
A quick introduction to RA quick introduction to R
A quick introduction to R
Angshuman Saha
 
Structured data type
Structured data typeStructured data type
Structured data type
Omkar Majukar
 
C arrays
C arraysC arrays
Monoids - Part 1 - with examples using Scalaz and Cats
Monoids - Part 1 - with examples using Scalaz and CatsMonoids - Part 1 - with examples using Scalaz and Cats
Monoids - Part 1 - with examples using Scalaz and Cats
Philip Schwarz
 
Monad Fact #4
Monad Fact #4Monad Fact #4
Monad Fact #4
Philip Schwarz
 
Templates in C++
Templates in C++Templates in C++
Templates in C++Tech_MX
 
Computer Science Sample Paper 2015
Computer Science Sample Paper 2015Computer Science Sample Paper 2015
Computer Science Sample Paper 2015
Poonam Chopra
 
Traversals for all ocasions
Traversals for all ocasionsTraversals for all ocasions
Traversals for all ocasions
Luka Jacobowitz
 
Advanced C - Part 3
Advanced C - Part 3Advanced C - Part 3
K map
K mapK map
Java notes 1 - operators control-flow
Java notes   1 - operators control-flowJava notes   1 - operators control-flow
Java notes 1 - operators control-flow
Mohammed Sikander
 
VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2
YOGESH SINGH
 
11 1. multi-dimensional array eng
11 1. multi-dimensional array eng11 1. multi-dimensional array eng
11 1. multi-dimensional array eng웅식 전
 
Lec 7 28_aug [compatibility mode]
Lec 7 28_aug [compatibility mode]Lec 7 28_aug [compatibility mode]
Lec 7 28_aug [compatibility mode]Palak Sanghani
 
An Introduction to Functional Programming using Haskell
An Introduction to Functional Programming using HaskellAn Introduction to Functional Programming using Haskell
An Introduction to Functional Programming using Haskell
Michel Rijnders
 
Engineering Equation Solver (Thai)
Engineering Equation Solver (Thai)Engineering Equation Solver (Thai)
Engineering Equation Solver (Thai)
Denpong Soodphakdee
 
The Ring programming language version 1.5.2 book - Part 175 of 181
The Ring programming language version 1.5.2 book - Part 175 of 181The Ring programming language version 1.5.2 book - Part 175 of 181
The Ring programming language version 1.5.2 book - Part 175 of 181
Mahmoud Samir Fayed
 
Lec 9 05_sept [compatibility mode]
Lec 9 05_sept [compatibility mode]Lec 9 05_sept [compatibility mode]
Lec 9 05_sept [compatibility mode]Palak Sanghani
 

What's hot (20)

Cs101 endsem 2014
Cs101 endsem 2014Cs101 endsem 2014
Cs101 endsem 2014
 
A quick introduction to R
A quick introduction to RA quick introduction to R
A quick introduction to R
 
Chapter2
Chapter2Chapter2
Chapter2
 
Structured data type
Structured data typeStructured data type
Structured data type
 
C arrays
C arraysC arrays
C arrays
 
Monoids - Part 1 - with examples using Scalaz and Cats
Monoids - Part 1 - with examples using Scalaz and CatsMonoids - Part 1 - with examples using Scalaz and Cats
Monoids - Part 1 - with examples using Scalaz and Cats
 
Monad Fact #4
Monad Fact #4Monad Fact #4
Monad Fact #4
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
 
Computer Science Sample Paper 2015
Computer Science Sample Paper 2015Computer Science Sample Paper 2015
Computer Science Sample Paper 2015
 
Traversals for all ocasions
Traversals for all ocasionsTraversals for all ocasions
Traversals for all ocasions
 
Advanced C - Part 3
Advanced C - Part 3Advanced C - Part 3
Advanced C - Part 3
 
K map
K mapK map
K map
 
Java notes 1 - operators control-flow
Java notes   1 - operators control-flowJava notes   1 - operators control-flow
Java notes 1 - operators control-flow
 
VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2
 
11 1. multi-dimensional array eng
11 1. multi-dimensional array eng11 1. multi-dimensional array eng
11 1. multi-dimensional array eng
 
Lec 7 28_aug [compatibility mode]
Lec 7 28_aug [compatibility mode]Lec 7 28_aug [compatibility mode]
Lec 7 28_aug [compatibility mode]
 
An Introduction to Functional Programming using Haskell
An Introduction to Functional Programming using HaskellAn Introduction to Functional Programming using Haskell
An Introduction to Functional Programming using Haskell
 
Engineering Equation Solver (Thai)
Engineering Equation Solver (Thai)Engineering Equation Solver (Thai)
Engineering Equation Solver (Thai)
 
The Ring programming language version 1.5.2 book - Part 175 of 181
The Ring programming language version 1.5.2 book - Part 175 of 181The Ring programming language version 1.5.2 book - Part 175 of 181
The Ring programming language version 1.5.2 book - Part 175 of 181
 
Lec 9 05_sept [compatibility mode]
Lec 9 05_sept [compatibility mode]Lec 9 05_sept [compatibility mode]
Lec 9 05_sept [compatibility mode]
 

Similar to Qno 2 (c)

Cs practical file
Cs practical fileCs practical file
Cs practical file
Shailendra Garg
 
Ch 4
Ch 4Ch 4
Ch 4
AMIT JAIN
 
Cs pritical file
Cs pritical fileCs pritical file
Cs pritical file
Mitul Patel
 
CBSE Question Paper Computer Science with C++ 2011
CBSE Question Paper Computer Science with C++ 2011CBSE Question Paper Computer Science with C++ 2011
CBSE Question Paper Computer Science with C++ 2011
Deepak Singh
 
Cbse question paper class_xii_paper_2000
Cbse question paper class_xii_paper_2000Cbse question paper class_xii_paper_2000
Cbse question paper class_xii_paper_2000Deepak Singh
 
Sp 1418794917
Sp 1418794917Sp 1418794917
Sp 1418794917
lakshmi r
 
CBSE Grade12, Computer Science, Sample Question Paper
CBSE Grade12, Computer Science, Sample Question PaperCBSE Grade12, Computer Science, Sample Question Paper
CBSE Grade12, Computer Science, Sample Question Paper
Malathi Senthil
 
OOP-Lecture-05 (Constructor_Destructor).pptx
OOP-Lecture-05 (Constructor_Destructor).pptxOOP-Lecture-05 (Constructor_Destructor).pptx
OOP-Lecture-05 (Constructor_Destructor).pptx
SirRafiLectures
 
Xiicsmonth
XiicsmonthXiicsmonth
Xiicsmonth
rishikasahu1908
 
CS Sample Paper 1
CS Sample Paper 1CS Sample Paper 1
CS Sample Paper 1
kvs
 
Object Oriented Programming using C++: Ch09 Inheritance.pptx
Object Oriented Programming using C++: Ch09 Inheritance.pptxObject Oriented Programming using C++: Ch09 Inheritance.pptx
Object Oriented Programming using C++: Ch09 Inheritance.pptx
RashidFaridChishti
 
Chapter27 polymorphism-virtual-function-abstract-class
Chapter27 polymorphism-virtual-function-abstract-classChapter27 polymorphism-virtual-function-abstract-class
Chapter27 polymorphism-virtual-function-abstract-classDeepak Singh
 
Unit 3 arrays and_string
Unit 3 arrays and_stringUnit 3 arrays and_string
Unit 3 arrays and_string
kirthika jeyenth
 
Computer Science Sample Paper 2
Computer Science Sample Paper 2Computer Science Sample Paper 2
Computer Science Sample Paper 2
kvs
 
2014 computer science_question_paper
2014 computer science_question_paper2014 computer science_question_paper
2014 computer science_question_paper
vandna123
 
Computer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paperComputer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paperDeepak Singh
 
Managing I/O in c++
Managing I/O in c++Managing I/O in c++
Managing I/O in c++
Pranali Chaudhari
 

Similar to Qno 2 (c) (20)

Cs practical file
Cs practical fileCs practical file
Cs practical file
 
Ch 4
Ch 4Ch 4
Ch 4
 
Cs pritical file
Cs pritical fileCs pritical file
Cs pritical file
 
CBSE Question Paper Computer Science with C++ 2011
CBSE Question Paper Computer Science with C++ 2011CBSE Question Paper Computer Science with C++ 2011
CBSE Question Paper Computer Science with C++ 2011
 
Cbse question paper class_xii_paper_2000
Cbse question paper class_xii_paper_2000Cbse question paper class_xii_paper_2000
Cbse question paper class_xii_paper_2000
 
Sp 1418794917
Sp 1418794917Sp 1418794917
Sp 1418794917
 
CBSE Grade12, Computer Science, Sample Question Paper
CBSE Grade12, Computer Science, Sample Question PaperCBSE Grade12, Computer Science, Sample Question Paper
CBSE Grade12, Computer Science, Sample Question Paper
 
OOP-Lecture-05 (Constructor_Destructor).pptx
OOP-Lecture-05 (Constructor_Destructor).pptxOOP-Lecture-05 (Constructor_Destructor).pptx
OOP-Lecture-05 (Constructor_Destructor).pptx
 
Bc0037
Bc0037Bc0037
Bc0037
 
Xiicsmonth
XiicsmonthXiicsmonth
Xiicsmonth
 
Lab 13
Lab 13Lab 13
Lab 13
 
CS Sample Paper 1
CS Sample Paper 1CS Sample Paper 1
CS Sample Paper 1
 
Object Oriented Programming using C++: Ch09 Inheritance.pptx
Object Oriented Programming using C++: Ch09 Inheritance.pptxObject Oriented Programming using C++: Ch09 Inheritance.pptx
Object Oriented Programming using C++: Ch09 Inheritance.pptx
 
Chapter27 polymorphism-virtual-function-abstract-class
Chapter27 polymorphism-virtual-function-abstract-classChapter27 polymorphism-virtual-function-abstract-class
Chapter27 polymorphism-virtual-function-abstract-class
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
 
Unit 3 arrays and_string
Unit 3 arrays and_stringUnit 3 arrays and_string
Unit 3 arrays and_string
 
Computer Science Sample Paper 2
Computer Science Sample Paper 2Computer Science Sample Paper 2
Computer Science Sample Paper 2
 
2014 computer science_question_paper
2014 computer science_question_paper2014 computer science_question_paper
2014 computer science_question_paper
 
Computer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paperComputer science-2010-cbse-question-paper
Computer science-2010-cbse-question-paper
 
Managing I/O in c++
Managing I/O in c++Managing I/O in c++
Managing I/O in c++
 

More from Praveen M Jigajinni

Chapter 09 design and analysis of algorithms
Chapter 09  design and analysis of algorithmsChapter 09  design and analysis of algorithms
Chapter 09 design and analysis of algorithms
Praveen M Jigajinni
 
Chapter 08 data file handling
Chapter 08 data file handlingChapter 08 data file handling
Chapter 08 data file handling
Praveen M Jigajinni
 
Chapter 07 inheritance
Chapter 07 inheritanceChapter 07 inheritance
Chapter 07 inheritance
Praveen M Jigajinni
 
Chapter 06 constructors and destructors
Chapter 06 constructors and destructorsChapter 06 constructors and destructors
Chapter 06 constructors and destructors
Praveen M Jigajinni
 
Chapter 05 classes and objects
Chapter 05 classes and objectsChapter 05 classes and objects
Chapter 05 classes and objects
Praveen M Jigajinni
 
Chapter 04 object oriented programming
Chapter 04 object oriented programmingChapter 04 object oriented programming
Chapter 04 object oriented programming
Praveen M Jigajinni
 
Chapter 03 python libraries
Chapter 03 python librariesChapter 03 python libraries
Chapter 03 python libraries
Praveen M Jigajinni
 
Chapter 02 functions -class xii
Chapter 02   functions -class xiiChapter 02   functions -class xii
Chapter 02 functions -class xii
Praveen M Jigajinni
 
Unit 3 MongDB
Unit 3 MongDBUnit 3 MongDB
Unit 3 MongDB
Praveen M Jigajinni
 
Chapter 17 Tuples
Chapter 17 TuplesChapter 17 Tuples
Chapter 17 Tuples
Praveen M Jigajinni
 
Chapter 15 Lists
Chapter 15 ListsChapter 15 Lists
Chapter 15 Lists
Praveen M Jigajinni
 
Chapter 14 strings
Chapter 14 stringsChapter 14 strings
Chapter 14 strings
Praveen M Jigajinni
 
Chapter 13 exceptional handling
Chapter 13 exceptional handlingChapter 13 exceptional handling
Chapter 13 exceptional handling
Praveen M Jigajinni
 
Chapter 10 data handling
Chapter 10 data handlingChapter 10 data handling
Chapter 10 data handling
Praveen M Jigajinni
 
Chapter 9 python fundamentals
Chapter 9 python fundamentalsChapter 9 python fundamentals
Chapter 9 python fundamentals
Praveen M Jigajinni
 
Chapter 8 getting started with python
Chapter 8 getting started with pythonChapter 8 getting started with python
Chapter 8 getting started with python
Praveen M Jigajinni
 
Chapter 7 basics of computational thinking
Chapter 7 basics of computational thinkingChapter 7 basics of computational thinking
Chapter 7 basics of computational thinking
Praveen M Jigajinni
 
Chapter 6 algorithms and flow charts
Chapter 6  algorithms and flow chartsChapter 6  algorithms and flow charts
Chapter 6 algorithms and flow charts
Praveen M Jigajinni
 
Chapter 5 boolean algebra
Chapter 5 boolean algebraChapter 5 boolean algebra
Chapter 5 boolean algebra
Praveen M Jigajinni
 
Chapter 4 number system
Chapter 4 number systemChapter 4 number system
Chapter 4 number system
Praveen M Jigajinni
 

More from Praveen M Jigajinni (20)

Chapter 09 design and analysis of algorithms
Chapter 09  design and analysis of algorithmsChapter 09  design and analysis of algorithms
Chapter 09 design and analysis of algorithms
 
Chapter 08 data file handling
Chapter 08 data file handlingChapter 08 data file handling
Chapter 08 data file handling
 
Chapter 07 inheritance
Chapter 07 inheritanceChapter 07 inheritance
Chapter 07 inheritance
 
Chapter 06 constructors and destructors
Chapter 06 constructors and destructorsChapter 06 constructors and destructors
Chapter 06 constructors and destructors
 
Chapter 05 classes and objects
Chapter 05 classes and objectsChapter 05 classes and objects
Chapter 05 classes and objects
 
Chapter 04 object oriented programming
Chapter 04 object oriented programmingChapter 04 object oriented programming
Chapter 04 object oriented programming
 
Chapter 03 python libraries
Chapter 03 python librariesChapter 03 python libraries
Chapter 03 python libraries
 
Chapter 02 functions -class xii
Chapter 02   functions -class xiiChapter 02   functions -class xii
Chapter 02 functions -class xii
 
Unit 3 MongDB
Unit 3 MongDBUnit 3 MongDB
Unit 3 MongDB
 
Chapter 17 Tuples
Chapter 17 TuplesChapter 17 Tuples
Chapter 17 Tuples
 
Chapter 15 Lists
Chapter 15 ListsChapter 15 Lists
Chapter 15 Lists
 
Chapter 14 strings
Chapter 14 stringsChapter 14 strings
Chapter 14 strings
 
Chapter 13 exceptional handling
Chapter 13 exceptional handlingChapter 13 exceptional handling
Chapter 13 exceptional handling
 
Chapter 10 data handling
Chapter 10 data handlingChapter 10 data handling
Chapter 10 data handling
 
Chapter 9 python fundamentals
Chapter 9 python fundamentalsChapter 9 python fundamentals
Chapter 9 python fundamentals
 
Chapter 8 getting started with python
Chapter 8 getting started with pythonChapter 8 getting started with python
Chapter 8 getting started with python
 
Chapter 7 basics of computational thinking
Chapter 7 basics of computational thinkingChapter 7 basics of computational thinking
Chapter 7 basics of computational thinking
 
Chapter 6 algorithms and flow charts
Chapter 6  algorithms and flow chartsChapter 6  algorithms and flow charts
Chapter 6 algorithms and flow charts
 
Chapter 5 boolean algebra
Chapter 5 boolean algebraChapter 5 boolean algebra
Chapter 5 boolean algebra
 
Chapter 4 number system
Chapter 4 number systemChapter 4 number system
Chapter 4 number system
 

Recently uploaded

Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
AzmatAli747758
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 

Recently uploaded (20)

Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 

Qno 2 (c)

  • 1. XII CBSE Previous Year Question Paper QUESTION NO 2 (c) 4 Marks
  • 2. (c) Define a class named ADMISSION in C++ with the following descriptions : Delhi 2006 4 Private members : AD_NO integer (Ranges 10 - 2000) NAME Array of characters(String) CLASS Character 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.
  • 3. (c) class ADMISSION { int AD_NO; char NAME[20]; //or any constant size char CLASS; float FEES; public: void Read_Data() { do { cin>>AD_NO; }while (AD_NO<10 || AD_NO>2000);
  • 5. void Draw_Nos(); }; (1 mark for proper syntax of class definition with correct class name and a semicolon to end the class definition) (1 mark for proper declaration of private members) (1 mark for proper definition of Read_Data()) (1 mark for proper definition of Display()) Note: No marks should be deducted for Not checking the range for AD_NO Not declaring or defining Draw_Nos(). (Mentioned as Draw- Nos() in the question paper)
  • 6. (c) Define a class named HOUSING in C++ with the following descriptions : Outside Delhi 2006 4 Private members REG_NO integer(Ranges 10 - 1000) NAME Array of characters(String) TYPE Character COST Float
  • 7. (c) Define a class named HOUSING in C++ with the following descriptions : Outside Delhi 2006 4 Public Members • Function Read_Data() to read an object of HOUSING type • Function Display() to display the details of an object • Function Draw_Nos()to choose and display the details of 2 houses selected randomly from an array of 10 objects of type HOUSING. Use random function to generate the registration
  • 8. (c) class HOUSING { int REG_NO; char NAME[20]; char TYPE; float COST; public: void Read_Data(); void Display(); void Draw_Nos(HOUSING S); };
  • 9. (c) void HOUSING::Read_Data() { cin>>REG_NO; //Validation not required cin>>NAME; //OR gets(NAME); cin>>TYPE; cin>>COST; } void HOUSING::Display() { cout<<REG_NO<<NAME<<TYPE<<COST<< endl; }
  • 10. (c) void HOUSING::Draw_Nos();//Ignore (1/2 mark for proper syntax of class definition with correct class name and a semicolon to end the class definition) (1/2 mark for mentioning the proper visibility modes (private / public)) (1 mark for proper declaration of private data members)
  • 11. (1 mark for proper definition of Read_Data() with user entry for data members OR declaring a local object and entering the values of data members of this object ) (1 mark for proper definition of Display()) Note: As language of Third part of this question has ambiguity, it is required to be ignored. Moreover, if anyone has partially attempted the third part (i.e., Draw_nos function) and not attempted/not correctly attempted Read/Display function, he/she should be given 2 Marks for Third part taking into consideration the marks for this question should not exceed the max. marks allocated (i.e. 4 marks) to this question 2 (c).
  • 12. (c) Define a class Travel in C++ with the description given below : Delhi 2007 4 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
  • 13. (c) Define a class Travel in C++ with the description given below : Delhi 2007 4 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
  • 14. (c) Define a class Travel in C++ with the description given below : Delhi 2007 4 • 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
  • 15. (c) Define a class Travel in C++ with the description given below : Delhi 2007 4 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
  • 16. (c) Define a class Travel in C++ with the description given below : Delhi 2007 4 • 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.
  • 17. (c) class Travel { char TCode[5]; //OR char *Tcode; int No_of_Adults; int No_of_Children; int Distance; float TotalFare; public: Travel(); void AssignFare(); void EnterTravel(); void ShowTravel(); };
  • 18. Travel::Travel() { strcpy(TCode,”NULL”);// OR TCode[0]=’0’ OR strcpy(TCode,”0”) // OR TCode=NULL if TCode is declared as char pointer No_of_Adults = 0; No_of_Children = 0; Distance = 0; TotalFare = 0; }
  • 19. void Travel::AssignFare() { if(Distance>=1000) TotalFare = 500*No_of_Adults+250*No_of_Children; else if (Distance >= 500) TotalFare = 300*No_of_Adults+150*No_of_Children; else TotalFare = 200*No_of_Adults+100*No_of_Children; }
  • 20. void Travel::EnterTravel() { gets(TCode); // or cin >> TCode; cin>>No_of_Adults>>No_of_Children>>Dista nce; AssignFare(); } void Travel::ShowTravel() { cout<<TCode<<No_of_Adults<<No_of_Childr en <<Distance<<TotalFare<<endl; }
  • 21. (½ Mark for correct syntax of class header) (½ Mark for correct declaration of data members) (1 Mark for correct definition of constructor) (1 Mark for checking all three conditions and calculating TotalFare in AssignFare( )) (½ Mark for correct EnterTravel( ) with proper invocation of AssignFare( )) (½ Mark for displaying all data Members including TotalFare inside ShowTravel( ))
  • 22. (c) Define a class Tour in C++ with the description given below : Outside Delhi 2007 4 Private Members : TCode of type string NoofAdults of type integer NoofKids of type integer Kilometres of type integer TotalFare of type float
  • 23. (c) Define a class Tour in C++ with the description given below : Outside Delhi 2007 4 Public Members : • A constructor to assign initial values as follows : TCode with the word “NULL” NoofAdults as 0 NoofKids as 0 Kilometres as 0 TotalFare as 0
  • 24. (c) Define a class Tour in C++ with the description given below : Outside Delhi 2007 4 • A function AssignFare ( ) which calculates and assigns the value of the data member TotalFare as follows For each Adult Fare(Rs) For Kilometres 500 >=1000 300 <1000&>=500 200 <500
  • 25. (c) Define a class Tour in C++ with the description given below : Outside Delhi 2007 4 For each Kid the above Fare will be 50% of the Fare mentioned in the above table For example : If Kilometres is 850, NoofAdults = 2 and NoofKids = 3 Then TotalFare should be calculated as NumofAdults * 300 + NoofKids * 150 i.e. 2*300 + 3*150=1050
  • 26. (c) Define a class Tour in C++ with the description given below : Outside Delhi 2007 4 • A function EnterTour( ) to input the values of the data members TCode, NoofAdults, NoofKids and Kilometres; and invoke the Assign Fare( ) function. • A function ShowTour( ) which displays the content of all the data members for a Tour.
  • 27. (c) class Tour { char TCode[10]; //OR char *Tcode; int NoofAdults; int NoofKids; int Kilometres; float TotalFare; public: Tour() { strcpy(TCode,”NULL”); //OR TCode[0]=’0’OR strcpy(TCode,”0”)
  • 28. //OR TCode=NULL if TCode is declared as char pointer NoofAdults = 0; NoofKids = 0; Kilometres = 0; TotalFare = 0; } void AssignFare(); void EnterTour(); void ShowTour(); };
  • 29. void Tour::AssignFare() { if(Kilometres>=1000) TotalFare = 500*NoofAdults+250*NoofKids; else if (Kilometres >= 500) TotalFare = 300*NoofAdults+150*NoofKids; else TotalFare = 200*NoofAdults+100*NoofKids; }
  • 30. void Tour::EnterTour() { gets(TCode); // or cin >> TCode; cin>>NoofAdults>>NoofKids>>Kilometres; AssignFare( ); } void Tour::ShowTour() { cout<<TCode<<NoofAdults<<NoofKids<<Kilo metres<<TotalFare<<endl; }
  • 31. (½ Mark for correct syntax for class header) (½ Mark for correct declaration of data members) (1 Mark for correct definition of constructor) (½ Mark for condition checking in AssigFare()) (½ Mark for calculation of correct TotalFare for each condition) (½ Mark for correct EnterTour() with proper invocation of AssignFare()) (½ Mark for displaying all data Members including TotalFare inside ShowTour())
  • 32. (c) Define a class Garments in C++ with the following descriptions: Delhi 2008 4 Private Members: GCode of type string GType of type string GSize of type integer GFabric of type string GPrice of type float A function Assign ( ) which calculates and assigns the value of GPrice as follows
  • 33. (c) Define a class Garments in C++ with the following descriptions: Delhi 2008 4 For the value of GFabric as “COTTON”, GType GPrice(Rs) TROUSER 1300 SHIRT 1100 For GFabric other than “COTTON” the above mentioned GPrice gets reduced by 10%.
  • 34. (c) Define a class Garments in C++ with the following descriptions: Delhi 2008 4 Public Members: A constructor to assign initial values of GCode, GType and GFabric with the word “NOT ALLOTTED” and GSize and GPrice with 0 A function Input ( ) to input the values of the data members GCode, GType, GSize and GFabric and invoke the Assign ( ) function. A function Display ( ) which displays the content of all the data members for a Garment.
  • 35. Ans: class Garments { char GCode[10]; char GType[10]; int GSize; char GFabric[10] ; float GPrice; void Assign( ) ;
  • 36. public: Garments( ) { strcpy(GCode,”NOT ALLOTTED”) ; strcpy(GType,”NOT ALLOTTED”) ; strcpy (GFabric, “NOT ALLOTTED”) ; GSize=0; GPrice=0; } void Input( ) ; void Display( ) ; } ;
  • 37. void Garments::Assign( ) { if (strcmp(GFabric,“COTTON”)==0) //if (!strcmp(GFabric, “COTTON”)) { if (strcmp(GType,“TROUSER”) ==0) GPrice=1300; else if (strcmp(GType,“SHIRT”)==0) GPrice=1100; }
  • 38. else { if (strcmp(GType,”TROUSER”) = =0) GPrice=1300*0.9; // 10% reduction else if (strcmp(GType,“SHIRT”)= =0) GPrice=1100*0.9; // 10% reduction } } void Garments::Input( ) { gets(GCode) ; // or cin >> GCode; gets(GType) ; // or cin >> GType; cin>>Gsize;
  • 39. gets(GFabric) ;// or cin >> GFabric; Assign( ) ; } void Garments::Display( ) { cout<<GCode<<GType<<GSize<<GFabric<<G Price<<endl; } (½ Mark for correct syntax for class header) (½ Mark for correct declaration of data members) (½ Mark for correct definition of constructor)
  • 40. (1 Mark for correct definition of Assign( )) (1 Mark for correct definition of Input( ) with proper invocation of Assign( ) function) (½ Mark for correct definition of Display( )) NOTE: Deduct % Mark if Assign( ) is not invoked properly inside Input( ) function
  • 41. (c) Define a class Clothing in C++ with the following descriptions: Outside Delhi 2008 4 Private Members: Code of type string Type of type string Size of type integer Material of type string Price of type float A function Calc_Price( ) which calculates and assigns the value of Price as follows:
  • 42. (c) Define a class Clothing in C++ with the following descriptions: Outside Delhi 2008 4 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%.
  • 43. (c) Define a class Clothing in C++ with the following descriptions: Outside Delhi 2008 4 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
  • 44. Ans: class Clothing { char Code[25]; char Type[25]; int Size; char Material[30]; float Price; Public: Clothing() ; void Calc_Price() ; void Enter() ; void Show() ; };
  • 46. void Clothing:: Calc_Price() { if (strcmp(Type, “TROUSER”) ==0 && strcmp (Material,“COTTON”)==0) Price=1500; else if (strcmp(Type, “SHIRT”) ==0 && strcmp(Material,”COTTON”)==O) Price=1200; else if (strcmp(Type, “TROUSER”) ==0 && strcmp(Material,”COTTON”)!=O) Price=1500*0.75;
  • 47. void Clothing:: Calc_Price() { if (strcmp(Type, “TROUSER”) ==0 && strcmp (Material,“COTTON”)==0) Price=1500; else if (strcmp(Type, “SHIRT”) ==0 && strcmp(Material,”COTTON”)==O) Price=1200; else if (strcmp(Type, “TROUSER”) ==0 && strcmp(Material,”COTTON”)!=O) Price=1500*0.75; else if (strcmp(Type,”SHIRT”)==0) &&
  • 48. strcmp(Material,”COTTON”)!= 0) Price=1200*0.75; } void Clothing::Enter() { gets(Code) ; // or cin >> Code; gets(Type) ; // or cin >> Type; cin>>Size; gets(Material) ;// or cin >> Material; Calc_Price() ; }
  • 49. void Clothing::Show() { cout<<Code<<Type<<Size<<Material<<Price< <endl; } (½ Mark for correct syntax for class header) (½ Mark for correct declaration of data members) (½ Mark for correct definition of function Calc_price()) (½ Mark for constructor) (1 Mark for calculation of correct Price for each condition)
  • 50. (½ Mark for correct Enter() with proper invocation of Calc_Price()) (½ Mark for displaying all data Members in function Show())
  • 51. (c) Define a class RESORT in C++ with following description: Delhi 2009 4 Private Members Rno //Data member to store Room No Name //Data member to store customer name Charges //Data member to store per day charges Days //Data member to store number of days of stay COMPUTE( ) //A function to calculate’ and return Amount as
  • 52. (c) Define a class RESORT in C++ with following description: Delhi 2009 4 Days*Charges and if the value of Days*Charges is more than 11000 then as 1.02*Days*Charges Public Members Getinfo ( ) //A function to enter the content Rno, Name, Charges and Days Dispinfo ( ) //A function to display Rno, Name, Charges,Days and Amount (Amount to be displayed by calling function COMPUTE ( ) )
  • 53. Ans class RESORT { int Rno; char Name [20]; float Charges; int Days; float COMPUTE(); public: void Getinfo() ; void Dispinfo(); };
  • 54. void RESORT::Getinfo() { cin>>Rno; gets (Name); cin>>Charges; cin>>Days; } void RESORT::Dispinfo() { cout<<Rno<<” “<<Name<<“ “<<Charges<<” “<<Days<< COMPUTE()<<endl; }
  • 55. float RESORT::COMPUTE() { float Amount = Charges*Days; if (Amount>11000) Amount = 1.02*Days*Charges; return Amount; } (½ Mark for correct syntax for class header) (½ Mark for correct declaration of data members) (1 Mark for correct definition of COMPUTE ( )) .
  • 56. (1 Mark for correct definition of Dispinfo( ) with proper invocation of COMPUTEO function) (1 Mark for correct definition of Getinfo( )) NOTE: Deduct ½ Mark if COMPUTE( ) is not invoked properly inside Dispinfo( ) function
  • 57. (c) Define a class HOTEL in C++ with the following description: Outside Delhi 2009 4 Private Members: Rno //Data member to store Room No Name //Data member to store customer name Tariff //Data member to store per day charges NOD //Data member to store number of days of stay CALC( ) //A function to calculate and return Amount as NOD*Tariff and if the value of NOD*Tariff is more than 10000 then as 1.05*NOD*Tariff
  • 58. (c) Define a class HOTEL in C++ with the following description: Outside Delhi 2009 4 Public Members Checkin ( ) / / A function to enter the content Rno, Name, Tariff and NOD Checkout( ) / / A function to display Rno, Name, Tariff,NOD and Amount (Amount to be displayed by calling function CALC( ))
  • 59. Ans class HOTEL { int Rno; char Name[20]; float Tariff; int NOD; float CALC() ; public: void Checkin() ; void Checkout() ; } ;
  • 60. float HOTEL::CALC() { float Amount = Tariff*NOD; if (Amount>10000) Amount = 1.05*NOD*Tariff; return Amount; } void HOTEL::Checkin() { cin>>Rno; gets (Name); cin>>Tariff; cin>>NOD; }
  • 61. void HOTEL::Checkout() { cout<<Rno<<” “<<Name<<“ “<<Tariff<<” “<<NOD<< CALC ()<<endl; } (½ Mark for correct syntax for class header) (½ Mark for correct declaration of data members) (1 Mark for correct definition of CALC( )) (1 Mark for correct definition of Checkout( ) with proper invocation of CALC( ) function)
  • 62. (1 Mark for correct definition of Checkin()) NOTE: Deduct ½ Mark if CALC() is not invoked properly inside Checkout( ) function
  • 63. (c) Define a class ITEM in C++ with following description: Delhi 2010 4 Private Members Code of type integer (Item Code) Iname of type string (Item Name) Price of type float (Price of each item) Qty of type integer (Quantity of item in stock) Offer of type float (Offer percentage on the item)
  • 64. (c) Define a class ITEM in C++ with following description: Delhi 2010 4 A member function GetOffer() to calculate Offer percentage as per the following rule: If Qty<=50 Offer is 0 If 50<Qty<=100 Offer is 5 If Qty>100 Offer is 10
  • 65. (c) Define a class ITEM in C++ with following description: Delhi 2010 4 Public Members A function GetStock() to allow user to enter values for Code, Iname, Price, Qty and call function GetOffer() to calculate the offer A function ShowItem() to allow user to view the content of all the data members
  • 66. Ans. class ITEM { int Code; char Iname [20] ; float Price; int Qty; float Offer; void GetOffer() ; public: void GetStock () { cin>>Code;
  • 67. gets (Iname) ; // OR cin.getline (Iname, 80) ; OR cin>>Iname; cin>>Price>>Qty; GetOffer() ; } void ShowItern ( ) { cout<<Code<<Iname<<Price<<Qty<<Offer; };
  • 68. void ITEM: : GetOffer () { if (Qty<=50) Offer = 0; else if (Qty <=100) Offer = 5; / /OR Offer = 0.05; else Offer = 10; / /OR Offer = 0.1; } (½ Mark for correct syntax for class header) (½ Mark for correct declaration of data members)
  • 69. (1 Mark for correct definition of GetOffer()) (1 Mark for correct definition of GetStock () with proper invocation of GetOffer() function) (1 Mark for correct definition of Showltem()) NOTE: Deduct ½ Mark if GetOffer() is not invoked properly inside GetStock()function
  • 70. (c) Define a class STOCK in C++ with following description: OUTSIDE DELHI 2010 4 Private Members ICode of type integer (Item Code) Item of type string (Item Name) Price of type float (Price of each item) Qty of type integer (Quantity in stock) Discount of type float (Discount percentage on the item)
  • 71. (c) Define a class STOCK in C++ with following description: OUTSIDE DELHI 2010 4 A member function FindDisc() to calculate discount as per the following rule: If Qty<=50 Discount is 0 If 50<Qty<=100 Discount is 5 If Qty>100 Discount is 10
  • 72. (c) Define a class STOCK in C++ with following description: OUTSIDE DELHI 2010 4 Public Members A function Buy() to allow user to enter values for ICode, Item, Price, Qty and call function FindDisc() to calculate the Discount. A function ShowAll( ) to allow user to view the content of all the data members.
  • 73. Ans. class STOCK { int ICode,Qty; char Item[20]; float Price,Discount; void FindDisc(); public: void Buy(); void ShowAll(); } ;
  • 75. void STOCK::FindDisc() { if (Qty<=50) Discount=0; else if (Qty<=100) Discount=5; // =0.05; else Discount=10; // =0.1; }
  • 76. void STOCK::ShowAll() { cout<<ICode<<’t’<<Item<<’t’<<Price<<’t’<<Q ty <<’t’<<Discount<<endl; } (½ Mark for correct syntax for class header) (½ Mark for correct declaration of data members) (1 Mark for correct definition of FindDisc())
  • 77. (1 Mark for correct definition of Buy() with proper invocation of FindDisc() function) (1 Mark for correct definition of ShowAll()) NOTE: Deduct ½ Mark if FindDisc() is not invoked properly inside Buy() function
  • 78. (c) Define a class Candidate in C++ with following description: Delhi 2011 4 Private Members A data member RNo (Registration Number) of type long A data member Name of type string A data member Score of type float A data member Remarks of type string A member function AssignRem( ) to assign Remarks as per the Score obtained by a candidate. Score range and the respective Remarks are shown as follows:
  • 79. (c) Define a class Candidate in C++ with following description: Delhi 2011 4 Score Remarks >=50 Selected less than 50 Not selected Public Members A function ENTER ( ) to allow user to enter values for RNo, Name, Score & call function AssignRem( ) to assign the remarks. A function DISPLAY ( ) to allow user to view the content of all the data members.
  • 80. Ans class Candidate { long RNo; char Name[20]; float Score; char Remarks[20]; void AssignRem( ) ; public: void Enter( ); void Display( ); } ;
  • 81. void Candidate: :AssignRem( ) { if (Score>=50) strcpy (Remarks,"Selected") ; else strcpy(Remarks,"Not Selected") ; } void Candidate: : Enter ( ) { cin>>RNo ; gets (Name) ; cin>>Score; AssignRem( ) ; }
  • 82. void Candidate: :Display() { cout<<RNo<<Name<<Score<<Remarks<<endl; } (½ Mark for correct syntax for class header) (½ Mark for correct declaration of data members) (1 Mark for correct definition of AssignRem()) (1 Mark for correct definition of Enter() with proper invocation of AssignRem() function)
  • 83. (1 Mark for correct definition of Display()) NOTE: Deduct ½ Mark to be deducted if Assignrem() is not invoked properly inside Enter( ) function No marks to be deducted if member function definitions are writteninside the class
  • 84. (c) Define a class Applicant in C++ with following description: OUTSIDE DELHI 2011 4 Private Members A data member ANo (Admission Number) of type long A data member Name of type string A data member Agg (Aggregate Marks) of type float A data member Grade of type char A member function GradeMe() to find the
  • 85. (c) Define a class Applicant in C++ with following description: OUTSIDE DELHI 2011 4 Grade as per the Aggregate Marks obtained by a student. Equivalent Aggregate Marks range and the respective Grades are shown as follows: Aggregate Marks Grade >=80 A less than 80 and >=65 B less than 65 and >=50 C less than 50 D
  • 86. (c) Define a class Applicant in C++ with following description: OUTSIDE DELHI 2011 4 Public Members A function ENTER() to allow user to enter values for ANo, Name, Agg & call function GradeMe() to find the Grade. A function_RESULT( ) to allow user to view the content of all the data members.
  • 87. Ans class Applicant { long ANo; char Name [20] ; float Agg; char Grade; void Grademe ( ) ; public: void Enter ( ) ; void Result ( ) ; } ;
  • 88. void Applicant: :GradeMe( ) { if (Agg>=80) Grade=' A' ; else if(Agg>=65) Grade=' B' ; else if(Agg>=50) Grade=' C' ; else Grade=' D' ; }
  • 89. void Applicant: :Enter ( ) { cin>>ANo; gets (Name) ; cin>>Agg; GradeMe() ; } void Applicant: :Result ( ) { cout<<ANo<<Name<<Agg<<Grade<<end1; }
  • 90. (½ Mark for correct syntax for class header) (½ Mark for correct declaration of data members) (1 Mark for correct definition of GradeMe( )) (1 Mark for correct definition of Enter() with proper invocation of GradeMe( ) function) (1 Mark for correct definition of Result()) NOTE: ½ mark to be deducted if Grademe() is not invoked within Enter() No marks to be deducted if member function definitions are inside the Class
  • 91. (c) Define a class TEST in C++ with following description: SAMPLE PAPER 2010 SET I 4 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)
  • 92. (c) Define a class TEST in C++ with following description: SAMPLE PAPER 2010 SET I 4 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
  • 93. (c) class TEST { int TestCode; char Description[20]; int NoCandidate,CenterReqd; void CALCNTR(); public: void SCHEDULE(); void DISPTEST(); };
  • 94. void TEST::CALCNTR() { CenterReqd=NoCandidate/100 + 1; } void TEST::SCHEDULE() { cout<<"Test Code :";cin>>TestCode; cout<<"Description :";gets(Description); cout<<"Number :";cin>>NoCandidate; CALCNTR(); }
  • 95. void TEST::DISPTEST() { cout<<"Test Code :"<<TestCode<<endl; cout<<"Description :"<<Description<<endl; cout<<"Number :"<<NoCandidate<<endl;; cout<<"Centres :"<<CenterReqd<<endl;; } (½ Mark for correct syntax for class header) (½ Mark for correct declarations of data members)
  • 96. (1 Mark for appropriate definition of function CALCNTR()) (1 Mark for appropriate definition of SCHEDULE() with a call for CALCNTR()) (1 Mark for appropriate definition of DISPTEST())
  • 97. (c) Define a class FLIGHT in C++ with following description: SAMPLE PAPER 2010 SET II 4 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
  • 98. 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
  • 99. (c) class FLIGHT { int Fno; char Destination[20]; float Distance, Fuel; void CALFUEL(); public: void FEEDINFO(); void SHOWINFO(); };
  • 100. void FLIGHT::CALFUEL() { if (Distance<=1000) Fuel=500; else if (Distance<=2000) Fuel=1100; else Fuel=2200; }
  • 101. void FLIGHT::FEEDINFO() { cout<<"Flight No :";cin>>Fno; cout<<"Destination :";gets(Destination); cout<<"Distance :";cin>>Distance; CALFUEL(); }
  • 102. void FLIGHT::SHOWINFO() { cout<<"Flight No :"<<Fno<<endl; cout<<"Destination :"<<Destination<<endl; cout<<"Distance :"<<Distance<<endl;; cout<<"Fuel :"<<Fuel<<endl;; }
  • 103. (½ Mark for correct syntax for class header) (½ Mark for correct declarations of data members) (1 Mark for appropriate definition of function CALFUEL()) (1 Mark for appropriate definition of FEEDINFO() with a call for CALFUEL()) (1 Mark for appropriate definition of SHOWINFO())
  • 104. SAMPLE PAPER 2012 SET I 4
  • 105.
  • 106. SAMPLE PAPER 2012 SET I 4
  • 107. SAMPLE PAPER 2012 SET II 4
  • 108. SAMPLE PAPER 2012 SET II 4
  • 109. SAMPLE PAPER 2012 SET II 4