Simple Program to Compute Positive and Negative Averages
Program Run - Simple Program to Compute Positive and Negative Averages
Program - Simple Program to Calculate Integrals via Trapezoidal Sums
Download integrate.f95 code
Program Run - Simple Program to Calculate Integrals via Trapezoidal Sums
Program Simple Program to Calculate Area of Circle Using Module Files
[mark@ubermentch Fortran Programs]$ gfortran math_module.f08 circle.f08
The program is run by entering ./a.out into the command prompt.
[mark@ubermentch Fortran Programs]$ ./a.out
The area is: 15.2053089
[mark@ubermentch Fortran Programs]$
Program to calculate the value of the natural logarithm base, also known as e
Program to calculate the median of three entered numbers.
This program ask the user to enter three numbers and finds the median. It uses a contains block, rather than putting the functions and procedures in a module. This is done to be proficient in both methods of function incorporation into programs.
First, in order to facilitate sorting, a subrouting "swap" is written. Its arguments have the attributes "in out", so they are passed by reference, so they are directly modified within the subroutine. Basically the subroutine swaps the arguments a with b.
The subroutine "sort" essentially uses the swap subroutine to perform a selection sort, by swapping the minimum value to the front of the list.
Finally, the function medianOf3 makes use of the sort subroutine to find the middle value and return it. The arguments to sort are passed by reference, and the names or the arguments with respect to the sort subroutine are named explicitly in the subroutine call.