-4

The problem is: - Draw a flowchart that computes and print the volume of a sphere. - Use the formula: V=r^3 * pi * 4/3. (Where pi is approximately equivalent to 3.1416).

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

int main()

{

    float radius, volume;


    printf("Enter the volume of sphere: ");
    scanf("%f", &radius);
    volume = (4.0/3) * (3.1416) * radius * radius * radius;
    printf("Volume of a sphere is : %.3f", volume);

    return 0;
 }
luxtrscnd
  • 3
  • 1

1 Answers1

0

If you're gonna include math.h, might as well use it.

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

int main()

{

    float radius, volume;


    printf("Enter the volume of sphere: ");
    scanf("%f", &radius);
    volume = (4.0/3.0) * (M_PI) * pow(radius, 3);
    printf("Volume of a sphere is : %.3f", volume);

    return 0;
}
Aditya Banerjee
  • 352
  • 1
  • 3
  • 12