Skip to content

Latest commit

 

History

History
 
 

control-structures

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Control structures

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.

  1. 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.

  2. Implement the above logic with select case. (Tip: check Fortran Wiki for specifying range of integers in case)

  3. 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

  4. Print out Fibonacci numbers Fn < 650 first using do while loop and then finally with do loop with explicit exit statement. Which form suits better this particular case?

  5. Write a program that determines the sum of squares of even numbers up to 10: s = 02 + 22 + 42 + ... + 102