-
What is a NaN ?
Code:
#include<stdio.h>
#include<conio.h>
#include<math.h>
main()
{
float a,b,c,d,k,x,y;
clrscr();
printf("Enetr the values of a,b,c=>");
scanf("%f %f %f",&a,&b,&c);
d=((b*b)-(4*a*c));
k=sqrt(d);
x= (-b+k)/(2*a);
y= (-b-k)/(2*a);
printf("The quadratic equation is x=%f and y=%f",x,y);
getch();
}
but after compiling the result is look like this .....why ....
wnter the values of a,b,c=>6 5 4
sqrt" DOMAIN error
The quadratic equation is x=+NAN and y=+NAN
its the program for to find out the result of the qudratic equation
with regards
anupam jamatia
-
That's it. I'm not helping ANYONE from now on if they aren't using CODE TAGS.
Go read the forum guidelines until you figure out how to use code tags. Do not pass GO, do not collect $200.
Quzah.
-
step 1) Use code tags
step 2) Use a meaningful subject. "Help me" says nothing. Why would you be creating a thread if you didn't need help?
EDIT: Ohhhhh, quzah beat me.
-
Have you actually tried solving [6x2 + 5x + 4 = 0] manually?
Other problems:
int main()
float x = {expression returning double}
-
> sqrt" DOMAIN error
It means don't do square roots on negative numbers. You need to check this before calling sqrt() and print appropriate answers.
-
NaN means Not a Number.
Have a nice day.