[Solved] Final Answer for volume of a spherical tank not valid


Try this code, you should pass height and radius to the function:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

double calculatevolume(double,double,double);
double main() {
    double radius, height;
    double sum;    //for storing the radius of the reservoir given by the user
     //for storing the calculated volume of the water.

    printf("Please enter the Radius in meters first and then the Height in meters right after:\n"); //Displays the message on the screen

    scanf("%lf", &radius);
    printf("Value of r: %f\n", radius);


    scanf("%lf", &height);
    printf("Value of h: %f\n", , height);

    sum = calculatevolume(sum,radius,height);

    printf("For a reservoir of radius: %.2f m\nAnd a water depth: %.2f m\nThe water volume is: %.2f m^3\n",radius,height,sum);

    system("PAUSE");
}

double calculatevolume(double sum, double radius, double height) {
    sum = ((((3 * radius) - height)/3) * 3.14 * height * height);
    return sum;
}

You may also delete sum from the function header, it’s not necessary to pass it

5

solved Final Answer for volume of a spherical tank not valid