True Roughly
True Roughly

Reputation: 11

division function variable definition quesiton

I have a question about the div function below. I keep getting a compile error that says div function has to be re-defined because div can't be defined. It has something to do with variable that div takes but I have no idea why this is not working.

double add(double a, double b);
double sub(double a, double b);
double mult(double a, double b);
double div(double a, double b);

int main() {
    double a;
    double b;

    printf("enter in1 value \n");
    scanf_s("%lf", &a);
    printf("enter in2 value \n");
    scanf_s("%lf", &b);

    printf("Addition of a and b is %lf\n", add(a, b));
    printf("Subtraction of a and b is %lf\n", sub(a, b));
    printf("Multiplication of a and b is %lf\n", mult(a, b));
    printf("Division of a and b is %lf\n", div(a, b));    
}

double add(double a, double b) { return a + b; }
double sub(double a, double b) { return a - b; }
double mult(double a, double b){ return a * b; }
double div(double a, double b) { return a / b; }

Upvotes: 0

Views: 49

Answers (1)

Shawn
Shawn

Reputation: 52549

C has a standard function named div(), declared in <stdlib.h>. You need to use a different name for your function.

Upvotes: 3

Related Questions