0% found this document useful (0 votes)
22 views

#Include

The program takes in coefficients a, b, and c of a quadratic equation as input from the user. It then calculates the discriminant and determines if the roots are distinct, equal, or complex. Appropriate messages are printed along with the root values.

Uploaded by

Nick
Copyright
© © All Rights Reserved
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

#Include

The program takes in coefficients a, b, and c of a quadratic equation as input from the user. It then calculates the discriminant and determines if the roots are distinct, equal, or complex. Appropriate messages are printed along with the root values.

Uploaded by

Nick
Copyright
© © All Rights Reserved
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include<stdio.

h>
#include<math.h>
void main()
{ foat a,b,c,x1,x2,disc;
print(!"nter the co#e$cients%n!);
scan(!&&&!,'a,'b,'c);
i(a(()**b(()**c(())
{
print(+ e,uation is not ,uadratic %n-);
exit());
.
disc(b/b#0/a/c;1/to 2nd discriminant/1
i(disc>)) 1/distinct roots/1
{
x1((#b3s,rt(disc))1(2/a);
x2((#b#s,rt(disc))1(2/a);
print(!4he roots are distinct%n!);
.

else i(disc(())1/",ual roots/1
{
x1(x2(#b1(2/a);
print(!4he roots are e,ual%n!);
print(!x1(&%nx2(&%n!,x1,x2);
.
else
{
x1(#b1(2/a);1/complex roots/1
x2(s,rt(abs(disc))1(2/a);
print(!4he roots are complex%n!);
print(!4he 2rst root(&3i
&%n!,x1,x2);
print(!4he second root(&#i
&%n!,x1,x2);
.
. 1/ end o main unction /1

You might also like