Comp Sci Fortran DO Statements (how many loop times)

  • Thread starter Thread starter rk2ray
  • Start date Start date
  • Tags Tags
    Fortran Loop
AI Thread Summary
The discussion focuses on evaluating the execution count of various Fortran DO statements, assuming all loop index variables are integers. The first example, DO irange = -32768, 32767, will execute 65536 times. The second example, DO j = 100, 1, -10, will run 10 times, decreasing by 10 each iteration. The third example, DO count = 2, 3, 4, will execute only once as it does not meet the increment condition. The fourth example, DO index = -4, -7, will not execute at all since the starting point is greater than the endpoint, and the final example, DO i = -10, 10, 10, will run 3 times.
rk2ray
Messages
7
Reaction score
0
Hello,

Examining the following DO statements and determining how many times each loop will be executed. Assume that all loop index variables are integers.

(a) DO irange = -32768, 32767
(b) DO j = 100, 1, -10
(c) DO count = 2, 3, 4
(d) DO index = -4, -7

(e) DO i = -10, 10, 10
The loop will take 10 increments and will run 2 times.

Thanks for any help.
 
Last edited:
Physics news on Phys.org
If you don't try to evaluate at least one or two of the easy statements, you won't get any help on the harder ones.
 

Similar threads

Replies
2
Views
6K
Replies
3
Views
7K
Replies
2
Views
2K
Replies
17
Views
3K
Replies
3
Views
2K
Replies
21
Views
3K
Back
Top