A C++ program to calculate the area of a circle when the radius is given using a simple function
#include <iostream>
float circarea(float radius);//Function prototype
using namespace std;
int main ()
{
float r,cArea;
cout<<"Enter the radius of the circle: ";
cin>>r;
cArea=circarea(r);//Calling function
cout<<"The area of the circle is "<<cArea<<endl;
return 0;
}
float circarea(float radius)//Called function
{
const double pi=22/7.0;
float area=pi*radius*radius;
return area;
}
Comments
Post a Comment