I've written a simple program in C++ to explain how the circumference of the circle being equal to 2*r*pi follows from the Pythagorean Theorem and numeric integration:

`#include <cmath>`

#include <iostream>

#include <vector>

int main() {

using namespace std;

cout << "How many middle-points do you want on the unit circle?" << endl;

int number_of_middle_points;

cin >> number_of_middle_points;

if (number_of_middle_points < 0) {

cerr << "Error!" << endl;

return 1;

}

cout << "The points on the unit circle are:" << endl;

vector<pair<double, double>> middle_points;

middle_points.push_back(make_pair(-1, 0));

cout << "(-1, 0)" << endl;

for (int i = 1; i <= number_of_middle_points; i++) {

double x = -1 + 2. * i / (number_of_middle_points + 1);

double y = sqrt(1 - x * x); // This follows from the Pythagorean Theorem and

// the distance from the center to any point on

// the unit circle always being 1.

cout << "(" << x << ", " << y << ")" << endl;

middle_points.push_back(make_pair(x, y));

}

cout << "(1, 0)" << endl;

middle_points.push_back(make_pair(1, 0));

double approximation_of_pi = 0;

for (int i = 1; i < middle_points.size(); i++) {

double distance =

hypot(middle_points[i].first - middle_points[i - 1].first,

middle_points[i].second - middle_points[i - 1].second);

cout << "The distance between (" << middle_points[i - 1].first << ", "

<< middle_points[i - 1].second << ") and (" << middle_points[i].first

<< ", " << middle_points[i].second << ") is " << distance << endl;

approximation_of_pi += distance;

}

cout << "The sum of the distances is " << approximation_of_pi

<< ", which is close to but less than pi." << endl;

}

Here is an example session of it, it prints inter-results which you can check yourself:

`How many middle-points do you want on the unit circle?`

10

The points on the unit circle are:

(-1, 0)

(-0.818182, 0.57496)

(-0.636364, 0.771389)

(-0.454545, 0.890724)

(-0.272727, 0.962091)

(-0.0909091, 0.995859)

(0.0909091, 0.995859)

(0.272727, 0.962091)

(0.454545, 0.890724)

(0.636364, 0.771389)

(0.818182, 0.57496)

(1, 0)

The distance between (-1, 0) and (-0.818182, 0.57496) is 0.603023

The distance between (-0.818182, 0.57496) and (-0.636364, 0.771389) is 0.267661

The distance between (-0.636364, 0.771389) and (-0.454545, 0.890724) is 0.217482

The distance between (-0.454545, 0.890724) and (-0.272727, 0.962091) is 0.195323

The distance between (-0.272727, 0.962091) and (-0.0909091, 0.995859) is 0.184927

The distance between (-0.0909091, 0.995859) and (0.0909091, 0.995859) is 0.181818

The distance between (0.0909091, 0.995859) and (0.272727, 0.962091) is 0.184927

The distance between (0.272727, 0.962091) and (0.454545, 0.890724) is 0.195323

The distance between (0.454545, 0.890724) and (0.636364, 0.771389) is 0.217482

The distance between (0.636364, 0.771389) and (0.818182, 0.57496) is 0.267661

The distance between (0.818182, 0.57496) and (1, 0) is 0.603023

The sum of the distances is 3.11865, which is close to but less than pi.