Chapter4 - ComputerProgramming usingFortran77...

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

View Full Document Right Arrow Icon
Computer Programming using Fortran 77 Chapter 4 - Repetitive Execution
Background image of page 1

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

View Full DocumentRight Arrow Icon
Selective Execution Basic control structures of all programming  languages 1) Seqeunce (Ch 2) 2) Selection  (Ch 3) 3) Repetition (Ch 4)
Background image of page 2
Repetitive Execution Repetition structure  or a loop  makes it possible to  repeat execution of 1 or more statements (the body  of the loop) 2 types of repetition 1) counter controlled - execute body of loop while  counting value within a range 2) logical expression controlled – execute body of loop  based on a logical expression
Background image of page 3

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

View Full DocumentRight Arrow Icon
DO LOOPS - counter controlled   DO n ctrl var  = init val , limit , step size      stmt seq n continue n  = label of next exe stmt after DO loop    = positive integer    = up to 5 digits    = in columns 1 - 5 continue  = exe after DO loop has completed init val  = starting point ctrl var  = must be declared as int or real limit  = ending point step size  = increment or decrement        = if not specified, default to 1 Column  1-5
Background image of page 4
DO LOOPS - counter controlled Some guidelines: uses .GE. or .LE. when comparing if step size positive then incr using .LE. if step size negative then decr using .GE. Do not modify the control var inside the loop . The  loop will not change though, due to built in code that  takes a snapshot at the beginning and sets up the  loop
Background image of page 5

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

View Full DocumentRight Arrow Icon
DO LOOPS – Example 1     DO 10 num = 1,5  (incr =.LE.)        print *, num, num ** 2 10 continue     print *, 'DO loop complete'
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 21

Chapter4 - ComputerProgramming usingFortran77...

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

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