You are on page 1of 1

implicit none

real a,b,c,x1r,x1i,x2r,x2i,d,r1,ipoz,ineg
write(*,*) "Introduceti numerele a,b si c, va rog:"
read(*,*) a,b,c
d=b*b-4*a*c
if(a==0 .and. b/=0 .and. c/=0) then
write(*,*) -c/b
elseif(a==0 .and. b==0 .and. c/=0) then
write(*,*) "Nu are sens"
elseif(a==0 .and. b==0 .and. c==0) then
write(*,*) "0"
else
if(d>0) then
write(*,*) (-b+sqrt(d))/2*a,(-b-sqrt(d))/2*a
elseif(d<0) then
r1=(-b)/(2*a)
ipoz=sqrt(-d)/(2*a)
ineg=-(sqrt(-d)/(2*a))
write(*,*) "Prima solutie complexa este: ",r1,"+i*",ipoz
write(*,*) "A doua solutie complexa este: ",r1,"-i*",ineg
else
write(*,*) (-b)/(2*a)
endif
endif
end

You might also like