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 radius = 0; //radius
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
cout <<"Please enter the Radius:" << endl;
cin >> radius; //user enter radius
r = pow (radius,2); //setting radius squared
h = pow (height,2); //setting height squared
slant = sqrt(r+h);
surface = pi * radius * (radius + sqrt(radius + slant));
volume = pi * (pow (radius,2)) * height/3;
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.
Alright thanks guys, I just went with the equation that was on my assignment. But it was different then the end result but this works now and I'm good to go. Thanks again.