All exercises

Nested Loop Control

Run a nested FOR loop every scan in this rungs.dev Add-On Instruction and report the total inner-loop iteration count — 1001 when fully enabled.

intermediate

Parameters

NameTypeUsageDescription
In_EnableBOOLInput1 enables the loop execution logic.
Out_TotalIterationsDINTOutputThe total number of inner loop iterations completed in the current scan.

Behavior

  1. On every scan, if In_Enable is 1, execute a nested FOR loop.
  2. The outer loop index 'i' ranges from 0 to 10.
  3. The inner loop index 'j' ranges from 10 to 100.
  4. An internal accumulator Count increments by 1 for every execution of the inner loop body.
  5. Out_TotalIterations is updated to the value of Count after the completion of the loops.
  6. If In_Enable is 0, Out_TotalIterations remains at 0.
  7. When enabled, the nested loops complete in the same scan and produce Out_TotalIterations = 1001.

Ready to start?

Open this exercise in Rungs Studio, write your solution, then click Test in the toolbar to verify your work against the built-in test cases.