Skip to content

Instantly share code, notes, and snippets.

@programmingfaster0226
Created January 18, 2018 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save programmingfaster0226/18a2f31423a435ae9d4744f161bf6364 to your computer and use it in GitHub Desktop.
Save programmingfaster0226/18a2f31423a435ae9d4744f161bf6364 to your computer and use it in GitHub Desktop.
/*program to read the values for coefficients a,b and c of a quadratic equation ax²+bx+c=0*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int a,b,c,d;
float r1,r2;
printf("enter a ,b,c:");
scanf("%d%d%d",&a,&b,&c);
d=(b*b)-(4*a*c);\
if (d>0)
{
r1=(-b + sqrt(d))/(2*a);
printf("answer=%f",r1);
r2=(-b - sqrt(d))/(2*a);
printf("answer=%f",r2);
}
else
printf("the root is imaginary:");
getch();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment