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


Please Help Members By Posting Answers For Below Questions

How can I find out if there are characters available for reading?

629


How can I access an I o board directly?

607


What is an expression?

645


Why is this loop always executing once?

605


What are register variables? What are the advantage of using register variables?

665






what is a function method?give example?

1904


Why can’t constant values be used to define an array’s initial size?

818


What is a dynamic array in c?

577


Is there a built-in function in C that can be used for sorting data?

727


What is the difference between break and continue?

596


What is 'bus error'?

630


Why is it usually a bad idea to use gets()? Suggest a workaround.

882


What is the process to generate random numbers in c programming language?

596


code for find determinent of amatrix

1498


What is self-referential structure in c programming?

642