power and sqrt

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
#include <math.h>
using namespace std;

int main ()
{
int a = 5;
int b = 5;
int c;
a = sqrt(pow(a, 2) + pow(b, 2));
cout << c;
return 0;
}


why can't the first argument of pow() and sqrt() be an integer?
how can I make the script work?

Last edited on
The first argument must be a floating point type because that is how the functions are defined. You can use typecasting if you want to use an integer.

a = sqrt(pow((double)a, 2) + pow((double)b, 2));

On an unrelated note, I think you probably meant to assign a value to c, rather than to a, on line 10.
thanks, that did it :)
Topic archived. No new replies allowed.