program to find the roots of a quardratic equation



program to find the roots of a quardratic equation..

Answer / valli

/***********
quadratic equationis ax^2+bx+c=0
************8/
#include<math.h>
main()
{
int a,b,c,d,r1,r2;
printf("enter the values of a,b,c");
scanf("%d%d%d",&a,&b,&c)'
d=(b*b)-(4*a*c);
if(d<0)
{
printf("the roots are imaginary");
d=sqrt(-d);
printf("\nroots are %d+i%d",-b/(2*a),d/(2*a));
printf("\n%d-i%d",-b/(2*a),d/(2*a));
}
else
{
d=sqrt(d);
r1=(-b+d)/(2*a);
r2=(-b-d)/(2*a);
printf("the roots of the equation are %d %d ",r1,r2);
}
}

Is This Answer Correct ?    3 Yes 3 No

Post New Answer

More C Interview Questions

What is a const pointer?

0 Answers  


What are the types of i/o functions?

0 Answers  


how can write all 1to 100 prime numbers using for loop,if and break ?

2 Answers   TCS,


Calculate 1*2*3*____*n using recursive function??

0 Answers  


how can i sort numbers from ascending order and descending order using turbo c..

1 Answers  






a character or group of characters that defines a register,or a part of storage a) memory b) byte c) address d) linear list

0 Answers  


What is the acronym for ansi?

0 Answers  


Write a program using two-dimensional array that lists the odd numbers and even numbers separately in a 12 input values.

1 Answers  


What is the explanation for cyclic nature of data types in c?

0 Answers  


Write a C program to help a HiFi’s Restaurant automate its breakfast billing system. Your assignment should implement the following items: a. Show the customer the different breakfast items offered by the HiFi’s Restaurant. b. Allow the customer to select more than one item from the menu. c. Calculate and print the bill to the customer. d. Produce a report to present your complete program and show more sample output. Assume that the HiFi’s Restaurant offers the following breakfast menu: Plain Egg $2.50 Bacon and Egg $3.45 Muffin $2.20 French Toast $2.95 Fruit Basket $3.45 Cereal $0.70 Coffee $1.50 Tea $1.80

0 Answers  


what will happen if you free a pointer twice after allocating memory dynamically ?

3 Answers   Novell,


What is a static function in c?

0 Answers  


Categories