The Daily CLAD

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

Re: For loops, Shift Registers and Auto-Indexing #2

SercoSteveB
Active Participant

What is Numeric Value Out after the following has executed?

 

 Daily CLAD #10 Nested For Loops Arrays and SRs.png

a)    A 1D Array with contents {0,2,12}

b)    A 1D Array with contents {0,2,24}

c)    A 1D Array with contents {0,2,48}

d)    A 1D Array with contents {0,2,96}

Comments
SercoSteveB
Active Participant

Answer: C

For each of the four iterations of the outer loop (defined by the constant value wired to the Count (N) terminal) the inner loop will iterate three times (defined by the size of the auto-indexed array).

At run-time:

The following tables show the contents of the three element array (in the shift register) before and after execution of the inner loop, for each of the outer loop iterations.

NOTE:  Modifications made to the array within the inner loop are passed to the next iteration of the outer loop via the shift register.

Outer loop iteration #1

Array Element

Array contents before inner loop

Array contents before after loop

0

1

1×0=0

1

2

2×1=2

2

3

3×2=6

Outer loop iteration #2

Array Element

Array contents before inner loop

Array contents before after loop

0

0

0×0=0

1

2

2×1=2

2

6

6×2=12

Outer loop iteration #3

Array Element

Array contents before inner loop

Array contents before after loop

0

0

0×0=0

1

2

2×1=2

2

12

12×2=24

Outer loop iteration #4

Array Element

Array contents before inner loop

Array contents before after loop

0

0

0×0=0

1

2

2×1=2

2

24

24×2=48

Following four iterations the outer loop completes and the value in the shift register, a 1D array containing {0, 2, 48}, is passed to Numeric Array Out.

ashwinilele
Member

C

Dushy@11
Member

C

Andreas.Bernau
Member

C

sac0071
Member

C

N.UdhayaKamali
Member

C

Lily2016
Member

c

ersmt444
Member

Image broken

மணிகண்டபிரபு
Member

C

skian
Member

C