The Daily CLAD

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

Re: For Loop

SercoSteveB
Active Participant

What is the value in Numeric Value Out following execution of the VI?

For Loop Strange.png

a) 0

b) 7

c) 14

d) Undefined (The VI does not Stop)

Comments
faymia
Member

I am going to say that the answer is b) 7 because the loop will only iterate zero times because of the empty array and the value in the shift register just passes through.

Ajay_MV
Active Participant

At first I thought it would be a) 0.  But only after testing the code I saw that shift register is there and found shift register brings the data to the other end as well.  Hence the answer is b)7.

--
Ajay MV


mini09
Active Participant

Since the empty array is connected to the for loop, the loop will take the miminum no of initialization the array with zero elements is taken by the for loopo and the loop executes zero times.

as the shift register is connected to the loop the value of shift register is taken as the output of numeric value out.

so the numeric value out of the executed program is 7. option B

JÞB
Knight of NI

"I saw that shift register is there and found shift register brings the data to the other end as well.  Hence the answer is b)7."

To add 1 small point.  Shift registers are required to be "Inplace".  That means they point to the same buffer (the area in memory where the data is located)  We can operate on that data inside the loop, even change the data in the buffer and, with some operations like build array, we may even change the size and location of the buffer (which is why we avoid building arrays in loops) but there is ONE shift register pointing to one buffer represented on both sides of the for loop.  since nothing happened inside the for loop, because it iterated zero times, the data in the buffer could not be changed. b)7


"Should be" isn't "Is" -Jay
SercoSteveB
Active Participant

Answer: B. Nice one faymia, AjayvigneshMV , gnshmrthy & JeffBohrer. Nice combined explanations from everyone.

Yep; a bit of a smoke screen on this one, place some complex (ish) looking code inside the For Loop and then don't execute it. 

RAMESHB
Member

Ans is B)7

ashwinilele
Member

Ans is7 because of shift register

skian
Member

B