write a c program to find the roots of a quadratic equation
ax2 + bx + c = 0
Answer Posted / shravya poojitha
#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 ? | 142 Yes | 49 No |
Post New Answer View All Answers
How can I do serial ("comm") port I/O?
What is null pointer constant?
disply the following menu 1.Disply 2.Copy 3.Append; as per the menu do the file operations 4.Exit
what are the 10 different models of writing an addition program in C language?
Is there anything like an ifdef for typedefs?
What is actual argument?
Explain threaded binary trees?
What is strcpy() function?
Describe the order of precedence with regards to operators in C.
What's the total generic pointer type?
What is a class c rental property?
hi... can anyone help me to make a two-dimensinal arrays in finding the sum of two elements plzzz. thnx a lot...
How is a structure member accessed?
What is meant by realloc()?
Do pointers store the address of value or the actual value of a variable?