Skip to content

Instantly share code, notes, and snippets.

@MitchellScottHenke
Forked from anonymous/formula.c
Last active February 3, 2016 16:58
Show Gist options
  • Save MitchellScottHenke/112b5f35fff56e1f77fd to your computer and use it in GitHub Desktop.
Save MitchellScottHenke/112b5f35fff56e1f77fd to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <math.h>
int main()
{
float a, b, c;
float pos, neg;
printf("Working on a Quadratic formula? Let me help!\nA=");
scanf("%f",&a);
printf("B=");
scanf("%f",&b);
printf("C=");
scanf("%f",&c);
printf("A=%f\nB=%f\nC=%f\n",a,b,c);
pos = ((-b + sqrt(pow(b,2)-(4*a*c)))/(2*a));
neg = ((-b - sqrt(pow(b,2)-(4*a*c)))/(2*a));
if (( pow (b, 2) - (4*a*c))<=0) printf("You have a non-real answer on your hand$
else printf("%f,%f\n",pos,neg);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment