Hello, World
Hello World Example in Fortran
Here is a simple "Hello, World!" program written in Fortran:
program hello
print *, 'Hello, World!'
end program hello
Instructions to Run the Fortran Program
Save the Code: Save the above code in a file named
hello.f90
.Compile the Program: Use a Fortran compiler to compile the program. If you have
gfortran
installed, you can compile the program using the following command in the terminal:gfortran -o hello hello.f90This command compiles
hello.f90
and creates an executable namedhello
.Run the Program: Execute the compiled program by running the following command in the terminal:
./helloYou should see the output:
Hello, World!
Summary
Save the code in
hello.f90
.Compile with
gfortran -o hello hello.f90
.Run with
./hello
.
Last modified: 28 November 2024