Answer to Question #205326 in C++ for waheed

Question #205326

write a class circle with one protected data member radius. Write three member function set radius to set radius value with parameter value area to display area and circum to calculate and display circumfance of circle


1
Expert's answer
2021-06-10T13:30:44-0400
#include<iostream.h>
#include<stdlib.h>
using namespace std;

class Circle{
  protected:
    float radius;
};
class child : public Circle{
  public:
    void setRadius(float rad){
      radius=rad;
    }
    void displayArea(){
      float area=3.14*radius*radius;
      cout<<"Area of circle"<<area<<endl;
    }
    void displayCircumference(){
      float circum=2*3.14*radius;
      cout<<"Circumference of Circle is = "<<circum<<endl;
    }
};

int main(){
  child obj;
  obj.setRadius(5);
  obj.displayArea();
  obj.displayCircumference();
  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