ELEVATE YOUR BUSINESS WITH

Limitless customization options & Elementor compatibility let anyone create a beautiful website with Valiance.

Break Continue in C

SELECT * FROM `itio_tutorial_master` WHERE `tutorial_menu`='28' AND `tutorial_submenu`='1647' AND `tutorial_status`=1 LIMIT 1

Break Continue in C

In C, break and continue are loop control statements that help you manage how loops behave — great for skipping stuff or exiting early! ??


? break Statement

break is used to exit a loop (or switch statement) immediately, regardless of loop condition.

? Example

c

int main() { for (int i = 1; i <= 10; i++) { if (i == 5) { break; // Exit loop when i is 5 } printf("%d ", i); } return 0;}

Output:


1 2 3 4

? Loop stops when i == 5.


? continue Statement

continue skips the rest of the current iteration and jumps to the next one.

? Example

c

#include <stdio.h>int main() { for (int i = 1; i <= 5; i++) { if (i == 3) { continue; // Skip when i is 3 } printf("%d ", i); } return 0;}

Output:


1 2 4 5

? It skips i == 3 but keeps looping.


? With while or do...while

? break inside while

c

int i = 1;while (i <= 10) { if (i == 6) break; printf("%d ", i); i++;}


? continue inside do...while

c

int i = 0;do { i++; if (i == 2) continue; printf("%d ", i);} while (i < 5);

Output:

1 3 4 5

? Skips printing when i == 2


? Summary

StatementMeaning
breakExit the loop immediately
continueSkip to next loop iteration

Disclaimer for AI-Generated Content:
The content provided in these tutorials is generated using artificial intelligence and is intended for educational purposes only.
html
docker
php
kubernetes
golang
mysql
postgresql
mariaDB
sql