can't make square root function work

I'm in intro to C++ at my school, and am trying to make a program to calculate the hypotenuse of a right triangle. what is wrong with my coding?

#include <iostream.h>
#include <math.h>
int main()
double a, b, c;
cout <<"what is a?";
cin >> a;
cout <<"what is b?";
cin >> b;
c = sqrt (a * a + b * b) << '\n';
cout << c;
system ("PAUSE");
return 0;

anything helps
Last edited on
You will have to use the using namespace std; or prefix each cout/cin with std:: to get the compiler to recognize them.

the problem is in the line c=sqrt(a*a+b*b) << '\n'

the sqrt function cannot be used in such a way. you need to put the code before << on its own statement and use cout with the << to output the new line.

Topic archived. No new replies allowed.