C program for calculating the roots of the quadratic equation - With Output

#include<stdio.h>
#include<conio.h>
#include<math.h>

void main()
{
int a=1,b=-10,c=34;

double q,m,h,x,y,f,g;
x=b*b-4*a*c;
printf(“Value of x is %1f\n”,x);
m=(double)x;

if(x>=0)
h=sqrt(m);
else{
                q=-m;
h=sqrt(m);
}

printf(“Square root is %1f\n”,n);

if(x>=0)
{
                x=(-b+h)/(z*a);
y=(-b-h)/(z*a);
printf(“\nAnswer is %1f and %1f\n”,x,y);

}

else
{
                f=b/(z*a);
                g=h/(z*a);
printf(“1st Root is %1f +i %1f \n”,f,g);
printf(“2nd Root is %1f -i %1f \n”,f,g);

}

getch();
}

OUTPUT :
Value of x is  -36
Value of y is  6
1st Root is 5+3i

2nd Root if 5-3i
Share on Google Plus

About Akash Manhas

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment