Formulae:
- Area of Circle = Ï€ r²
- Circumference of Circle =2 π r
Calculate and print area and circumference of circle
Code
#include<bits/stdc++.h>
using namespace std;
void Area(int r){
float area=3.14*r*r; //formula to calculate area of circle
cout<<"Area of Circle is: "<<area<<endl; //prints area of circle
}
void Circumference(int r){
float circumference=2*3.14*r; //formula to calculate circumference of circle
cout<<"Perimeter of Circle is: "<<circumference<<endl; //prints circumference of circle
}
int main(){
cout<<"Enter Radius of the Circle "<<endl; //Requesting Radius
int radius; //to store radius
cin>>radius; //reading radius
Area(radius); //calling Area function
Circumference(radius); //calling Circumference function
return 0;
}
0 Comments