program to find the roots of a quardratic equation

Answer Posted / valli

/***********
quadratic equationis ax^2+bx+c=0
************8/
#include<math.h>
main()
{
int a,b,c,d,r1,r2;
printf("enter the values of a,b,c");
scanf("%d%d%d",&a,&b,&c)'
d=(b*b)-(4*a*c);
if(d<0)
{
printf("the roots are imaginary");
d=sqrt(-d);
printf("\nroots are %d+i%d",-b/(2*a),d/(2*a));
printf("\n%d-i%d",-b/(2*a),d/(2*a));
}
else
{
d=sqrt(d);
r1=(-b+d)/(2*a);
r2=(-b-d)/(2*a);
printf("the roots of the equation are %d %d ",r1,r2);
}
}

Is This Answer Correct ?    3 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is an endless loop?

796


What is define directive?

634


#include #include struct stu { int i; char j; }; union uni { int i; char j; }; void main() { int j,k; clrscr(); struct stu s; j=sizeof(s); printf("%d",j); union uni u; k=sizeof(u); printf("%d",k); getch(); } what is value of j and k.

5192


What is meant by keywords in c?

611


Write a program to reverse a string.

631






define string ?

662


what is different between auto and local static? why should we use local static?

638


What do you mean by recursion in c?

621


Dont ansi function prototypes render lint obsolete?

601


Which node is more powerful and can handle local information processing or graphics processing?

819


What is atoi and atof in c?

612


What is the best organizational structure?

637


Is it possible to have a function as a parameter in another function?

594


C program to find all possible outcomes of a dice?

1848


Why structure is used in c?

583