QUADRATIC EQUATION (using if else loop)

QUADRATIC EQUATION (using if else loop)

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int D,a,b,c,real,x,y,z;
clrscr();
printf("enter any number a,b,c");
scanf("%d%d%d",&a,&b,&c);
D=(b*b)-(4*a*c);
x=sqrt(D);
if(D>0)
{
printf("roots r real");
y=(-b+x)/2*a;
z=(-b-x)/2*a;
printf("%d%d",y,z);
}
else if(D==0)
{
printf("roots r equal n real");
y=(-b+D)/2*a;
z=(-b-x)/2*a;
printf("%d%d",y,z);
}
else
printf("imaginary");
getch();
}

NOTE- WE USE else if,  WHEN THERE IS MORE THAN ONE IF STATEMENT.

No comments:

Post a Comment