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 does the format %10.2 mean when included in a printf statement?

0 Answers  


What is the difference between big endian form and little endian form? write a code to convert big endian form to little endian and vice versa..

5 Answers   Aricent, TCS,


Why we use break in c?

0 Answers  


what is array?

8 Answers  


Write a C program to get the desired output. 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 . . . 1 n..............n 1 Note: n is a positive integer entered by the user.

4 Answers  






enum DAY { sunday, monday, tuesday }; enum EDAYS { friday, saturday, sunday }; void main() { int i =0; if( i == sunday) { printf("%d",i); } } what would be the output?

4 Answers   TCS,


Why do we need functions in c?

0 Answers  


How can I write functions that take a variable number of arguments?

0 Answers  


Does sprintf put null character?

0 Answers  


Explain a pre-processor and its advantages.

0 Answers  


Explain what is a pragma?

0 Answers  


HOW TO SOLVE A NUMERICAL OF LRU IN OS ??????

0 Answers  


Categories