This project has moved. For the latest updates, please go here.

Create a class circle, that have the one data member radius; and have a methods SetRadius that set the value of the radius and another method that compute the area of circle; then in your main program access the method and display the area of the circle.

Coordinator
Nov 27, 2015 at 2:26 PM
#include<iostream.h>
#include<conio.h>
#include<math.h>

class Circle
{
    float radius;
    public:
    void setRadius(float value)
    {
        radius = value;
    }
    float areaOfCircle()
    {
        return 3.14 * pow(radius,2);
    }
};

void main()
{
    Circle circle;
    clrscr();
    float radius, area;
    cout<<"Enter the radius of a circle\n";
    cin>>radius;
    circle.setRadius(radius);
    area = circle.areaOfCircle();
    cout<<"Area of a circle = "<<area;
    getch();
}