TRENDING TOPICS

×

'continue' statement in C

continue statement in c programming performs just opposite to the behaviour of break statement. break statement is used to immediate terminate the loop and come out from the loop whereas continue statement is used to immediate skip all remaining statement in loop and start new iteration.

continue statement in c

How continue statement look like

loop_name(test condition)
   {
      // loop body
      continue;
   }

Try to find output...?

Flow of continue; statement

c continue statement

Let's Know continue; statement

  • Continue state that skip the following statements and continue with the next iteration.
  • Continue statement can be with all kind of loops available in c programming.
  • Continue statement can be used with or without condition checking statement.
  • The combination of for statement and continue; statement performs excellent result in programming.
  • Basically continue; statement is used in loop where we need to skip some statement based on some conditions.
  • Let’s see various examples to understand how we can make best use of continue statement.

C contunue statement example with for loop

white a program to find all even number between 1 to 20.

Note: This problem can in differents way, but here we are going to use for loop and continue statemen to solve above problem.

Output

2 4 6 8 10 12 14 16 18 20

Explanation

In above example when the for condition i!=0 is true then the body of for loop will execute and within the body of for loop there is continue; statement which will immediate enforce to the control to start next iteration without execute all other statement which are below the continue statement in the loop.

C contunue statement example with while loop

Let's see the some problem solution with while loop and continue statement.

Output

2 4 6 8 10 12 14 16 18 20

Explanation

In while loop, have incremented the value of variable i in both condition either for condition is true or false. If for condition is true then first the value of variable i will be incremented by 1 and then continue statement executed, so in this way we can perform increment operation in both condition.

Note: Just similar to for and while loop we can use continue statement in do while loop, so try to practice with all kind of loop.

Advertise With Us

We offer sponsored posts and guest posts with do-follow links, back-links, and other advertising services, To advertise email us at "advertise@gdatamart.com"

© 2021 GDATAMART.COM (All Rights Reserved)