#include <stdio.h>
#include <math.h>
// this function calculates the volume of a Cylinder
int main(void)
{
int r; // radius
int h; // height
double M_PI; // pi
int pOne = pow (r, 2);
// get user input of radius and height
printf ("Enter your radius: ");
scanf ("%f", &r);
printf ("Enter your height: ");
scanf ("%f", &h);
// calculate volume
volumeCylinder = pOne * M_PI * h;
// output volume result
printf ("The Volume of the Cylinder is: %lf\n", volumeCylinder);
return 0;
}
Sample Output:
~Enter your radius: 3
~Enter your height: 2
~The Volume of the Cylinder is: 0.000000
~
The program compiles and runs but no matter what kind of printf format I do (double, float, int) I always get 0.0000..., -0.000..., or some really large number.
I don't know what could be wrong. Can anybody please help me with this? It is driving me insane.