03-23-2022 10:06 AM
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?
Solved! Go to Solution.
03-23-2022 11:57 AM
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!
03-23-2022 12:33 PM
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
03-23-2022 12:56 PM
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.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
03-23-2022 01:03 PM
CoastalMaineBir
03-23-2022 01:24 PM
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.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
03-23-2022 01:34 PM
In any case, there is no practical use for code like that. CLAD should focus on real world scenarios, not trick questions.
03-23-2022 01:51 PM
CoastalMaineBir
Thanks again!
G
03-23-2022 02:05 PM
@LvTech wrote:
CoastalMaineBir
d 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.
03-23-2022 02:08 PM
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.
Blog for (mostly LabVIEW) programmers: Tips And Tricks