I know there's a million of these but I've been trying to work through it for a while and can't grasp it.
Basically have to make a calculator using functions for the basic mathematical operations.
Here's a small bit of my code, and I'm getting the same error for each of my switch statements so one answer should work for all.
My compile error is
int add(int, int); //addition function prototype
int subtract(int, int); //subtraction function prototype
int multiply(int, int); //multiply function prototype
int divide(int, int); //divide function prototype
int modulus(int, int); //modulus function prototype
int primeNumber(int); //test prime function prototype
int power(int, int); //exponent function prototype
int factorial(int); //factorial function prototype
int iSelection = 0; //Menu selection
int iFirstDigit = 0; //First digit entered
int iSecondDigit = 0; //Second digit entered
while (iSelection !=10)
printf("5 Modulus (Integers Only)\n");
printf("6 Test If Prime (Integers Only)\n");
printf("7 Factorial (Integers Only)\n");
printf("10 Exit Calculator\n");
/*Prompt User To Begin Interaction*/
printf("\nPlease select one of the options (1-7): ");
switch(iSelection) //begin switch
printf("\nPlease enter first digit to be added: ");
printf("\nPlease enter second digit to be added: ");
printf("\nThe sum of the two numbers is %d\n\n", add(iFirstDigit, iSecondDigit));
int add (int iFirstDigit, int iSecondDigit)
return iFirstDigit + iSecondDigit;
break; //end case 1
[Linker error]: undefined reference to 'add'
I'm assuming it has something to do with how I've defined/prototyped my function or something along those lines, but I can't spot the error myself.
I've looked through past threads of this nature and couldn't really find the solution. Any help at all is appreciated.