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 does %d do in c?
What is an auto variable in c?
find the output? void r(int a[],int c, int n) { if(c>n) { a[c]=a[c]+c; r(a,++c,n); r(a,++c,n); } } int main() { int i,a[5]={0}; r(a,0,5); for(i=0;i<5;i++) printf("\n %d",a[i]); getch(); }
Tell me can the size of an array be declared at runtime?
What is the difference between malloc() and calloc()?
What is the difference between null pointer and wild pointer?
What is the difference between malloc calloc and realloc in c?
What are pragmas and what are they good for?
Explain function?
Distinguish between actual and formal arguments.
When is the “void” keyword used in a function?
What is the best way of making my program efficient?
Draw a diagram showing how the operating system relates to users, application programs, and the computer hardware ?
number of times a digit is present in a number
Explain goto?