Circumference Of Circle C++ Example Program


When a circle's diameter is 1, its circumference is π. When a circle's radius is 1—called a unit circle—its circumference is 2π.


The circumference of a circle is written

π = C / d

Or, equivalently, as the ratio of the circumference to twice the radius. The above formula can be rearranged to solve for the circumference:

C = π * d = 2π * r


r = Radius
π = ~3.14

Circumference Of Circle Example Program

/*## Circumference Of Circle In C++*/
/*## Calculation C++ Programs, Datatype C++ Programs, Basic C++ Programs*/

#include <iostream>

using namespace std;

float PI = 3.14;

int main() {
   // Declare Variables
   float radius, ci;

   cout << "Simple C++ Program : Circumference Of Circle\n";
   cout << "\nEnter the radius of Circle : ";

   ci = 2 * PI * radius;

   cout << "\nCircumference of Circle : " << ci;

   return (0);

Sample Output

Simple C++ Program : Circumference Of Circle

Enter the radius of Circle : 5

Circumference of Circle : 31.4