Simple Example of Reusability in C++

Suppose the following code is in a file called main.cpp:

#include <cmath>
#include <stdio.h>
using namespace std;int main(int argc, const char *argv[])
{
int x = 1, y = 2;
// of (1, 2)
int m1 = sqrt(x * x + y * y);
cout << m1 << "\n";
int x = 2, y = 3;
// magnitude of (2,3)
int m2 = sqrt(x * x + y * y);
cout << m2 << "\n";
}
#include <cmath>
#include…