write a c program to find the roots of a quadratic equation
ax2 + bx + c = 0
Answer Posted / sagarsp2010
// using sqrt in the program it needs header file <math.h>
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float a,b,c,delta,alpha,beta;
clrscr();
printf("\nENTER THE VALUE OF a:");
scanf("%f",&a);
printf("\nENTER THE VALUE OF b:");
scanf("%f",&b);
printf("\nENTER THE VALUE OF c:");
scanf("%f",&c);
delta=(b*b)-(4*a*c);
if(delta>0)
{
alpha=(-b-sqrt(delta))/(2.0*a);
beta=(-b+sqrt(delta))/(2.0*a);
printf("\nalpha=%f",alpha);
printf("\nbeta=%f",beta);
}
else if(delta==0)
{
printf("\nROOTS ARE REAL");
alpha=-b/(2.0*a);
beta=-b/(2.0*a);
printf("\nalpha=%f",alpha);
printf("\nbeta=%f",beta);
}
else
{
printf("\nROOTS ARE IMAGINARY");
}
getch();
}
| Is This Answer Correct ? | 23 Yes | 25 No |
Post New Answer View All Answers
Can stdout be forced to print somewhere other than the screen?
Explain the array representation of a binary tree in C.
Write a program to swap two numbers without using the third variable?
why use "return" statement a) on executing the return statement it immediately transfers the control back to the calling program b) it returns the value present in the parentheses return, to the calling program c) a & b d) none of the above
what is diffrence between linear and binary search in array respect to operators?what kind of operator can be used in both seach methods?
main use of recursive function a) processing speed high b) reduce program length/reduce repeated statements c) if you do not, use iterative methods like, for, while or do-while d) all the above
write a c program to print the next of a particular no without using the arithmetic operator or looping statements?
if the area was hit by a virus and so the decrease in the population because of death was x/3 and the migration from other places increased a population by 2x then annually it had so many ppl. find our the population in the starting.
how logic is used
What is the difference between typedef struct and struct?
Difference between Shallow copy and Deep copy?
Explain what happens if you free a pointer twice?
Why do we need arrays in c?
is it possible to create your own header files?
main() { int i = 10; printf(" %d %d %d ", ++i, i++, ++i); }