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 mean by Data Driven framework in QTP? Can any one answer me in details on this regard.
How do you define CONSTANT in C?
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
How variables are declared in c?
A program is required to print your biographic information including: Names, gender, student Number, Cell Number, line of study and your residential address.
What is pointers in c with example?
What does struct node * mean?
How pointer is different from array?
What is the use of volatile?
How can I write a function that takes a format string and a variable number of arguments?
write a program using linked list in which each node consists of following information. Name[30] Branch Rollno Telephone no i) Write the program to add information of students in linked list
What is a null pointer assignment error? What are bus errors, memory faults, and core dumps?
What is %d called in c?
Are there any problems with performing mathematical operations on different variable types?
What are global variables and how do you declare them?