write a c program to find the roots of a quadratic equation
ax2 + bx + c = 0
Answer Posted / rupesh
#include<stdio.h>
#include<conio.h>
void main()
{
int a, b, c;
float x1, x2, root, d;
clrscr();
printf("Enter the values of a, b & c");
scanf("%d %d %d", &a, &b, &c);
if(a==0 && b==0)
printf("There izz no Soln...");
else
if(a=0)
{
root= -c/b;
printf("root = %d", root);
}
else
d = b*b-4*a*c;
if(d>=0)
{
x1 = (-b + d)/2*a;
x2 = (-b - d)/2*a;
printf("Roots are....x1 = %f, x2 = %f\n", x1,x2);
}
else
printf("Given Eqn has imaginary roots");
getch();
}
| Is This Answer Correct ? | 32 Yes | 41 No |
Post New Answer View All Answers
What is the need of structure in c?
What is pointer & why it is used?
How is pointer initialized in c?
What is the explanation for the dangling pointer in c?
When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?
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 use of bit field?
How does selection sort work in c?
How can a process change an environment variable in its caller?
write a C program:There is a mobile keypad with numbers 0-9 and alphabets on it. Take input 0f 7 keys and then form a word from the alphabets present on the keys.
Explain how can I open a file so that other programs can update it at the same time?
What are the 4 types of functions?
what is the difference between class and unio?
What are the benefits of c language?
What is a rvalue?