/*****************<soeasyprograms.blogspot.in>******************/
/*Program to find roots of a quadratic equation*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int A,B,C;
float disc,deno,x1,x2;
clrscr();
printf("ENTER THE VALUES OF A,B,C \n");
scanf("%d%d%d",&A,&B,&C);
disc = (B*B)-(4*A*C);
deno = 2*A;
if(disc > 0)
{
printf(" THE ROOTS ARE REAL ROOTS");
x1 = (-B/deno)+(sqrt(disc)/deno);
x2 = (-B/deno)-(sqrt(disc)/deno);
printf("\n THE ROOTS ARE: %f and %f ",x1,x2);
}
else if(disc == 0)
{
printf(" THE ROOTS ARE REPEATED ROOTS");
x1 = -B/deno;
printf("\n THE ROOTs ARE: %f and %f ",x1,x1);
}
else
printf(" THE ROOTS ARE IMAGINARY ROOTS");
getch();
}
/*End of program*/
/*****************<soeasyprograms.blogspot.in>******************/
No comments:
Post a Comment