here's the code
Code:
/*QUADRATIC FORMULA*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
main()
{
float a;
float b;
float c;
float d;
float e;
float f;
float x1;
float x2;
int choice;
float sqr;
char bool='Y';
while (bool=='y'||bool=='Y')
{
a=0;
b=0;//setting variables to 0
c=0;
d=0;
e=0;
f=0;
x1=0;
x2=0;
printf ("A=\n");
scanf ("%f",&a);
printf ("B=\n");
scanf ("%f",&b);
printf ("C=\n");
scanf ("%f",&c);
if (a==0 && b==0 && c==0)
choice=1;
else if (a==0 && b==0 && c!=0)
choice=2;
else if (a==0 && b!=0 && c!=0)
choice=3;
else if (pow(b,2)-4*a*c < 0)
choice=4;
else if (pow(b,2)-4*a*c == 0)
choice=5;
else
choice=6;
switch (choice)
{
case 1:
printf ("\n\n\t\t\tInfinite Solution der...");
break;
case 2:
printf ("\n\n\t\t\ttTHATS ONLY ONE NUMBER!!");
break;
case 3:
x1=-b/a;
printf ("\n\n\t\t\tSingle Root\n\t\t\tx= %4.2f", x1);
break;
case 4:
d=sqrt(pow(b,2)-4*a*c);
e=-b/(2*a);
f=d/(2*a);
printf ("\n\n\t\t\t\tTwo complex roots\n\n\t\t\t x1 = %4.2f + %4.2fi", e, f);
printf ("\n\n\t\t\t x2 = %4.2f - %4.2fi", e, f);
break;
case 5:
printf ("\n\n\t\t\tRepeated Root\n\t\t\t");
case 6:
x1=(-b+sqrt(pow(b,2)-4*a*c))/(2*a);
x2=(-b-sqrt(pow(b,2)-4*a*c))/(2*a);
printf ("x1=%f x2=%f",x1,x2);
break;
}
bool='N';
printf ("\nagain? press Y for yes, or N for no\n");
scanf ("%s", &bool);
while (bool!='y'&&bool!='n'&&bool!='Y'&&bool!='N')
{
printf ("\nY for yes, or N for no\n");
scanf ("%s", &bool);
}
printf ("\nthankyou\n");
if (bool=='n'||bool=='N')
{
// something to exit program
}
}
}
ending main() exits the program, but it doesn't close the window