#include #include #include using namespace std; // function prototypes go here float calc_square(float); float calc_distance (float, float); //**************************************************** // main program goes here int main() { int ans; float dist; dist = calc_distance(3.0, 4.0); cout << "main program says " << dist << endl; dist = calc_distance(6.0, 8.0); cout << "main program says " << dist << endl; return 0; } //**************************************************** // functions go here float calc_square(float a) { float b = 99.; // note never used cout << " entering calc_square: a = " << a << " b = " << b << endl; a = a * a; // clobbering input--NOT recommended style cout << " leaving calc_square: a = " << a << " b = " << b << endl; return (a); } float calc_distance(float a, float b) { float c; // note uninitialized cout << " at entrance to calc_distance: a = " << a << " b = " << b << " c = " << c << endl; c = sqrt(calc_square(a) + calc_square(b)); cout << " calc_distance: dist. from " << a << " to " << b << " is " << c << endl; cout << " at exit from calc_distance: a = " << a << " b = " << b << " c = " << c << endl; return (c); }