hand3ex1 - DO loop, the elements of aa along with the...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Extra Question Handout Three Consider the following series of numbers. 1,1,2,3,5,8,13,21,34,55,89,144 The first two elements of the series are set to one. From then on the next term in the series is simply the sum of the two previous terms. Problem Outline 1. Create an ‘ INTEGER ’ array of six elements and set the array to hold the values as follows, aa=(/3,7,5,4,14,21/) ’. 2. First sort the array ‘ aa ’ into ascending numerical order using a pair of nested ‘ DO ’ loops. 3. For each integer value k stored in the array ‘ aa ’ you need to work out the corresponding k th term in the series outlined above. So, for example, element ‘ aa(1) ’ your code needs to calculate the third term of the series as ‘ aa(1) ’ holds the value three. 4. In a ‘ REAL ’ array, called ‘ bb ’, which is the the same size as ‘ aa ’ you need to store the the k th value of the series you have just calculated. It should be stored in ‘ bb ’ in the corresponding location of aa ’. 5. At the end of your program you need to print out, using a ‘
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: DO loop, the elements of aa along with the corresponding calculated value in the series stored in bb . So for aa=(/3,7,5,4,14,21/) we have the position of the term in the series in the left column and the corresponding value of that term in the series in the right column. Your output should be the same as below. 3 2.000000 4 3.000000 5 5.000000 7 13.00000 14 377.0000 21 10946.00 In your handout3 directory, make a new directory extra and write your code in a le called series.f90 . When you compile your code call the executable le series . Follow the instructions below to help you write your code. Note the points below. Create only two arrays aa and bb . Create two loop index variables i and j . You will need to create other variables as you need them. 1...
View Full Document

Ask a homework question - tutors are online