Below is the code that I'm having trouble with. There is an error in the line avg += abs(num)
but I can't solve it. Error code:
error: call of overloaded 'abs(double&)' is ambigous
I realize that it is pretty basic but in the book I am using "C++: A Beginner's Guide (second edition)" by Herbert Schildt the code is identical in one of the examples used here:
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
double num, avg;
int x = 5;
int i;
avg = 0.0;
for (i = 1; i <= x; ++i){
cout << "Enter value " << i << ": ";
cin >> num;
avg += abs(num);
}
avg /= x;
cout<< endl;
cout << "The average is " << avg;
return 0;
}