Area of Circle program in c++. Circumference of circle in Cpp. Area and perimeter of circle program.




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;

}



Output


Enter Radius of the Circle 
4
Area of Circle is: 50.24
Perimeter of Circle is: 25.12

Post a Comment

0 Comments