NI LabVIEW Quiz Challenge
Our monthly quiz question
Our monthly quiz question
“It’s okay to have fun”. A phrase that was used in the past to promote LabVIEW. And the mantra is back, “It’s still okay to have fun”. Many programmers will agree with this, it is fun to program in LabVIEW.
For this edition, we received a nice question from Enzo Perini from www.Emibyte.com
Here it is:
What is the value in “Array” when you ran this VI?
For the previous edition, we had this easy question:
What is the value of “result” after running this code?
The answer is: 32
Here are the winners:
Country Name Company
Sweden Patrik Parlefjord GPV-Group
Norway Øystein Kristiansen Aker Solutions
Denmark Michael Hansen Eltwin
Finland Mikko Rossi University of Jyväskylä
Netherlands Piotr Samek Nexperia
Belgium Christian Lequeux Cl Consulting
Two answers we would like to highlight. The first one is from Patrik Parlefjord:
Chat GPT gave the answer 8, after believing that the “i” was involved in the multiplication. But after I pointed it out the there was an input number to the loop, it changed its answer:
Starting at 1, after five doublings the final value is:
1 → 2 → 4 → 8 → 16 → 32
Hence, the indicator “result” will show 32 once the loop finishes.
Copilot was a bit confused about the “1.23” that was already in the result block, but correctly assumed that the numbers were unrelated to the multiplication.
However, it could not understand the loop at all, and came up with the answer 2. So again, I had to help it understand a bit more. I explained that the structure around the blocks is a “for-loop”, and that the arrows was a shift register, it to came to the same conclusion:
“So, after 5 iterations, the final value in the shift register, which is displayed in the “result” indicator, will be 32.”
The second from Michael Hansen:
The sequence represents a left shift operation (multiplication by 2) in each loop iteration. Let’s break it down:
Step-by-Step Execution:
Loop 1: 1 × 2 = 2
Loop 2: 2 × 2 = 4
Loop 3: 4 × 2 = 8
Loop 4: 8 × 2 = 16
Loop 5: 16 × 2 = 32
Conclusion:
This process is equivalent to a left shift.
Do you want to challenge the Newsletter readers? Send your question to ni@cnrood.com and who knows, we might use it. Let’s have some fun!