Questions tagged [continue]

A language construct typically used to bypass the rest of a loop and return to the beginning for the next iteration.

Using continue will go back to the first line of the loop, in this example when i is 2 or 3 the program will immediately go back to the first line: for i in range(1, 6) before the current iteration has finished

Example (Python):

for i in range(1, 6):
    print(i)
    if i == 2 or i == 3:
        continue
    print("do stuff")
print("after the loop")

Output:

1
do stuff
2
3
4
do stuff
5
do stuff
after the loop

Also see .

724 questions
-5
votes
2 answers

How does “continue" work in this code?

while ( fgets(eqvline, 1024, eqvfile) != NULL ) { eqvline[strlen(eqvline)-1] = '\0'; if (!strcmp (eqvline, "$SIGNALMAP")) { start_store_mask = 1; continue; } if (!strcmp (eqvline, "$SIGNALMAPEND")) { …
Jaden Ng
  • 141
  • 1
  • 12
-6
votes
2 answers

Continue statement

The continue statement is for skipping the iteration but it doesn’t work as I expect. Here is my code: int i = 0; do { if(i== 10)continue; printf("\n This is = %d",i); i++; } while (i<20); My understanding is that it will skip just This…
-6
votes
2 answers

Labeled Continue statement fails to compile

import java.util.Scanner; class testing { int i ; int j ; Scanner sc = new Scanner(System.in) ; void lolwa() { out: for(i = 0 ; i <= 6 ; i++) { System.out.println(i); } …
Rishava
  • 3
  • 1
-7
votes
2 answers

Which loop does the 'continue' act on with a flag?

The continue statement should act on the inner loop, right?? Or am I missing something? for (j=0; j< 100; j++) { for (i=0 ; i<10; i++) { bool flag = false; //CALL TO A FUNCTION WHICH, BASED ON SOME CONDITION, MODIFIES…
ZeroTwo
  • 307
  • 1
  • 3
  • 12
1 2 3
48
49