C++ program to find the area and perimeter of circle
In this example, we will find the C++ Program to Find Area and Circumference of circle when radius is given.
Area of Circle :- Area of any circle is the region enclosed by the circle itself or the space covered by the circle.
Circumference of a circle :- Circumference of the circle or perimeter of the circle is the measurement of the boundary of the circle.
Formulae :-
Circumference of Circle – 2ℼr
Area of Circle – ℼr2 (where r is the radius of circle) and ℼ = 3.14
C++ program to find the area and perimeter of circle
// Program to input (1 or 2). If choice is 1, print the area of
// a circle otherwise print the perimeter of circle.
// Accept the radius of circle from user
using namespace std;
#include<iostream>
int main()
{
const float pi = 3.14;
float r, area, c;
int ch;
cout<<"Enter the radius of circle: "<<endl;
cin>>r;
cout<<"\t\tOptions"<<endl;
cout<<"\t1. Area of circle"<<endl;
cout<<"\t2. perimeter of circle"<<endl;
cout<<"enter your choice: ";
cin>>ch;
switch(ch)
{
case 1:
area = pi*r*r;
cout<<"radius is:"<<r<<endl;
cout<<"area is:"<<area<<endl;
break;
case 2:
c = 2*pi*r;
cout<<"radius is:"<<r<<endl;
cout<<"perimeter is:"<<c<<endl;
break;
default:
cout<<"invalid choice, try again"<<endl;
break;
}
return 0;
}
Output :-



