Thank you all for the help
after I did some modification i got this final code
Code:
#include <stdio.h>
#include <math.h>
const int TWO = 2;
int main()
{
int a,b,c;
float Determinant;
char ANS;
double root1;
double root2;
More:
printf("Please enter 3 integers separated by a space:\n");
printf("These numbers will be calculated as A, B and C in a quadratic equation and the output will be the two calculated roots.\n");
scanf("%d,%d,%d,",&a,&b,&c);
if ((a==0) && (b==0))
{
printf ("Since 0 was your input for A and B, the equation has no solution.\n");
}
else
{
Determinant = (b*b)-(4*a*c);
}
if (Determinant > 0)
{
printf("The Determinant equals to: %f\n", Determinant);
root1=(-b+sqrt(Determinant))/(2*a);
root2=(-b-sqrt(Determinant))/(2*a);
printf("The two roots are %d and %d\n",root1, root2);
}
else if (Determinant < 0)
{
printf ("There are no real roots.\n");
}
printf("If more data to be processed, type Y or y: \n");
printf("else type Q or q to quit: \n");
scanf("%c",&ANS);
if (ANS == 'Y' || ANS == 'y')
goto More;
else
{
printf("**** End of the program **** \n");
}
return 0;}
Now I did some examples but still I dont get to type the answer for the last two printf statements, and I keep getting ( there are no real roots )
these are some examples i did
Code:
Please enter 3 integers separated by a space:
These numbers will be calculated as A, B and C in a quadratic equation and the output will be the two calculated roots.
1 8 4
There are no real roots.
If more data to be processed, type Y or y:
else type Q or q to quit:
**** End of the program ****
Please enter 3 integers separated by a space:
These numbers will be calculated as A, B and C in a quadratic equation and the output will be the two calculated roots.
0 0 0
Since 0 was your input for A and B, the equation has no solution.
The Determinant equals to: 0.000000
The two roots are 0 and 2146435072
If more data to be processed, type Y or y:
else type Q or q to quit:
**** End of the program ****
this is driving me crazy ,, but i feel so close to finish it ..
also the scanf for the last part doesn't seem to work and doesn't go back to More
any help on what to do , or if i have some mistakes in the code
thank you all again