answersLogoWhite

0


Want this question answered?

Be notified when an answer is posted

Add your answer:

Earn +20 pts
Q: What is the definition of nested loop statement?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Basic Math

What is the purpose of wend statement in while loop in gw-basic?

While--wend statement is used to execute a loop until a given condition is true.if the condition is false the loop ends and the program continous to the line following eend.


How does a FOR loop work in GML?

FOR loops work as follows:{for( [initialize a variable]; [expression]; [increment the variable] ) {//Do this code}}Here as an example of a FOR loop:{for(i = 1; i < 10; i += 1) {show_message(string(i));}}What this will do is show a message 10 times displaying the value of "i" so you would get a message that says "1," another one after that saying "2," etc... The way this works is that you have the variable "i" initialized in the FOR loop. The FOR loop will keep looping until i >= 10, because the middle statement dictates that i must be smaller than 10 for the FOR loop activate. The third statement in the for loop is the statement that you increment the i variable with. If you change i += 1 to i -= 1 then the FOR loop would go on forever, freezing the game. This is a critical mistake to make when constructing a FOR loop (as is with any loop.)


How do you write a Program of printing prime numbers between 1 to 100 in 1 statement only?

You really need some nested loops; but some programming languages might allow you to write this as one statement.


What are the purpose of test condition in a loop statement in qbasic?

The purpose of using a 'test condition' inside of a loop statement/which is also called a 'conditional loop'; is to make the loop STOP counting. Otherwise, you would have gone and created what is known as being called an 'endless loop'; which just keeps on running really quite endlessly, forevermore...! To give a quick example, let's compare... CONDITIONAL LOOP EXAMPLE num% = 0 DO num% = num% + 1 PRINT num%; LOOP UNTIL num% = 3 END Output... 1 2 3 Press any key to continue... Here, when the LOOP's test condition is met: (num%=3); then, the loop stops counting up any further; the DO/LOOP block structure is broken out of; and, the final END statement will get executed. UNCONDITIONAL LOOP EXAMPLE Next, let's try re-writing the same above program; by removing the conditional statement part of the LOOP which says: (UNTIL num%=3)... num% = 0 DO num% = num% + 1 PRINT num% LOOP END Output... 1 2 3 4 5 6 7 8 9 10 11 12 .... ...because there is no conditional test statement to make the loop stop repeating itself; therefore, it just keeps on endlessly counting upwards, instead; the program never breaks out of the DO/LOOP block; and, therefore never gets to reach the final END statement. To make an 'unconditional loop' stop repeating itself inside of QBASIC IDE/Integrated Development Environment; then, use combination key press: [CTRL] + [BREAK]; and, this should make an 'endless loop' stop repeating itself any further; and, return you straight back to the Editor Screen where you can futher change/edit your code.


How does a WHILE loop work in GML?

The while loop works as follows:{while( [expression is true] ) {//Do this code}}The while loop re-runs until the expression contained within the parentheses is false. Take a look at this example:{while(!place_meeting(x,y,obj_ground)) {y += 1;}}This while loop tells the object to move down one pixel until it collides with obj_ground. Unfortunately, nothing guarantees that this loop will not run forever. Always make sure that when you construct a while loop that you make sure that it does not run forever. Take a look at this whileloop:{while(obj_ball.y < y) {draw_sprite(sprite_index,0,x,y);}} This while loop will run for ever. Why? It does not have any statements that insure that the while loop aborts. Again, Always make sure that when you construct a loop that you put statements in the loop that will eventually abort the loop. y -= 1; is the statement in this new while loop that eventually aborts the loop:{while(obj_ball.y < y) {draw_sprite(sprite_index,0,x,y); y -= 1;}}

Related questions

What is the definition of 'nested' in C programming?

In C a structure within a structure is called nested. For example, you can embed a while loop in another while loop or for loop in a for loop or an if statement in another if statement.


How do you exit in nested loop in java?

You may exit a nested loop in Java using a break with a label for the outer loop.


What is the if statement that appears inside another if statement?

nested if Statement


In C which loop is embedded within another loop?

The nested loop.


What is a nested loop in java?

A nested loop is a (inner) loop that appears in the loop body of another (outer) loop. The inner or outer loop can be any type: while, do while, or for. For example, the inner loop can be a while loop while an outer loop can be a for loop.


How do you use nested for loop on the image in matlab?

Please ask clearly what you want to do with the image and explain why a nested for-loop is necessary.


What is difference between select Case statement and nested loop in c programming in UNIX?

UNIX has no bearing on the C language; it is cross-platform. There is no select/case in C, you probably meant switch/case. However, a switch/case is a conditional jump while a nested loop is a loop within a loop. Besides the C language they have nothing in common with each other.


Which loop is used when two things are done at the same time?

A loop inside a loop, which is known as a nested loop.


When loops are nested does one loop have to end before the other begins?

If one loop ends before the next begins then they are not nested at all -- they are completely independent. To be nested, one loop must contain the other loop in its entirety. That is, the inner, nested loop must start and end within the outer, containing loop. Nested loop example (in C++): for( int x = 0; x &lt; 10; ++x ) // outer loop { for( int y = 0; y &lt; 10; ++y ) // inner loop (nested loop) { printf( "%d x %d = %d\r\n", x, y, x*y ); } // end of inner loop } // end of outer loop


Why should you indent the statement in the body of a loop?

In some programming languages like Python, the indentation of the text indicates how nested it is and is required for a loop to function properly. However, for most languages, indenting the body of the loop is simply for style and readability.


Definition and comments for loop?

The C and C++ for loop is defined as...for (init-expression; test-expression; loop-expression) loop-statement;The init-expression is executed once.At the top of the loop, test-expression is evaluated. If it is false, control passes to the statement following loop-statement.The loop-statement is executed. It may be one statement, it may be a block of statements, or it may be no statement. If it is no statement, the semi-colon is required.At the bottom of the loop, loop-expression is executed, and then control passes to the test-expression at the top of the loop for another go-around.Each of init-expression, test-expression, and loop-expression may be missing. The semi-colons are required. The formal "forever" loop is for (;;) loop-statement; in which case the only way out is the break statement.Since each of init-expression, test-expression, and loop-expression can have side-effects, sometimes a loop is constructed with no loop-statement, and all processing is done between the parentheses.If test-expression is initially false, loop-expression and loop-statement are never executed. The init-expression is always executed only one time, and test-expression is executed at least one time.At any point during loop-statement, the breakstatement will exit to the statement following loop-statement, and the continue statement will jump to the loop-expression at the bottom of the loop.


When do you use the nested if?

we use "nested if" if we have to test a large number of possibilities and trials i an if statement.