answersLogoWhite

0


Best Answer

ANSWER

Continue is used to jump to the end of an iteration in a loop. It is often used in an if statement within a while or for loop to skip the remainder of the loop code.

Example (note: not the easiest way to write this code):

for ( i=0; i<10; i++ )

{

if ( array[i] <= 0 )

{

continue; // do not add this value to the total

}

total += array[i];

}

User Avatar

Wiki User

13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

The continue is another jump statement like the break statement as both the statements skip over a part of code . But continue statement is somewhat different from break.Instead of forcing termination,it forces the next iteration of loop to take place, skipping any code in between.A continue statement will just abandon the current iteration and let the loop start the next iteration.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

We use the continue keyword within a loop statement (for, while and do) whenever we wish to start a new iteration of the loop, bypassing any and all remaining statements within the loop.

Use of continue should always be conditional, otherwise none of the remaining statements would ever execute.

There are often alternatives to using continue within a loop, but if the condition can be expressed or processed more efficiently with continue then it makes sense to use it.

The following example demonstrates both unconditional and conditional use of continue within while loops. The final loop demonstrates a possible alternative to using continue.

int x = 10;

while( x-- )

{

continue; // Unconditional.

std::cout << x << std::endl; // Never executes!

}

x = 10;

while( x-- )

{

if( x % 2 )

continue; // Conditional.

std::cout << x << std::endl; // Executes when x is even.

}

x = 10;

while( x-- )

{

if( !(x % 2 )) // Alternative to using continue.

std::cout << x << std::endl; // Executes when x is even.

}

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is work of continue statement in c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Difference between goto and continue statement in c language?

In continue statement, we immediately continue next step through loop In go to statement, we go to in perfect label which we call.


Would you continue to work for a company if you disagreed with the firm's mission statement why or why not?

Would you continue to work for a company if you disagreed with the firm's mission statement


What is the use of continue in c?

Continue statement is used to take the control to the begining of the loop in which it is used.


How do you use continue statement in c language?

In C continue stements are used inside the loops like for .while,do while .its a statement used in c language wher it tell the compiler to skip the following statement(statement or part of progm following continue)&amp;continue with next iteration.it shud me noted that its diff from break statement wher the control of prog goes out of the particular loop.in case of for ,while ,or do loops when we use continue the rest of the loop will not me excecuted and it will go back to check the condition of the loop.


What is the meaning of continue in C programming?

The continue statement means to branch to the end of the smallest enclosing loop and continue with the next iteration, if there is one.


How do you use a C-continue statement in a block- without any looping or conditional statements?

In the C language, the continue statement can only be used within a loop (for, while, or do). Upon execution, control transfers to the beginning of the loop.


How many arithmetic statement in c?

Only one: expression. Yes, in C expression is one of the statements. Some other statements are: if, do, goto, while, for, switch, break, continue, return, NULL-statement, compound-statement.


How do you use a c program-continue statement in a block not in a loop?

You can use it like an usual operator. Everything (in the same block) after continue will not be executed.


Can a continue statement be used in a switch statement?

If you have a loop in your switch statement or around your switch statement, you can use the continue statement in that. You cannot use a continue statement outside of a loop (do, for, or while).


How do you use a c program-continue statement in a block?

int f(int num) { int i; for (i = 0; i &lt; 10; i++) { if (num &gt; i) continue; printf("aaa"); } } printf will only be reached when i &lt;= num.


What is the purpose of Continue and break statement in C?

The break statement is frequently used to terminate the processing of a particular case within a switch statement. Lack of an enclosing iterative or switch statement generates an error.Within nested statements, the break statement terminates only the do, for, switch, or whilestatement that immediately encloses it. You can use a returnor goto statement to transfer control elsewhere out of the nested structure.This example illustrates the break statement:#include int main() { char c; for(;;) { printf_s( "\nPress any key, Q to quit: " ); // Convert to character value scanf_s("%c", &c); if (c == 'Q') break; } } // Loop exits only when 'Q' is pressed


Where is the continue statement NOT usually used?

The continue statement is not actually used when it is the last statement of the body of the loop. Plus: outside any loop it is rarely or never used.