07MoreArrays-handout

07MoreArrays-handout - More on Arrays Amir Hossein Rabbani...

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

View Full Document Right Arrow Icon
More on Arrays Amir Hossein Rabbani Winter 2009
Background image of page 1

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

View Full DocumentRight Arrow Icon
Array : Review Is the type of the values that can be stored in each element of the array Specifies the range of the indices for the subscript Type :: Name ( Bound ) REAL :: course_grades(10) course_grade(1) = 92 A1 A2 An-1 An 1 2 n-1 n Index elements
Background image of page 2
This session More examples on arrays Nested DO loop Implied DO loop
Background image of page 3

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

View Full DocumentRight Arrow Icon
G C D G reatest C ommon D ivisor : the largest number that divides two integers Given two numbers a and b , and provided that a <= b , it is sufficient to divide both a and b by all numbers that are equal to or less than a . 204 12 x 17 12 ------- = ------------- = ------- 119 7 x 17 7
Background image of page 4
Example A B / A Common Divisor 12 18 / 12 - 11 18 / 11 - 10 18 / 10 - 9 18 / 9 - 8 18 / 8 - 7 18 / 7 - 6 18 / 6 6 = G C D 5 18 / 5 - 4 18 / 4 - 3 18 / 3 3 2 18 / 2 2 1 18 / 1 1 A = 12 B = 18
Background image of page 5

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

View Full DocumentRight Arrow Icon
! Greatest Common Divisor PROGRAM GCD IMPLICIT NONE INTEGER :: A, B, counter IF (A <= B) THEN ! Finding minimum of A and B counter = A ELSE counter = B END IF DO IF (MOD(A , counter) == 0 .AND. MOD(B , counter) == 0) EXIT counter = counter - 1 END DO WRITE (*,*) “GCD of”, A, “ and “, B, “ is “, counter END PROGRAM GCD
Background image of page 6
all common divisors? QuickTimeª and a
Background image of page 7

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

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/15/2010 for the course COMP COMP 206 taught by Professor Vybihal during the Spring '04 term at McGill.

Page1 / 17

07MoreArrays-handout - More on Arrays Amir Hossein Rabbani...

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

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