write a c program to find the roots of a quadratic equation
ax2 + bx + c = 0

Answers were Sorted based on User's Feedback



write a c program to find the roots of a quadratic equation ax2 + bx + c = 0 ..

Answer / 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

More C Interview Questions

what will be the output: main(){char ch;int a=10;printf("%d",ch);}

36 Answers   Accenture, TCS, Wipro,


Predict the output or error(s) for the following: 25. main() { printf("%p",main); }

3 Answers   Google, ME,


Why c is called procedure oriented language?

0 Answers  


a.One Cannot Take the address of a Bit Field b.bit fields cannot be arrayed c.Bit-Fields are machine Dependant d.Bit-fields cannot be declared as static Which of the Following Statements are true w.r.t Bit-Fields A)a,b&c B)Only a & b C)Only c D)All

3 Answers   Accenture, Digg.com,


What are the ways to a null pointer can use in c programming language?

0 Answers  






#include<stdio.h> int main(){ int i=10; int *ptr=&i; *ptr=(int *)20; printf("%d",i); return 0; } Output: 20 can anyone explain how came the output is 20

0 Answers  


why wipro wase

0 Answers   Wipro,


Give differences between - new and malloc() , delete and free() ?

0 Answers   Genpact,


Q.1 write a program to create binary tree 1 to 16 numbers? Q.2 write a program to creat a binary search tree for the member that is given by user?

0 Answers   Case, IBM,


write a program to arrange the contents of a 1D array in ascending order

4 Answers  


How do I declare a pointer to an array?

6 Answers   IBM,


What are the application of void data type in c?

0 Answers  


Categories