Answer to Question #174166 in C++ for P. Gokul

Question #174166

Declare the base class circle with attribute radius. Assign the values in default constructor, member functions are getdata() to get input values for data members, develop member function area() to find the area of circle and display() to print the area of circle using multilevel inheritance.


1
Expert's answer
2021-03-25T01:36:30-0400
#include <bits/stdc++.h> 
using namespace std;


// Declare the base class circle with attribute radius. 
// Assign the values in default constructor, 
// member functions are getdata() to get input values for data members, 
// develop member function area() to find the area of circle and display() 
// to print the area of circle using multilevel inheritance.


class Circle
{
	float Radius,PI=3.1457;
	public:
	float area(float r) 
	{
		float A;
		A = PI * r * r;
		return(A);
	}
	float getData(void)
	{
		float r;
		cout<<"\nEnter the radius of circle: "; cin>>r;	
		return(r);
	}
	void display(float A)
	{
		cout<<"\n\nArea of Circle = "<<A<<" sq. units";
	}
	
};




main(void)
{
	float Radius,CircleArea,Perimeter;
	Circle C;
	Radius = C.getData();
	CircleArea = C.area(Radius);
	C.display(CircleArea);
	return(0);
}




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS