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
how to write optimum code to divide a 50 digit number with a 25 digit number??
What are local static variables? How can you use them?
What are compound statements?
I came across some code that puts a (void) cast before each call to printf. Why?
which is an algorithm for sorting in a growing Lexicographic order
Explain the Difference between the New and Malloc keyword.
Why functions are used in c?
What do the functions atoi(), itoa() and gcvt() do?
What are the features of the c language?
What is the difference between mpi and openmp?
What is bash c?
Is c# a good language?
What is d'n in c?
What are reserved words?
What are identifiers and keywords in c?