You probably have another error message before that line:
undefined reference to `main'
In order to build an executable program in C++ you need to declare the main
function.
It is the main entry point to your program. Try this:
#include <iostream>
using namespace std;
double convert(int knots)
{
double mile;
mile = double(knots) * 6076 / 5280 / 60;
return mile;
}
int main(void) {
double miles = convert(10); // Use convert function
cout << "Miles: " << miles << endl; // Print result
return 0;
}
Note: You need at least one value to be explicitly cast to a double
in order to use that operator/
version. See Why does dividing two int not yield the right value when assigned to double?.
And remember the associativity rules. An expression is resolved from left to right, so you only need to explicitly cast the first (or the second) operand in a multiple division/multiplication expression.