next up previous
Next: Specification of Properties Up: CS101 Lecture 9 Previous: More Examples

Array Initialization

Method 1:
Integer :: I   ! counter for Do loop
Real, Dimension(-5:4) :: Temp

!Initialize to 0
Do I = -5, 4, 1
 Temp(I) = 0.0
End Do

!Equivalent but more risky
!Use the first method. this is only for ``macho'' programmers.
! Do I = 1, 10
!   Temp(I - 6) = 0.0
! End Do

Method 2:

Integer, Dimension(5) :: Marks

Marks = (/0, 0, 0, 0, 0/)

Other methods in Pass 2.



G. Sivakumar 2000-08-20