In this exercise you can practice the various control structures that Fortran provides. No skeleton codes are provided, so you should implement the whole program yourself.
-
Write an
if
structure which checks whether an integer is negative, zero, or larger than 100 and performs corresponding write. Investigate the behavior with different integer values. -
Implement the above logic with
select case
. (Tip: check Fortran Wiki for specifying range of integers incase
) -
Fibonacci numbers are a sequence of integers defined by the recurrence relation
Fn = Fn-1 + Fn-2
with the initial values F0=0, F1=1.
Write a
do
loop with integer counter that prints out Fibonacci numbers up to n=15 -
Print out Fibonacci numbers Fn < 650 first using
do while
loop and then finally withdo
loop with explicitexit
statement. Which form suits better this particular case? -
Write a program that determines the sum of squares of even numbers up to 10: s = 02 + 22 + 42 + ... + 102