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 does. int *x[](); means ?
What does volatile do?
Explain what is page thrashing?
How can I trap or ignore keyboard interrupts like control-c?
Which function in C can be used to append a string to another string?
Can we assign string to char pointer?
What is a null pointer in c?
Hi can anyone tell what is a start up code?
What are the benefits of organizational structure?
When can you use a pointer with a function?
Why doesnt this code work?
Why isn't any of this standardized in c? Any real program has to do some of these things.
What are different types of operators?
What extern c means?
Is a house a shell structure?