Program to cheque roots are real,imaginary or equal in C-language
#include<stdio.h>
int main()
{
int a,b,c;
printf("Enter the coefficient of x^2\n");
scanf("%d",&a);
printf("Enter the coefficient of x\n");
scanf("%d",&b);
printf("Enter the constant term\n");
scanf("%d",&c);
if(((b*b)-(4*a*c))==0)
{
printf("Roots are real and equal");
}
else if(((b*b)-(4*a*c))>0)
{
printf("Roots are real and distinct");
}
else
{
printf("Roots are imaginary");
}
}
OUTPUT
Enter the coefficient of x^2
1
Enter the coefficient of x
2
Enter the constant term
4
Comments
Post a Comment