#include using namespace std; double bendingMoment(double x, double w, double l); void prettyPrintDouble(double x){ char tmp[21]; sprintf(tmp, "%10.2lf", x); cout << tmp; return; } int main(){ double x, w, l; double moment; cout << "Enter x (distance of w), w (weight), and l (beam length)" << endl; cin >> x >> w >> l; cout << "x = " << x << ", w = " << w << ", l = " << l << endl; moment = bendingMoment(x, w, l); cout << "The maximum bending moment for distance " << x << " is: " << moment << endl; moment = bendingMoment(0.5 * x, w, l);//2nd call with 1/2 x cout << "The maximum bending moment for distance " << x/2.0 << " is: " << moment << endl; return 0; } double bendingMoment(double x, double w, double l){ return x * w * (l - x) / l ; }