is there a way to make return count as a double instead of an int? thanks
is there a way to make return count as a double instead of an int? thanks
If you mean just any function then sure, declare it as
double func ( args );
If you are talking about main then you really don't want to return anything but an int.
-Prelude
My best code is written with the delete key.
well, here's my program:
#include <iostream.h>
#include <math.h>
int pyth(double one, double two);
int main()
{
double product, one, two;
product = pyth(one, two);
cout<<"Please enter two sides of a right triangle\n";
cin >>one>>two;
cout<<"the hypotenuse of the right triangle is "<<pyth(one, two)<< " long"<<endl;
return 0;
}
int pyth(double one, double two)//takes two number, squares them, adds them, then squares the product.
{
one = pow(one, 2);
two = pow(two, 2);
one = one + two;
two = sqrt(one);
return two; //can I have this return two as a double instead of an int?
}
as you can see, I need these numbers to be more precise then just an int. or if there's an easyer way to do this, thanks
just change the function type to double, not int...
ohh... well now I feel stupid, i tryed this and it gave me an error the first time, now it works.... thanks
yea, that's it... pretty straightforward