I know I didn't use pow, because I'm unsure of where I would put it. The function of this is to get it to tell me the volume of a cylinder, but I keep encountering an error, for someone reason when it reaches the formula, it has an error.
> Failed to declare correct value
> Wrong use of formula (( pi * radius^2 * height) = volume )
> Variable radius, height, volume wasn't declared
> Failed to produce the correct volume output
I'm thinking of changing the formula that I have currently to:
volume = PI*pow(radius,2)*height
Does anyone have a clue if that's the only thing that needs to be fixed?
EDIT: I've realized that my main error was using int instead of float. I'm switching that out and editing the code, but I'm still getting an error because of my cout. I need it to say:
"The volume of a cylinder with radius 8.67 and height 25.85 is 6104.47"
I'm gonna try working on it, but if anyone has any suggestions feel free to let me know.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
#include <iostream>
#include <cmath> // needed for pow
using namespace std;
const double PI = 3.14159;
int main()
{
float radius;
float height;
float volume;
// assigned values to variables
radius = 8.67;
height = 25.85;
volume = PI * radius^2 * height;
cout << volume;
endl;
return 0;
}
|