

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


C Write, compile, and run a Fortran90 program that uses a DO-EXIT loop construct to count from 1 to 100 in integer arithmetic; print out the value of the counter at each iteration.
C Write, compile, and run a Fortran90 program that uses an incrementing au- tomatic counter-controlled loop construct to count from 0 to 100 by 2’s in an integer variable and print out the value of the counter at each iteration. What is the value of the loop control variable upon exit from the loop?
B Write, compile, and run a Fortran90 program that uses a decrementing counter-controlled loop construct to count backward from 200 to 100 by 10’s in integer arithmetic and print out the value of the counter at each it- eration. What is the value of the loop control variable upon exit from the loop?
B Write, compile, and run a Fortran90 program that counts from 1 to 100 in integer arithmetic and prints out the value of the counter at every iteration except 27.
A Enter and compile the program on the reverse side, which reads n and com- putes the first n Fibonacci numbers.
A Run program FIBONACCI using n = 30 and describe what happens. Then run program FIBONACCI using n = 50 and describe what happens.
A+ Explain in some detail what went wrong for n = 50.
PROGRAM fibonacci ! !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! ! Outputs the first n Fibonacci numbers, where n is ! an integer input value ! ! Author: Dr. Dave Pruett ! JMU Math ! Credits: None ! !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! IMPLICIT NONE INTEGER :: fibo_number, previous1=1, previous2=0, i, n ! ! input the number n ! WRITE (,) ’enter the number n of Fibonacci ’, & ’numbers to print out ’ READ (,) n ! ! write the first two Fibonacci numbers outside the loop ! WRITE (,) 1, previous2! first Fibonacci number WRITE (,) 2, previous1! second Fibonacci number ! ! write the next n-2 Fibonacci numbers ! DO i = 3,n! NOTE: counter i is passive except at exit
fibo_number = previous2 + previous WRITE (,) i, fibo_number previous2 = previous1! shift operations previous1 = fibo_number! CAUTION: order is crucial
END PROGRAM fibonacci