I have reviewed multiple questions and answers for powers in C, or 4^2
. I have wrote it out in different ways and still can't it right. As of now I get the message:
/tmp/cc9yBiPo.o: In function `main':
Functions2.c:(.text+0x2b8): undefined reference to `pow'
collect2: error: ld returned 1 exit status.
Here is my code so far, like I said I have tried different peoples answers but I am more confused more than anything.
#include <stdio.h>
#include <math.h>
int main()
{
int choice;
int a, b, c;
float d;
do{
printf("\t Menu \n");
printf("1. Addition \n");
printf("2. Subtraction \n");
printf("3. Multiplication \n");
printf("4. Division \n");
printf("5. Modulo \n");
printf("6. Eponents \n");
printf("7. Exit \n");
printf("Please choose a menu selection: \n");
scanf("%d", &choice);
switch(choice)
{
case 1:
{
printf("Enter two numbers to add: \n");
scanf("%d%d", &a, &b);
c = a + b;
printf("The sum of the two numbers = %d \n", c);
}break;
case 2:
{
printf("Enter two numbers to subtract: \n");
scanf("%d&d", &a, &b);
c = a - b;
printf("The difference between the two number = %d \n", c);
}break;
case 3:
{
printf("Enter two numbers to multiply: \n");
scanf("%d%d", &a, &b);
c = a * b;
printf("The product of the two numbers = %d \n", c);
}break;
case 4:
{
printf("Enter two numbers to divide: \n");
scanf("%d%d", &a, &b);
d = (float) a/b;
printf("The quotient of the two numbers = %f \n", d);
}break;
case 5:
{
printf("Enter two numbers to get a modulo: \n");
scanf("%d%d", &a, &b);
c = a % b;
printf("The modulus of the two numbers = %d \n", c);
}break;
case 6:
{
printf("Enter a base: \n");
scanf("%d", &a);
printf("Enter an exponent: \n");
scanf("%d", &b);
c = pow(a, b);
printf("The exponent of the two numbers = %d", c);
}break;
case 7:
{
printf("Thank you, you will now exit.");
}break;
default:
printf("error \n");
}
} while (choice != 7);
return 0;
}