How to find area of circle(object oriented method)

0

 



#
include<iostream>

//Implement a circle class. Each object of this class will represent a circle accepting its radius value as float . Include an area() function which will calculate the area of circle

#include<bits/stdc++.h>
using namespace st
int main(){
    float r,a;
    const float pi = 3.1
    cout<<"enter the radius";
    cin>>
    a = pi * pow(r,2);
    cout<<"The area of the circle is ="<<
    return 0;  
}  

// object oriented method
#include<iostream>
using namespace std;

class Test {
public:
    float r, area;

    void input() {
        cout << "Enter radius of a circle:";
        cin >> r;

    }

    void findArea() {
        area = 3.14 * r * r;
    }

    void display() {
        cout << "Area of circle is:" << area;
    }
};

int main() {

    Test obj;

    obj.input();
    obj.findArea();
    obj.display();

    return 0;
}

Post a Comment

0 Comments
Post a Comment (0)
To Top