I am working on my first C++ program for school. For some reason I am getting the following error when I try to compile it:
`truncate\' undeclared (first use
You need forward declaration before your main
:
double truncate(double d);
double round(double d);
You could just define your functions before main, that will solve the problem too:
#include
#include
using namespace std;
#define CENTIMETERS_IN_INCH 2.54
#define POUNDS_IN_KILOGRAM 2.2
// round result
double round(double d) {
return floor(d + 0.5);
}
// round and truncate to 1 decimal place
double truncate(double d) {
return round(double * 10) / 10;
}
int main() {
...
}