This document discusses different types of loops that can be used in NQC programming including while loops, do-while loops, and until loops. It provides examples of the general syntax for each type of loop and describes how they work. While loops repeat a statement or block of code while a condition is true. Do-while loops always execute the code block at least once before checking the condition. Until loops wait for a condition to become true before continuing to the next statement.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
45 views5 pages
11control Loop
This document discusses different types of loops that can be used in NQC programming including while loops, do-while loops, and until loops. It provides examples of the general syntax for each type of loop and describes how they work. While loops repeat a statement or block of code while a condition is true. Do-while loops always execute the code block at least once before checking the condition. Until loops wait for a condition to become true before continuing to the next statement.
do { Toggle(OUT_A); Off(Out_B); } while (SENSOR_2 <= 10);
Notice the do while is always executed at least one time since the test of the condition is at the bottom of the loop. General Form do statement while(condition) The until control structure Example until(SENSOR_2>=5) x+=1;
This is often used to trigger a segment of code when an event occurs
until(SENSOR_1==1)
Note in the last example the statement is the null statement. The program acts as though it holds at this point until the event SENSOR_1==1 occurs and then it is released to the next statement in the program. General Form until(condition) statement