Answer: No, continue statement works inside loops only.

Listed below are two examples of continue statement. Both examples show how to skip "Detail print....." in the next statements with the continue statement. They take keyboard inputs from user and if user presses the ESC key, they then skip the remaining statements like a long print and continue to the next iteration.
Example:

for(i = 0; i < 10; i++)
{
  printf("Iteration %d\nPress Esc to skip long print", i);
  if(getch() == 27)/*Esc pressed*/
  {
    continue;
  }
  printf("Detail print....");
}
i = 0;
while(i < 10)
{
  printf("Iteration %d\nPress Esc to skip long print", i);
  i++;
  if(getch() == 27)/*Esc pressed*/
  {
    continue;
  }
  printf("Detail print....");
  
}

You have viewed 1 page out of 248. Your C learning is 0.00% complete. Login to check your learning progress.

 Vote 0

Similar topics related to this section

for to while, do-while and while usage, infinite loops, break and continue, switch statement, continue in switch and loops, basic operators, logical operators, logical vs bitwise operators,

# C Programming Language (Prentice Hall Software)
# Let Us C Paperback - 2006 by Yashavant Kanetkar
# Understanding and Using C Pointers Core techniques for memory management
# Data Structures Using C and C++ Paperback - 1998
# Data Structures In C Paperback - August 11, 2008 by Noel Kalicharan