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 is pointers in c with example?
Why isn't it being handled properly?
Can a function argument have default value?
Is Exception handling possible in c language?
What happens if a header file is included twice?
What is adt in c programming?
Devise a program that inputs a 3 digit number n and finds out whether the number is prime or not. Find out its factors.
In C language, a variable name cannot contain?
Is null always equal to 0(zero)?
What is extern keyword in c?
What are control structures? What are the different types?
What is structure packing in c?
What are high level languages like C and FORTRAN also known as?
differentiate built-in functions and user – defined functions.
What is #define?