Sei sulla pagina 1di 25

R e vie w S e ssio n 1

CSCE150EF FORTRAN
Nate Benes
A Disclaimer:
• I have not seen the test
• Things in the review may not be on
the test.
• Things on the test may not be in the
review.
• Questions?
THE STORY SO FAR…
Stuff we have covered:
• “Hello World!”
• Assignment Statements
• Looping
– The counted loop
• DO I = 1,5,2 … END DO
– The simple loop
• DO … END DO
– The while loop
• DO WHILE (skyIsBlue) … END DO

Stuff we have covered:
• Formatting
– 100 FORMAT(I4, F7.4, A)
• File Input and Output
– OPEN(UNIT=8, FILE='trigTable.out',&
STATUS='REPLACE',
ACTION='WRITE',& IOSTAT=ierror)
• Arrays
– addressBook(jenny) = 8675309
• Subroutines/Functions
QUESTIONS?
THE TEST
What we know so far:
• 5 – 6 Questions
• Will cover everything up through
Subroutines/Functions (but no
recursion)
• Will have two types of questions:
– Write a program to accomplish some
task.
– What does this program do?
• (see disclaimer)
A Disclaimer:
• I have not seen the test
• Things in the review may not be on
the test.
• Things on the test may not be in the
review.
• Questions?
 Writing simple programs…

THE TEST
Common Gotchas
• Forgetting to declare a variable or
declaring a variable as the wrong
type.
– Declare a variable as soon as you
write it down (especially for loops,
these are sneaky.).
– Think about how it is being used.
• IMPLICIT NONE
• Comments
Common Gotchas
• Do’s and End Do’s
• If’s and End If’s
• Doesn’t solve the problem.
• Basic Syntax stuff.
– See handout
Example 1
• Write a short, simple, legal program
to sum the integers from 1 to 100
and print the results.
– Counted DO Loop
– Write Statements
Example 2
• Write a short, legal Fortran program to
read a series of integers from the
console until a zero is encountered.
• The program should calculate and print
out the average (mean) of all the data
entered.
• You don’t need to query the user for
data or echo the input values, but
make sure that an illegal math
operation can’t cause a crash. You are
guaranteed that only integers will be
entered at the console.
Example 3
• Write a simple program to solve the
quadratic formula given three real
numbers a, b, and c. We are only
interested in finding the real roots
(no complex #’s).
• You are guaranteed that the user will
enter only numbers.
Example 3

Borrowed from: http://facstaff.gpc.edu/~mkim/C1211&1212Lec/14_Quadratic


 What does this program do?

THE TEST
How do they do that?
• Given a program (or snippet) explain
its purpose and how it does its
job…
• Examples anyone?
Example 1
• Link
Example 2
• Link
Example 3
• Link
Example 4
• Link
Example 5
• Link
 Anything I left out?

QUESTIONS?
C o n ta ct In fo

Nate Benes
nbenes@cse.unl.edu
Wednesdays 2pm-3pm

Potrebbero piacerti anche