can you help me please on how to use the squared in calculating the volume of a cone?? i am a beginner using C++... please do help me... thanks for all the help and god blesss.
#include <iostream>
usingnamespace std;
int main()
{
double Pi, v, r h;
cout << "Enter the Radius: ";
cin >> r;
cout << "Enter the Hieght: ";
cin >> h;
Pi=3.1416287;
v = (1.0/3.0) * Pi * (r*r) * h;
cout << "The Volume is: " <<v;
return 0;
}
You can't exclude the multiplication operator when performing multiplication.
You also had pi as an integer. Integers can't have fractions, so it needs to be a double. The same applies to the rest of the rest of your variables.
When you type numbers such as '1' and '3' they are automatically interpreted by the compiler as integers. To have the compiler understand them as doubles you have to write them as '1.0' and '3.0'.