Cpp - Write program to calculate the circumference and area of a circle

Requirements

Write a void type function called circle() to calculate the circumference and area of a circle.

The radius and two variables are passed to the function, which therefore has three parameters:

• references to double that the function uses to store the area
• and circumference of the circle.

Hint

Given a circle with radius r:

Area = pi * r * r and circumference = 2 * pi * r where p = 3.1415926536

Test the function circle() by outputting a table containing the radius, the circumference, and the area for the radii 0.5, 1.0, 1.5, . . ., 10.0.

Demo

```// circle.cpp
// Defines and calls the function circle().
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

// Prototype of circle():
void circle( const double& rad, double& um, double& fl);

const double startRadius =  0.5,     // Start, end and
endRadius   = 10.0,     // step width of
step        =  0.5;     // the table

int main() /*  ww  w . ja  va2  s  .c  o  m*/
{
<< setw(20) << "Circumference"
<< setw(20) << "Area\n" << endl;

cout << fixed;           // Floating point presentation
{
cout << setprecision(1)
<< setw(8)
<< setprecision(5)
<< setw(22)
<< circuit
<< setw(20)
<< plane <<endl;
}
return 0;
}
// Function circle(): Compute circumference and area.
void circle( const double& r, double& u, double& f)
{
const double pi = 3.1415926536;
u = 2 * pi * r;
f = pi * r * r;
}
```