- #1
magnifik
- 360
- 0
i am trying to write a code that calculates the hypotenuse of a triangle... when i try to run it, i get a run time error. I'm not exactly sure what the problem is.
Code:
#include <iostream>
#include <cmath>
using namespace std;
void hypotenuse(double side1, double side2, double* result)
{
*result = sqrt(side1*side1 + side2*side2);
}
int main()
{
double* p;
hypotenuse(1.5, 2.0, p);
cout << "The hypotenuse is " << *p << endl;
}