#include <iostream>
#include <cmath>
usingnamespace std;
int main()
{
cout << "(c) 2012, bfields Byron Fields." << endl;
int num1;
int num2;
int sum;
int product;
int quotient;
int remainder;
float average;
int square;
int square2;
double squareroot;
double squareroot2;
cout << "Please enter the first integer: " << endl;
cin >> num1;
cout << "Please enter the second integer: " << endl;
cin >> num2;
sum = num1 + num2;
product = num1*num2;
quotient = num1/num2;
remainder = num1%num2;
average = sum/2;
square = num1*num1;
square2 = num2*num2;
squareroot = sqrt (num1);
squareroot2 = sqrt (num2);
cout << "The sum of the two integers is : " << sum << endl;
cout << "The product of the two integers is : " << product << endl;
cout << "The quotient of the two integers is : " << quotient << endl;
cout << "The remainder of the two integers is : " << remainder << endl;
cout << "The average of the two integers is : " << average << endl;
cout << "The square of the first integer is : " << square << endl;
cout << "The square of the second integer is : " << square2 << endl;
cout << "The square root of the first integer is : " << squareroot << endl;
cout << "The square root of the second integer is : " << squareroot2 << endl;
return 0;
}
There are several functions sqrt that have parameters of different types. But among these functions no one has the parameter declared as having type int. So the compiler does not know which existent function to prefer for argument of type int.
I suggest to cast the argument to double as, for example
Try casting to one of those three types like the compiler suggests. squareroot = sqrt ( static_cast<double>(num1));
C++ does allow for implicit type casting between double and int, float and int, and long double and int. However, the compiler doesn't know what into cast the int to in this situation. It can pick any of three different things which is ambiguous to the compiler.
See typecasting here for other ways to do this: http://cplusplus.com/doc/tutorial/typecasting/