write a c program to find the roots of a quadratic equation
ax2 + bx + c = 0
Answer Posted / patel mac p
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int a,b,c,d;
float x1,x2,root;
printf("\nEnter the value of a,b,c");
scanf("%d %d %d",&a,&b,&c);
d=(b*b)-(4*a*c);
if(a==0&&b==0)
{
printf("\nNO SOLUTION");
}
else
if(a==0&&b!=0)
{
root=-c/b;
printf("ROOT=%f",root);
}
else
if(d>=0)
{
printf("\nROOTS ARE REAL");
x1=(-b+sqrt(d))/(2*a);
x2=(-b-sqrt(d))/(2*a);
printf("\nX1=%f",x1);
printf("\nx2=%f",x2);
}
else
if(d<0)
{
printf("\nTHIS EQUATION HAS IMAGINARY ROOTS");
}
getch();
}
| Is This Answer Correct ? | 11 Yes | 15 No |
Post New Answer View All Answers
What is the main difference between calloc () and malloc ()?
What is a pointer value and address in c?
What are the key features in c programming language?
a c variable cannot start with a) an alphabet b) a number c) a special symbol d) both b and c above
Disadvantages of C language.
What is define c?
What is the advantage of c?
Why is c so important?
What is wrong with this initialization?
Are there any problems with performing mathematical operations on different variable types?
Was 2000 a leap year?
What is the use of volatile?
What is the use of linkage in c language?
Explain what is a pragma?
Explain how can I remove the trailing spaces from a string?