I have a pretty simple program, it just asks the user for 3 values and then those are put into the quadratic formula (only using the -b + part of it, no -b -), and then it returns it and prints out the answer. However, I'm getting an error when compiling that I've never seen before.
"/tmp/cceIIpYr.o: In function `main':hw9.3A.c.text+0x84): undefined reference to `posQuadraticEquation'
collect2: ld returned 1 exit status"
hw9.3A.c is the name of the program. I'm compiling with this command:
gcc -o hw9.3A hw9.3A.c -lm
Here is the code:
Code:
#include <stdio.h>
#include <math.h>
double posQuadracticEquation(int a, int b, int c);
int main()
{
int a;
int b;
int c;
printf("Please enter an integer for 'a'.\n");
scanf("%d", &a);
printf("Please enter an integer for 'b'.\n");
scanf("%d", &b);
printf("Please enter an integer for 'c'.\n");
scanf("%d", &c);
double answer = posQuadraticEquation(a, b, c);
printf("With the values you entered, the positive portion of the Quadratic equation comes out to %lf\n", answer);
}
double posQuadracticEquation(int a, int b, int c)
{
double answer;
answer = -b/(2*a) + sqrt(b*b - 4*a*c) / (2*a);
return answer;
}
Any ideas?? Thanks!