LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

CLAD prep example question help please

Solved!
Go to solution

Hi,

 

I am taking multiple practice tests in preparation for the CLAD. My weak spot seems to be questions where you need to say what the output of a loop within a loop will be. For the below example, is there a way to approach this problem without going through each iteration in my head & trying to keep track of the values that will be in each of these stacked shift registers after every iteration? Gets very confusing because not allowed to have paper and pencil to note things during the exam. I am creating these examples in LabVIEW and stepping through hem to follow the data flow, but wondering if there is a "faster" way to get to the solution. The choices given as possible answers in this example are: 0, 1, 2, or 3. 

 

Thanks for the help!

 

George

 

 

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

 

LvTech_0-1648047969674.png

 

 

0 Kudos
Message 1 of 19
(2,581 Views)

On a side note, this is quite a stupid example, more of a brain twister. In the real world, stacked shift registers are typically a bad idea anyway and they should not even be part of a curriculum. There are always better options! Good luck with your exam!

Message 2 of 19
(2,548 Views)

Yes a brain twister it is for sure. Trying to find a pattern or an easier way to come up the output besides running the vi in my head!

 

Thanks,

 

G

0 Kudos
Message 3 of 19
(2,540 Views)

One key is to recognize that the inner loop is utterly pointless.  Since N is TWO, and there are THREE shift reg inputs, the third one NEVER gets changed.  It remains at its initial value (2).  You don't have to "run it in your head" to answer that.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 4 of 19
(2,534 Views)

 , not sure I'm following. The 3rd SR in the inner loop does change because the outer loop runs 3 times, so the inner loop's values all change correct?

0 Kudos
Message 5 of 19
(2,528 Views)

The inner loop doesn't change anything. the inner loop's OUTPUT will always be whatever the third ShiftReg input is, plus 1. That's because nothing can change that third input, if the loop only runs twice.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 6 of 19
(2,519 Views)

In any case, there is no practical use for code like that. CLAD should focus on real world scenarios, not trick questions.

0 Kudos
Message 7 of 19
(2,514 Views)

  I understand that, but the inner loop basically runs 6 times because it runs twice, outputs to outer SR & indicator, then twice more, than  twice more, all the while the values are cycling through the inner SR correct? Whether this code is practical or not, I feel like I need to be able to figure it out.

 

Thanks again!

 

G

0 Kudos
Message 8 of 19
(2,506 Views)

@LvTech wrote:

  I understand that, but the inner loop basically runs 6 times because it runs twice, outputs to outer SR & indicator, then twice more, than  twice more, all the while the values are cycling through the inner SR correct? Whether this code is practical or not, I feel like I need to be able to figure it out.

 

Thanks again!

 

G


The outer loop only runs 3 times, and you're prefilling the shift register with 3 values. The inner loop could run 100 times and not change the output of the outer loop.

0 Kudos
Message 9 of 19
(2,495 Views)

The inner loop does NOT keep cycling values, because the ShiftRegs get initialized every time the OUTER loop iterates.

 

Since inner N is 2, the third inner loop Shift Reg is never changed during its execution.  It always ALWAYS contains its initial value.

 

I don't claim that's the complete answer.  That is ONE key.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 10 of 19
(2,493 Views)