write a c program to find the roots of a quadratic equation
ax2 + bx + c = 0
Answer Posted / abc
#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 ? | 8 Yes | 11 No |
Post New Answer View All Answers
What is a buffer in c?
What are near, far and huge pointers?
How does pointer work in c?
What is the difference between #include
What is the best organizational structure?
How can I list all of the predefined identifiers?
Is c object oriented?
What is floating point constants?
Is c high or low level?
if (i = 0)printf ("True"); elseprintf("False"); Under what conditions will the above print out the string "True" a) Never b) Always c) When the value of i is 0 d) all of the above
Where are some collections of useful code fragments and examples?
What is the code in while loop that returns the output of given code?
Q.1 write aprogram to stack using linklist o insert 40 items? Q.2 write a program to implement circular queue with help of linklist?
What is the difference between class and object in c?
What are header files why are they important?