### Trying to make the program work for class, someone please point me in the right direction...

Please I just need some help finding out why the surface area is not coming out correctly. I just started the class a few weeks ago and i know it is probably something simple, but i have spent two days just going in circles trying everything i could think of. If someone could just maybe point me in the right direction. Thank you.
Also this is my first post so sorry if it is not done correctly.

#include <iostream>
#include <cmath>

using namespace std;

float height = 0; //height
float slant = 0; //slant height
double surface = 0; //surface area
double volume = 0; // volume
double pi = 3.14159; //pi
float r = 0; //radius squared
float h = 0; //height squared
float s = 0; //s = r^2 + h^2 for slant height

int main()
{

cout <<"Please input the Height:" << endl;
cin >> height; //user enter height

h = pow (height,2); //setting height squared

slant = sqrt(r+h);

volume = pi * (pow (radius,2)) * height/3;

cout << "Total Surface Area: " << surface << endl;

cout << "Volume: " << volume << endl;

system("pause");

return 0;

}
Last edited on
Sorry, the program is suppose to give both the surface area and volume of a cone given the height and radius. Forgot to mention that like a dumb.
Last edited on
Formula for surface area is incorrect.

Should be:

Everything else works. Although, you should get rid of system("PAUSE");.
Last edited on
Alright did it, works fine now thank you very much. I think that i just stared at it too long looking at everything but the obvious. Is there any particular reason why you recommended removing the pause? Because when I do the prgram runs though without stopping so I cant see my results. I am using visual studio 10, i dont know if that makes a difference.

thanks again
Last edited on
I believe if you just hit ctrl-f5 it will run without debugging and puase automatically. And if you just hit f5 thats where it disappears//
Last edited on