Using Break and Continue Statements in Loops

skip or terminate n.w
1 / 10
Embed
Share

Learn how to use the break and continue statements in loops to skip statements or terminate the loop immediately without evaluating the test expression. See examples and understand the syntax and behavior of break and continue statements in loops.

  • Looping
  • Break Statement
  • Continue Statement
  • Programming
  • Control Flow

Uploaded on | 1 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Skip or terminate

  2. It is sometimes desirable to skip some statements inside the loop or terminate the loop immediately without checking the test expression. In such cases, break and continue statements are used.

  3. The break statement terminates the loop immediately when it is encountered, Simply comes out of the loop. Immediate statement after the closing brace of the loop will be executed. Syntax of break statement break;

  4. The statements inside the loop. Loop will restart when continue is encountered. Syntax of continue Statement continue; continue statement skips some

  5. include<stdio.h> Void main(){ int i; for(i=0;i<=4;i++){ printf("%d ,i); break; printf("Label 1"); } printf("Label 2"); } Output: 0 label 2

  6. #include<stdio.h> Void main(){ int i=5; do{ printf("%d ,i); continue; i++; } while(i<=10); } Output: Infinite loop

More Related Content