Create function to calculate area of circle - C++ Function

C++ examples for Function:Function Parameter

Description

Create function to calculate area of circle

Demo Code

#include <iostream>
using namespace std;
float circarea(float radius);
int main()/*from w w w  .j a va  2  s .c  o  m*/
{
   double rad;
   cout << "\nEnter radius of circle: ";
   cin >> rad;
   cout << "Area is " << circarea(rad) << endl;
   return 0;
}
float circarea(float r)
{
   const float PI = 3.14159F;
   return r * r * PI;
}

Result


Related Tutorials