-
-
Save Ansarina/6cd8de8c484a215b9344 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PROGRAM Equation_solver_fortran | |
! This is program calculate the real roots of second order equation | |
IMPLICIT NONE ! this is important to get used to this statment | |
! Variable decleration | |
REAL::a,b,c | |
REAL::Delta, x1, x2 | |
! Main Porgram | |
WRITE(*,*) "Please enter the equation coefficients a*x^2+b*x+c" | |
WRITE(*,*) "a: ?" | |
READ(*,*) a | |
WRITE(*,*) "b: ?" | |
READ(*,*) b | |
WRITE(*,*) "c: ?" | |
READ(*,*) c | |
Delta=b**2-4*a*c | |
IF (Delta >= 0) THEN | |
x1=(b+SQRT(Delta))/(2*a) | |
x2=(b-SQRT(Delta))/(2*a) | |
WRITE(*,*) " The real roots are : ", x1, x2 | |
ELSE | |
WRITE(*,*) " This equation has no real root!" | |
ENDIF | |
PAUSE | |
END PROGRAM Equation_solver_fortran |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment