12.07.2015 Views

Chapter 4. More Fortran Elements: DO Loops and Input/Output 4.1 ...

Chapter 4. More Fortran Elements: DO Loops and Input/Output 4.1 ...

Chapter 4. More Fortran Elements: DO Loops and Input/Output 4.1 ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Chapter</strong> 4 Review Problems1. For each example, how many times will the loop be executed?a. <strong>DO</strong> 10 I = 10, 10b. <strong>DO</strong> 10 I = 1, 10, 3c. <strong>DO</strong> 10 I = –2, 2d. <strong>DO</strong> 10 I = 10, 5, –12. After executing the following segment of code, what values will be displayed?INTEGER I, MM = 0<strong>DO</strong> 100 I = 1, 5M = M + 1WRITE(*,*) I, M100 CONTINUE3. Construct a <strong>DO</strong> loop to calculate the value of n!, the factorial. Assume that you are given thevalue of n (a positive integer).<strong>4.</strong> Consider a file containing the following data.1.0 2.22.0 3.93.0 6.1<strong>4.</strong>0 7.85.0 9.56.0 12.1The data consists of six X, Y pairs. Construct a segment of <strong>Fortran</strong> code that employs a <strong>DO</strong>loop to read in the pairs from a file assigned to unit 30.2222

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!