12.WAP to find real roots of quadratic equation

CODE:

print("Enter the Coefficent in ax2 + bx +c = 0 format ")
a=int(input("Enter a\n"))
b=int(input("Enter b\n"))
c=int(input("Enter c\n"))
d=(b*b)-(4*a*c)
if d<0:
    print("Roots are Imaginary")
else:
    x1=(-b+(d**(1/2)))/2*a
    x2=(-b+(d**(1/2)))/2*a
    print("Root 1=",x1," & Root 2=",x2)


OUTPUT:

Enter the Coefficient in ax2 + bx +c = 0 format
Enter a
1
Enter b
1
Enter c
8
Roots are Imaginary



Comments

Popular posts from this blog