#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int a,b,c,d;
float det,x,y;
printf("\n\n For the following quadratic eqation ,\n\n\t\t a*x*x + b*x + c = 0 \n\n Enter the variables a , b, and c : ");
scanf("%d%d%d",&a,&b,&c);
printf("\n\n & Now, the quadratic eqation is : \n\n\t\t %d*x*x + %d*x + %d = 0 ",a,b,c);
d = b*b - 4*a*c;
if(d==0)
{
x= (float) -1*b/2*a;
printf("\n\n The roots of the abv. equations are real and equal .");
printf("\n\n The root is : %f",x );
}
else if(d>0)
{
det = sqrt(d);
x= (float) (-1*b-det)/2*a;
y= (float) (-1*b+det)/2*a;
printf("\n\n The roots of the abv. equations are real and distinct .");
printf("\n\n The root are : %f and %f",x,y);
}
else
{
det=sqrt(-1*d);
x= (float) (-1*b)/2*a;
printf("\n\n The roots of the abv. equations are imaginary .");
printf("\n\n The root are : %f + %fi and %f - %fi",x,det,x,det);
}
getch();
}
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int a,b,c,d;
float det,x,y;
printf("\n\n For the following quadratic eqation ,\n\n\t\t a*x*x + b*x + c = 0 \n\n Enter the variables a , b, and c : ");
scanf("%d%d%d",&a,&b,&c);
printf("\n\n & Now, the quadratic eqation is : \n\n\t\t %d*x*x + %d*x + %d = 0 ",a,b,c);
d = b*b - 4*a*c;
if(d==0)
{
x= (float) -1*b/2*a;
printf("\n\n The roots of the abv. equations are real and equal .");
printf("\n\n The root is : %f",x );
}
else if(d>0)
{
det = sqrt(d);
x= (float) (-1*b-det)/2*a;
y= (float) (-1*b+det)/2*a;
printf("\n\n The roots of the abv. equations are real and distinct .");
printf("\n\n The root are : %f and %f",x,y);
}
else
{
det=sqrt(-1*d);
x= (float) (-1*b)/2*a;
printf("\n\n The roots of the abv. equations are imaginary .");
printf("\n\n The root are : %f + %fi and %f - %fi",x,det,x,det);
}
getch();
}
No comments:
Post a Comment