Skip to content
Snippets Groups Projects
Commit 6a355e09 authored by Jonas Riedel's avatar Jonas Riedel
Browse files

Upload New File

parent b7d2f46a
Branches
No related tags found
No related merge requests found
!Programm 1
program function_test_1
implicit none
write(*,*)f(6)
contains
function f(x)
integer, intent(in) :: x
integer :: f
f = x*x
end function f
end program function_test_1
!----------------------------------------------------------------------------------------!
!Programm 2
program function_test_2
implicit none
write(*,*) "Die Summe von x und y ist:", f(3,4)
contains
function f(x,y)
integer,intent(in) :: x,y
integer :: f
f = x + y
end function f
end program function_test_2
!----------------------------------------------------------------------------------------!
!Programm 3
program recursive_function_test
implicit none
write(*,*)f(3)
contains
recursive function f(x) result(res)
integer, intent(in) :: x
integer :: res
if(x <= 1 .or. x >= 20) then
res = 10
else
res = f(x - 1) + f(x - 2)
end if
end function f
end program recursive_function_test
!----------------------------------------------------------------------------------------!
!Programm 4
module test_module_1
implicit none
private
public :: g, n
integer :: n
contains
function g()
logical :: g
g = n > 10
end function g
end module test_module_1
program module_test_1
use test_module_1
implicit none
n = 5
write(*,*) g()
end program module_test_1
!----------------------------------------------------------------------------------------!
!Programm 5
module test_module_2
implicit none
private
public :: f,dp
integer, parameter :: dp = selected_real_kind(15, 307)
contains
function f(x)
real(dp), intent(in):: x
real(dp) :: f
f = sqrt(real(5,dp))*sqrt(x)
end function
end module test_module_2
program module_test_2
use test_module_2
implicit none
real(dp) :: x
x = 5
write(*,*)f(x)
end program module_test_2
!----------------------------------------------------------------------------------------!
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment