#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int a,b,c,d;
float x1,x2,p,q;
clrscr();
printf("Enter 1st number, a = ");
scanf("%d",&a);
printf("Enter 2nd number, b = ");
scanf("%d",&b);
printf("Enter 3rd number, c = ");
scanf("%d",&c);
d=b*b-4*a*c;
if(d>0)
{
x1=(-b+sqrt(d))/(2*a);
x2=(-b-sqrt(d))/(2*a);
printf("\nX1= %.2f\nAnd\nX2= %.2f",x1,x2);
}
else if(d==0)
{
x1=x2=-b/(2*a);
printf("\nX1= %.2f\nAnd\nX2= %.2f",x1,x2);
}
else
{
p=-b/(2*a);
q=sqrt(-d)/(2*a);
printf("\nX1= %.2f+%.2f\nX2= %.2f-%.2f",p,q,p,q);
}
getch();
}
///////////////////////////////////////////////////////////////////////////
Copy & paste this code in your TC & run, then you will get output.......
If you have any problem please comment below.........