{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

07MoreArrays-handout

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

Info icon This 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
Image of page 1

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

View Full Document Right 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
Image of page 2
This session More examples on arrays Nested DO loop Implied DO loop
Image of page 3

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

View Full Document Right 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
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
Image of page 5

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

View Full Document Right 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
Image of page 6
How can I have all common divisors?
Image of page 7

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern