Difficulty: Easy
Correct Answer: 4
Explanation:
Introduction / Context:This question checks understanding of Fortran 77 DO loop semantics: initial value, terminal value, and step (increment). Correctly counting iterations prevents off-by-one errors in numerical codes.
Given Data / Assumptions:
Concept / Approach:The loop runs with values N = N0, N0 + s, N0 + 2s, ... while N ≤ NL. Count the generated sequence elements within bounds.
Step-by-Step Solution:
Compute sequence: 1, 1+3 = 4, 4+3 = 7, 7+3 = 10Check bound: 10 ≤ 10 → included; next would be 13 > 10 → stopNumber of values = 4 → executions = 4Verification / Alternative check:Use count formula for inclusive arithmetic progressions: count = floor((NL - N0)/s) + 1 = floor((10 - 1)/3) + 1 = floor(3) + 1 = 4.
Why Other Options Are Wrong:
Common Pitfalls:
Final Answer:4
Discussion & Comments