Thursday, 15 August 2019

Simple fortran programming - program for quadratic equations

!program for quardratic equation
integer a,b,c
write(*,*)"type the values of a,b,c"
read(*,*)a,b,c
d=(b*b)-4.0*a*c
if (d.ge.0)then
d=squart(d)
x1=(-b+d)/(2.0*a)
x2=(-b-d)/(2.0*a)
write(*,*)"the real roots are"
write(*,*)x1,x2
else
write(*,*)"there are no real roots are"
write(*,*)d
endif
d1= ABS(d)
write(*,*)d1
A=b/2.0*a
write(*,*)A
B=ABS(d)/2.0*a
write(*,*)B
write(*,*)"the complex roots are"
stop
end

Output:
Compilation completed with no errors.
Linking...

WARNING the following symbols are missing:
SQUART                                   C:\Users\RM\Desktop\3113550020\CheckMate\Win32\qeq.obj
(C:\USERS\RM\DESKTOP\3113550020\QEQ.F95)
Creating executable: CheckMate\Win32\qe.exe
Linking completed.

Result:

type the values of a,b,c                                                                                               3                                                                                                                       -4                                                                   5                                                                                                                        there are no real roots are                                                                                                 -44.0000                                                                                                                 44.0000                                                                                                                      -6                                                                                                                    -132                                                                                                            the complex roots are                                                                                                                                                                                                                          Press RETURN to close window...                                                                                                                          







!program for quardratic equation
integer a,b,c
write(*,*)"type the values of a,b,c"
read(*,*)a,b,c
d=(b*b)-4.0*a*c
if (d.ge.0)then
d=squart(d)
x1=(-b+d)/(2.0*a)
x2=(-b-d)/(2.0*a)
write(*,*)"the real roots are"
write(*,*)x1,x2
else
write(*,*)"there are no real roots are"
write(*,*)d
endif
d1= ABS(d)
write(*,*)d1
A=b/2.0*a
write(*,*)A
B=ABS(d)/2.0*a
write(*,*)B
write(*,*)"the complex roots are"
stop
end
Output:
Compilation completed with no errors.
Linking...
WARNING the following symbols are missing:
SQUART                                   C:\Users\Ra \Desktop\3113550020\CheckMate\Win32\qeq.obj
(C:\USERS\RM\DESKTOP\3113550020\QEQ.F95)
Creating executable: CheckMate\Win32\qe.exe
Linking completed.
Result:
type the values of a,b,c                                                                                               3                                                                                                              -4      5                                                                                                                                                                                                                                there are no real roots are                                                                                                 -44.0000                                                                                                                 44.0000                                                                                                                      -6                                                                                                                    -132                                                                                                            the complex roots are                                                                                                                                                                                                                          Press RETURN to close window...                                                                                                                         

No comments:

Post a Comment

Thanks for comment.