ps4altered - Problem Set Problem Problem Statement Write a...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
9/23/07 Problem Set Problem / Problem Statement Write a program that reads a positive integer n and then displays the first n Fibonacci numbers. FORTRAN Code PROGRAM FIB Implicit None Integer :: sum1,sum2, sum3, count, n Write(*,*) "Enter n" Read(*,*) n sum3 = 1 sum2 = 1 count = 0 Do sum2 = sum3 sum1 = sum2 sum3 = sum1+sum2 count = count+1 IF (count == "n") EXIT Write(*,*) sum3 End DO END PROGRAM FIB Output ./a.out Enter n 7 1 1 2 3 5 8 13 Problem Statement
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
9/23/07 Problem Set Problem / Write a program to read the data values shown in the following table, calculate the miles per gallon in each case, and print the values with appropriate labels Governing Equations Distance/usage = mileage FORTRAN Code PROGRAM Miles IMPLICIT NONE REAL :: mpg, consumption, distance Do Write (*,*) "enter miles (0 if finished) and gallons of fuel used" Read (*,*) distance, consumption IF (distance == 0) EXIT mpg = distance/consumption Write(*,*) "Milage is", mpg, "miles per gallon" END DO END PROGRAM Miles Output
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 7

ps4altered - Problem Set Problem Problem Statement Write a...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online