# Thread: Volume of a cylinder: volume_cylinder = PI * radius2 * height

1. ## Volume of a cylinder: volume_cylinder = PI * radius2 * height

Code:
```/*Name:Brian
Date:9/3/17
First Project

*/

#include <stdio.h>

int main(void) {
double mass=0.00, acceleeration=0.00 , force=0.00,radius=0.0, height=0.0, volume=0.0, pi=3.14 ;

//1. Promot the user for the mass and acceleration
printf("Please enter the mass and accleeration <both floating-points values> for use in Newton's Second Law ");

//2. Get the mass and accleration from the user
scanf("%lf %lf", &mass, &acceleeration);

//printf("%d %d\n", mass, acceleeration);

//3. Mutliply the mass with accelleration
force = mass * acceleeration;

//4. Put it together
printf("Newton's Second Law: force = mass*acceleeration= %lf\n",force);

//2.1 Promot the user for the radius and height
printf("Please enter the radius and the height <both floating-point values> for use in a volume of a cylinder equation ");

//2.2 Get the radius and height from the user

//2.3 Get the value of the volume

//2.4 Put it together
printf("Volume of a cylinder: volume_cylinder = PI* radius^2*height= %lf\n", volume);

}```

Whenever i run the volume part of my code, i get 0.000 as my answer. I'm not sure what i did wrong. Any help is welcome, thanks. 2. Try dividing decimals instead of integers to get an answer. In C, there is a difference: 1 / 3 in integer division is 0. 3. ## Thanks Originally Posted by whiteflags Try dividing decimals instead of integers to get an answer. In C, there is a difference: 1 / 3 in integer division is 0.
Yea it worked, but the volume of a cylinder does not include .333333. But if it did, inputing .3333333 instead of (1/3) works, so thanks. Popular pages Recent additions height, homework, mass, user, volume 