program main
implicit none
real a,b,c,D,r1,r2
!a=1;b=2;c=4
print*,"quadratic equation:ax^2+bx+c"
print*,"enter values of a b & c followed by space "
read(*,*) a,b,c
D=b**2-4*a*c
if(D>0.0) then
print*,"there are two distinct real roots"
r1=(-b+sqrt(D))/(2*a)
r2=(-b-sqrt(D))/(2*a)
print*,r1,r2
elseif(D<0.0) then
print*,"there are two distinct complex roots"
print*,cmplx(-b/(2*a),sqrt(-D)/2*a)
print*,cmplx(-b/(2*a),-sqrt(-D)/2*a)
!!you can also write 16 in this way!!
!print*,(-b+sqrt(cmplx(D)))/(2*a)
else
print*,"there are two equal real root"
r1=-b/(2*a)
r2=-b/(2*a)
print*,r1,r2
endif
end program main
To embed this project on your website, copy the following code and paste it into your website's HTML: