Created
August 7, 2020 02:04
-
-
Save iqfareez/6287e4707859282a446fa3f6d96601b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
#define PI 3.142 | |
class circle{ | |
private: | |
double radius; | |
public: | |
void setRadius(double); | |
double getRadius() const{ | |
return radius; | |
} | |
double getArea() const{ | |
return PI*radius*radius; | |
} | |
double getPerimeter() const{ | |
return 2*PI*radius; | |
} | |
}; | |
void circle::setRadius(double r){ | |
radius = r; | |
} | |
int main(){ | |
circle c1; | |
double r; | |
cout <<"Enter radius for c1" <<endl; | |
cin >> r; | |
c1.setRadius(r); | |
cout<<"Value entered for radius in c1 circle is: " <<c1.getRadius()<<endl; | |
cout<<"Area of c1 is: " <<c1.getArea()<<endl; | |
cout<<"Perimeter of c1 is: " <<c1.getPerimeter()<<endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment