Need Immediate help, cannot figure out what is cusing this error

Joined
Oct 22, 2008
Messages
1
Reaction score
0
Need Immediate help, cannot figure out what is causing this error

Here is my program:

/***
program: assignment5.c

Name: Nicholas Cucuzza
Date: 10/21/08

Description: This program reads 3 values at a time from the input file.
First it displays the quadratic function with these values.
Then it plugs those 3 values in to the discriminant function
first to make sure that the value is not a negative number, if
it is it will display an error. If it goes through the discriminant
and has a positive value it will go on to calculate the quadratic
formula and then display the roots in the output file.
***/

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

double discriminant(double a, double b, double c);

double quadratic1(double a1, double b1, double c1);

double quadratic2(double a2, double b2, double c2);

int main(void)
{
FILE *inp,
*outp;

int input_status;
double one,
two,
three,
quad1,
quad2;

inp = fopen("coeff.dat", "r");
outp = fopen("coeff.out", "w");

while(input_status != EOF){
input_status = fscanf(inp,"%lf%lf%lf", &one, &two, &three);
fprintf(outp,"For the equation %5.2f(x * x) + %5.2fx + %5.2f = 0 \n",
one, two, three);
if(discriminant(one, two, three) < 0) {
fprintf(outp,"No real roots\n");
} else {
quad1 = quadratic1(one, two, three);
quad2 = quadratic2(one, two, three);
fprintf(outp,"The roots are %5.2f and %5.2f \n",
quad1, quad2);
}
}
fclose(inp);
fclose(outp);
return(0);
}

double discriminant(double a, double b, double c)
{
return(pow(b, 2.0) - (4.0 * (a * c)));
}

double quadratic1(double a1, double b1, double c1)
{
return(-b1 + (sqrt(pow(b1, 2.0) - (4.0 * (a1 * c1))))/ (2 * a1));
}

double quadratic2(double a2, double b2, double c2)
{
return(-b2 - (sqrt(pow(b2, 2.0) - (4.0 * (a2 * c2))))/ (2 * a2));
}

And here is the error message I get when I try compiling it:

Undefined first referenced
symbol in file
sqrt /var/tmp//cc9PQNNs.o
ld: fatal: Symbol referencing errors. No output written to a.out
collect2: ld returned 1 exit status

I'm extremely confused, what can be causing this?
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top