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
What are variables and it what way is it different from constants?
How important is structure in life?
Explain how are portions of a program disabled in demo versions?
p*=(++q)++*--p when p=q=1 while(q<=6)
What are different types of variables in c?
What is the difference between char array and char pointer?
What is the use of #include in c?
Tell me is null always defined as 0(zero)?
Are enumerations really portable?
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?
What is the advantage of an array over individual variables?
Which is better malloc or calloc?
What is the value of a[3] if integer a[] = {5,4,3,2,1}?
How can I automatically locate a programs configuration files in the same directory as the executable?
What is pragma in c?