i have written a code to find the roots of a quadratic equation using functions passing 2 pointer parameters.
when i compile the code i get this error
/tmp/cclQJtoD.o: In function `quad':
ex11-2.c:(.text+0x14d): undefined reference to `sqrt'
ex11-2.c:(.text+0x17b): undefined reference to `sqrt'
collect2: ld returned 1 exit status
please tell why do i see this error, i have included the header file "math.h" also.
Your quad function is returning a pointer (array) that is allocated on the stack inside quad. You can't do that.
Problem #2 is that you are printing out r and r+1, both of which are pointers to floats, not floats.
Problem #3 is that you are using floats which have less precision than doubles.
Problem #4 is that floating point arithmetic is black magic due to roundoff error.
I refer you to http://docs.sun.com/source/806-3568/ncg_goldberg.html which has
an excellent treatise on the best way to reduce floating point roundoff error in the quadratic formula.