Hello,
I have this assigment to solve a quadratic equation, and the professor started us with the code..
He told us to use a,b,c and the Determinant and root1 and root2 and ANS, as the identifiers.
I tried finishing the code but keep getting errors or it wont work :( it's 4:55AM and am still trying to figure this out.
Just to let you know, am new to C programming
this is my final code that i did with no errors, however it doesn't seem to work quite well.
I hope to find help here as I have no other way to get help now.
Hope to get some help :) Thank youCode:#include <stdio.h>
#include <math.h>
const int TWO = 2;
int main()
{
int a,b,c, Determinant;
char ANS;
float root1;
float root2;
More: printf("Enter any three numbers: \n"); /*if more data to be processed */
scanf("%d %d %d ", &a, &b, &c);
Determinant = b*b-4*a*c;
root1 = -b + sqrt(Determinant) / 2 * a;
root2 = -b - sqrt(Determinant) / 2 * a;
if (Determinant < 0)
{
printf("You cannot have a negative number for the determinant. Non-real result\n");
}
else if (Determinant > 0)
{
printf("The Determinant equals to: 'Determinant'\n");
}
else
{
printf("root1 is equal to: 'root1'\n");
printf("root2 is equal to: 'root2'\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;}
