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
Write a program, where i have a grid with many cells, how many paths are possible from one point to other desired points.
what is uses of .net
void main(){ int a; a=1; while(a-->=1) while(a-->=0); printf("%d",a); }
What is self-referential structure in c programming?
What does %d do in c?
Why void is used in c?
Using functions, write a program that multiplies two arrays. Use the following functions: - Function ReadArray - Function MultiplyArrays - Function DisplayArrays
p*=(++q)++*--p when p=q=1 while(q<=6)
Write a program to input the price of 1 burger and the number of burgers eaten by a group of friends .print the total amount to be paid by the group?
What is array of pointers to string?
Explain the difference between #include "..." And #include <...> In c?
Can you subtract pointers from each other? Why would you?
What do you mean by a sequential access file?
Is r written in c?
What is a MAC Address?