{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

Info icon This 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
Image of page 1

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

View Full Document Right 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 ./a.out enter miles (0 if finished) and gallons of fuel used 231 14.8 Milage is 15.60811 miles per gallon
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}