Area and Circumference of circle in C++
#include<iostream>
#include<cmath>
using namespace std;
const float pi = 3.14;
class circle{
public: float area(int r){
return pi * pow(r,2);
}
float circumference(int r){
return 2 * pi * r;
}
};
int main(){
int r;
cout << "Get Area and Circumference of circle:\n";
cout << "enter radius of circle: ";
cin>>r;
circle c;
cout<<"area: "<<c.area(r)<<"\n";
cout<<"circumference: "<<c.circumference(r)<<"\n";
}
Comments
Post a Comment