write a c program to find the roots of a quadratic equation
ax2 + bx + c = 0
Answer Posted / rohit
#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 ? | 29 Yes | 21 No |
Post New Answer View All Answers
What is a macro?
Why does everyone say not to use gets?
What is far pointer in c?
How do you initialize pointer variables?
what are the advanced features of functions a) function declaration and prototypes b) calling functions by value or by reference c) recursion d) all the above
What is keyword with example?
What would be an example of a structure analogous to structure c?
what is the role you expect in software industry?
Explain do array subscripts always start with zero?
What are header files and explain what are its uses in c programming?
What is the meaning of && in c?
what is reason of your company position's in india no. 1.
Explain data types & how many data types supported by c?
Explain how can a program be made to print the name of a source file where an error occurs?
In C, What is the #line used for?