Mga bro, naa miy assignment sa among IT class. One of the problems was to solve for a quadratic formula. I already have made a C program out of it pero it doesn't seem to give the desired output. T_T
Mao ni akong program:
Code:
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
int a, b, c;
long double rt1, rt2, div, key;
clrscr();
printf("Enter three integers separated by a space: ");
scanf("%d %d %d", &a, &b, &c);
div=b*b-(4*a*c);
if (a==0)
printf("The given constants does not represent a quadratic equation");
else if (div>=0)
{
key=sqrt(div);
rt1=((-1*b)+key)/(2*a);
rt2=((-1*b)-key)/(2*a);
printf("Quadratic Root one: %f", rt1);
printf("\nQuadratic Root two: %f", rt2);
}
else
printf("Constants cannot represent the quadratic formula");
getch();
}
Any help is greatly appreciated!
Thanks mga bro!