(Numerical Methods: Pseudocode) 10. The statement DOFOR J = L, H, A means that,
ID: 3662388 • Letter: #
Question
(Numerical Methods: Pseudocode)
10. The statement DOFOR J = L, H, A means that, in the loop, J = L for the first cycle, J = L+A for the second cycle, J = A + 2A for third cycle, and so on, until J reaches H. In other words, J goes from L to H in increments of A. For example, DOFOR J = 10, 50, 20 means that J will take on the values 10, 30 and 50. With this in mind, write pseudocode to sum consecutive even whole numbers, with the lowest even whole number being L and the highest even whole number being H.
Explanation / Answer
Good wishes,
Pseudocode:
DOFOR J = L, H, 2
Explaination:
DOFOR J = L, H, 2
means that, in the loop, J = L for the first cycle,
J = L + 2 for the second cycle
J= L + 2 + 2 for the third cycle
and so on, until J reaches H.
In other words, J goes from L to H in increaments of 2
For example
DOFOR J = 4, 10, 2 means
that J will take on the values
4, 6, 8, 10
Hope this is clear.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.