Branching with if and else in Fortran is straight-forward.
To run the program, save the code in a file with a .f90 extension (e.g., if_else.f90) and use a Fortran compiler:
Note that in Fortran:
The if statement is followed by then and ends with end if.
Logical operators are written as .and. and .or..
The modulo operation is performed using the mod() function.
String literals are enclosed in double quotes.
The print * statement is used for console output.
Fortran doesn’t have a direct equivalent to Go’s ability to declare variables in the if statement itself. Variables need to be declared at the beginning of the program or subroutine.
There is no ternary if in Fortran, so you’ll need to use a full if statement even for basic conditions.