Page 247 - C++
P. 247
CBSE AISSCE 2016-2017 Marking Scheme for Computer Science
(Sub Code: 083 Paper Code 91/1 Delhi)
( ½ Mark for writing statement 1 correctly)
( ½ Mark for writing statement 2 correctly)
(c) Write the definition of a class RING in C++ with following description: 4
Private Members
- RingNumber // data member of integer type
- Radius // data member of float type
- Area // data member of float type
- CalcArea() // Member function to calculate and assign
// Area as 3.14 * Radius*Radius
Public Members
- GetArea() // A function to allow user to enter values of
// RingNumber and Radius. Also, this
// function should call CalcArea() to calculate
// Area
- ShowArea() // A function to display RingNumber, Radius
// and Area
Ans class RING
{
int RingNumber ;
float Radius ;
float Area ;
void CalcArea(){Area=3.14*Radius*Radius;}
public:
void GetArea();
void ShowArea();
};
void RING::GetArea()
{
cin>>RingNumber>>Radius;
CalcArea();
}
void RING::ShowArea()
{
cout<<RingNumber<<” ”<<Radius<<” ”<<Area<<endl;
}
(½ Mark for declaring class header correctly)
(½ Mark for declaring data members correctly)
(1 Mark for defining CalcArea() correctly)
(½ Mark for taking inputs of RingNumber and Radius in GetArea())
(½ Mark for invoking CalcArea() inside GetArea())
(½ Mark for defining ShowArea() correctly)
(½ Mark for correctly closing class declaration with a semicolon ; )
NOTE:
Marks to be awarded for defining the member functions inside or outside the
class
(d) Answer the questions (i) to (iv) based on the following: 4
class One
{
Page #6 of 28