write a c program to find the roots of a quadratic equation
ax2 + bx + c = 0

Answer Posted / lazy guyz

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,root;
float x1,x2;
printf("enter the roots a,b,c");
scanf("%d %d %d",&a,&b,&c);
if(a=0&&b=0)
printf("no solution");
else
if(a=0)
{
root=-c/b;
printf("root=%d",root);
}
else
if[(b*b-4*a*c)>0]
{
x1=[-b+sqrt (b*b-4*a*c)]/(2*a);
x2=[-b-sqrt (b*b-4*a*c)]/(2*a);
printf("the roots are x1=%f,x2=%f",x1,x2);
}
else
printf("it has imaginary roots");
getch();
}

Is This Answer Correct ?    1 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are variables and it what way is it different from constants?

795


How important is structure in life?

597


Explain how are portions of a program disabled in demo versions?

659


p*=(++q)++*--p when p=q=1 while(q<=6)

1272


What are different types of variables in c?

575






What is the difference between char array and char pointer?

535


What is the use of #include in c?

587


Tell me is null always defined as 0(zero)?

681


Are enumerations really portable?

600


Why is not a pointer null after calling free? How unsafe is it to use (assign, compare) a pointer value after it is been freed?

605


What is the advantage of an array over individual variables?

748


Which is better malloc or calloc?

658


What is the value of a[3] if integer a[] = {5,4,3,2,1}?

677


How can I automatically locate a programs configuration files in the same directory as the executable?

638


What is pragma in c?

636