Error: expression cannot be used as a function?

Be careful, (x1-x2)^2 will not do an exponent of 2 here. See http://www.cplusplus.com/reference/cmath/pow/.

Second, you probably forgot a + in your expression:

int distanceFormula(int x1, int y1, int x2, int y2) {
    double d = sqrt(pow(x1-x2, 2) + pow(y1-y2, 2));
    return d;
}

Leave a Comment