Question: A serious problem lies in the Compute volume function. Additionally, the programmer was confused about parameters and local variables. Make this function work correctly, and
A serious problem lies in the Compute volume function. Additionally, the programmer was confused about parameters and local variables. Make this function work correctly, and also improve its use of parameters, changing main as necessary. # include # define Pi E 3.14 float Compute Volume (float r, float h, float ans, float r2); int main () { float radius, height, ans, r2 printf ("radius :"); scant ("%g", &radius): printf ("Height : "); scant("% g" &height): ans = Compute Volume (radius, height, ans, r2); printf ("Volume:%g", ans); return (); } float Compute Volume (float r, float h, float ans, float r2) { r2 = r*r; ans = (1/3) * PIE * r2*h; return ans; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
