Hello
Thanks all for all the info, it helped me alot
now i have managed to get it to work. This is my final code
Code:
#include <stdio.h>
#include <math.h>
main ()
{
float a, b, c, root1, root2, Determinant;
float re, im;
char ANS;
More:
printf("\nThis program will compute the roots\n");
printf("of a quadratic equation of the form:\n");
printf("\tAx^2 + Bx + C");
printf("\nEnter A, B, and C with a space between each: ");
scanf("%f%f%f", &a, &b, &c);
Determinant = (b*b)-(4*a*c);
if (Determinant >= 0) {
root1 = (b - sqrt(Determinant))/(2*a);
root2 = (b + sqrt(Determinant))/(2*a);
printf("the roots are: x=%f and x=%f\n", root1, root2);
}
else {
re = -b/(2*a);
im = sqrt(-Determinant)/(2*a);
printf("the roots are: %f + %fi, and %f - %fi\n", re, im, re, im);
}
printf("\nIf 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;}
The Only thing that does not work iS this part
Code:
printf("\nIf 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");
The program does not wait for an answer from me, check the example bellow
Code:
root@o [/home]# ./a.out
This program will compute the roots
of a quadratic equation of the form:
Ax^2 + Bx + C
Enter A, B, and C with a space between each: 1 -5 4
the roots are: x=-4.000000 and x=-1.000000
If more data to be processed, type Y or y:
else type Q or q to quit:
**** End of the program ****
After giving the roots, it then prints out
If more data to be processed, type Y or y:
else type Q or q to quit:
and it doesn't wait for an answer and ends the program
Can someone help me with this last part
Thank you so much