#include <stdio.h>
#include <math.h>
int main(){
float a;
float b;
float c;
printf("this program will solve you any equation from this type: ax^2+bx+c=0.\n");
printf("First of all enter a, b and c:\n");
printf("a:"); scanf("%f", &a);
printf("b:"); scanf("%f", &b);
printf("c:"); scanf("%f", &c);
if (a==0){
printf("now your equation is:\n");
printf("%.1fx+", b); printf("%.1f=0\n", c);
float x3 = -c/b;
printf("the solution for this equation is: %f", x3);
}
else{
printf("now your equation is:\n");
printf("%.1fx^2+", a); printf("%.1fx+", b); printf("%.1f=0\n", c);
float d = b*b-4*a*c;
printf("yy");
float x1;
float x2;
if(d > 0){
printf("delta is greater than 0! the equation have 2 solutions!\n");
float x1 = (-b+sqrt(d))/(2*a);
float x2 = (-b-sqrt(d))/(2*a);
printf("the first solution is: %.2f\n", x1);
printf("the second solution is: %.2f\n", x2);
}
else if (d == 0)
{
printf("delta equals 0 the equation have a doubled solution!\n");
float x1 = -b / 2*a;
printf("the doubled solution is: %f", x1);
}
else if (d < 0)
{
printf("delta is less than 0! the equation have no solutions in R :(");
}
}
return 0;
}
it works perfectly when i run it in vs code terminal thing but when i open the batch file it exits after entering the value of c
edit: the code i posted is only the start and the remaining code is 100% correct because i test it many times in terminal in vs code and it works