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
How can I find out if there are characters available for reading?
How can I access an I o board directly?
What is an expression?
Why is this loop always executing once?
What are register variables? What are the advantage of using register variables?
what is a function method?give example?
Why can’t constant values be used to define an array’s initial size?
What is a dynamic array in c?
Is there a built-in function in C that can be used for sorting data?
What is the difference between break and continue?
What is 'bus error'?
Why is it usually a bad idea to use gets()? Suggest a workaround.
What is the process to generate random numbers in c programming language?
code for find determinent of amatrix
What is self-referential structure in c programming?