Questions about fixed count iterations

 

Definition:  Fixed-count iterations are controlled by the loop control variable (abbreviated LCV)

 

  1. What types are permitted for the LCV? 

any discrete type:  enumerated (including Boolean), char, integer

  1. What is the scope of the LCV (i.e. where is it known? where can it be printed ?

it can be printed inside the loop and after the loop

  1. Can the LCV be modified by the programmer within the iteration body?

it can (at least in Free Pascal) but it shouldn’t be

  1. What is the value of the LCV after normal termination of the iteration?

if it hasn’t been modified within the loop body by the programmer it will have terminal (or final value) of the expression (or value) in the loop header

  1. When are the final (and increment/decrement) expressions evaluated?

The increment or decrements happen at the end of each loop iteration

The final expression is only evaluated upon intial entry into the loop

  1. Is an increment other than successor permitted?

No

  1. Is iteration backward through a range allowed and if so, how is it specified?

Yes    for i := 10 downto 1 do

  1. Is transfer into the iteration permitted and if so, what effect does it have on the LCV?

Yes using a go to – it depends on whether you transfer in before the LCV has been initialized or whether you transfer in after the loop has completed.

  1. How is the iteration body delimited?

a begin end pair is required  if there is more than one statement in the body

  1. Is it possible to transfer out of the iteration before the iteration has completed and if so, how do you do it?

Yes, using a goto or a break