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
What is a loop?
What is bubble sort in c?
Why are algorithms important in c program?
Explain that why C is procedural?
How variables are declared in c?
Create a structure to specify data on students as given below: Roll number, Name, Department, Course, and Year of joining. Assume that there are not more than 450 students in the collage. (a) Write a function to print the names of all students who joined in the last 3 years. (b) Write a function to print the data of a student whose roll numbers are divisible by 4.
#include main() { enum _tag{ left=10, right, front=100, back}; printf("left is %d, right is %d, front is %d, back is %d",left,right,front,back); }
Why array is used in c?
What are the ways to a null pointer can use in c programming language?
What is f'n in math?
Which header file is used for clrscr?
Tell us two differences between new () and malloc ()?
What is an lvalue?
Why do we use & in c?
What is the c value paradox and how is it explained?