Final answer:
Fortran functions for calculating area of a rectangle and a factorial are written with the main program handling input and output.
Step-by-step explanation:
In Fortran, we can define the area of a rectangle given its length and width, and also calculate the factorial of a non-negative integer using recursion. The area and fac functions are quite straightforward to implement. Here's an example of how one might write these functions in Fortran:
function area(length, width) result(area_val)
real, intent(in) :: length, width
real :: area_val
area_val = length * width
end function area
recursive function fac(n) result(fac_val)
integer, intent(in) :: n
integer :: fac_val
if (n <= 1) then
fac_val = 1
else
fac_val = n * fac(n-1)
endif
end function fac
program main
real :: length, width
integer :: n
print *, 'Enter the length and width of the rectangle: '
read *, length, width
print *, 'The area is ', area(length, width)
print *, 'Enter a non-negative integer n for factorial calculation: '
read *, n
print *, n, '! = ', fac(n)
end program main
The main program asks for the user inputs, and then displays the results using the defined functions.