0 votes
3.0k views
in Programming by (98.9k points)
edited
Write an Object Oriented Program in C++, to implement circle class to find area and circumference of a circle using functions void area(), void circum().

1 Answer

0 votes
by (98.9k points)
selected by
 
Best answer

#include<iostream>

using namespace std;


class Circle 

{

public:

    float radius, area_of_circle,circumference;


    void getRadius() 

{

        cout << "Enter radius of a circle:";

        cin >> radius;

    }


    void area() 

{

        area_of_circle = 3.14 * radius * radius;

    }

    

    void circum()

    {

    circumference= 2 * 3.14 * radius;

}


void display() 

{

        cout << "Area of circle is:" << area_of_circle<<endl;

        cout << "Circumference of circle is:" << circumference;

    }

};


int main() {


    Circle cir;


    cir.getRadius();

    cir.area();

    cir.circum();

    cir.display();


    return 0;

}



Output::

Related questions

0 votes
1 answer 161 views
asked Apr 24, 2022 in Programming by Doubtly (98.9k points)

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

558 users

...