The Daily CLAD

Community Browser
cancel
Showing results for 
Search instead for 
Did you mean: 

Re: For loop iteration control

SercoSteveB
Active Participant

1.       What is the value in Numeric Value Out after the following has executed?

Question 11 For Loop Iterations 1.png

a)      0

b)      3

c)      6

d)      10

Comments
SercoSteveB
Active Participant

Answer: B

For loop iteration count can be controlled by; the value wired to the N (count) terminal, the size of an input array (with auto-indexing enabled) or optionally by a Conditional Terminal.  If multiple specifications of iteration count are made (as in the question) a For loop will always opt for the fewest number of iterations.  In the question the loop will iterate 3 times as defined by the size of the smaller of the two auto-indexed arrays.

At run-time:

1.    Before the loop performs the first iteration we initialise the shift register with 0. 

2.    On the first iteration of the loop we add the value in the shift register (0) to the value of the iteration terminal (0) and pass it to the shift register.

3.    On the second iteration we add the new value in the shift register (0) to the value of the iteration terminal (1) and pass it to the shift register.

4.    On the third iteration we add the new value in the shift register (1) to the value of the iteration terminal (2) and pass it to the shift register. 

5.    Having completed 3 iterations the For loop completes and the value in the shift register (3) is passed to Numeric Value Out.

swetha_sadula
Member

answer is :B

nmpundlik
Member

Ans: B) 3

SOM19
Member

B

ashwinilele
Member

B

izza
Member

B

Andreas.Bernau
Member

B

sac0071
Member

B

M.P.Bharghavi
Member

Ans:B

3

J.Nivetha
Member

B

vicky369
Member

B

skian
Member

B