A Collection of Code Snippets in as Many Programming Languages as Possible
This project is maintained by TheRenegadeCoder
Welcome to the Even Odd in Fortran page! Here, you'll find the source code for this program as well as a description of how the program works.
program evenodd
implicit none
character(len=12) :: arg
character(len=52) :: letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
integer :: number, ios, argc
argc = command_argument_count()
if (argc /= 1) call usage()
call get_command_argument(1, arg)
if (len_trim(arg) == 0) call usage()
if (scan(arg, letters) > 0) call usage()
read(arg, *, iostat=ios) number
if (ios /= 0) call usage()
if (mod(number,2) == 0) then
write(*,*) "Even"
else
write(*,*) "Odd"
end if
contains
subroutine usage()
write(*,*) "Usage: please input a number"
stop
end subroutine
end program evenodd
Even Odd in Fortran was written by:
If you see anything you'd like to change or update, please consider contributing.
No 'How to Implement the Solution' section available. Please consider contributing.
No 'How to Run the Solution' section available. Please consider contributing.