Skip to content

Instantly share code, notes, and snippets.

@sazid
Created February 26, 2017 18:00
Show Gist options
  • Save sazid/b9f94b56674c69682df7f7bad8ad7165 to your computer and use it in GitHub Desktop.
Save sazid/b9f94b56674c69682df7f7bad8ad7165 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <math.h>
int main()
{
int a, b, c;
double root_1, root_2;
printf("For ax^2 + bx + c = 0 ; give the following inputs.\n");
printf("Input a: ");
scanf("%d", &a);
printf("Input b: ");
scanf("%d", &b);
printf("Input c: ");
scanf("%d", &c);
root_1 = (-b + sqrt(b*b - 4 * a *c)) / 2 * a;
root_2 = (-b - sqrt(b*b - 4 * a * c)) / 2 * a;
printf("The two roots are: %.02f and %.02f\n", root_1, root_2);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment