Hi
Im very new to programming and i just need a little help
This is a little (very basic) app that solves quadratic equations
I want to add a bit on to it, but my basic skills are letting me down. Where it says "No Solution", i would like to add a bit where it says "No solution, would you like another go?" then if they say yes, it goes to the beginning and if they say no, the program exits.
I hope i explained it well enough Thanks
Im very new to programming and i just need a little help
This is a little (very basic) app that solves quadratic equations
I want to add a bit on to it, but my basic skills are letting me down. Where it says "No Solution", i would like to add a bit where it says "No solution, would you like another go?" then if they say yes, it goes to the beginning and if they say no, the program exits.
I hope i explained it well enough Thanks
#include <stdio.h>
#include <math.h>
int main()
{
//declare variables
double a,b,c,x1,x2,d;
//read inputs
printf("What number represents a? "); scanf("%lf",&a);
printf("What number represents b? "); scanf("%lf",&b);
printf("What number represents c? "); scanf("%lf",&c);
//calculate x1,x2
d=b*b-4*a*c;
if(d>=0)
{
x1=(-b+sqrt(d))/(2*a);
x2=(-b-sqrt(d))/(2*a);
printf("x1=%d\n",x1);
printf("x2=%d\n",x2);
}
else
{
printf("No solution\n");
}
}