From 19ef5250e6a64f7a7185684c33c83ebc105f337b Mon Sep 17 00:00:00 2001 From: kavyasreek9 <32074980+kavyasreek9@users.noreply.github.com> Date: Mon, 17 Dec 2018 21:15:37 +0530 Subject: [PATCH] Updated index.md (#26819) * Updated index.md Included description and examples of break and continue statements using for loop. * fix: formatting --- guide/english/c/for/index.md | 51 ++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/guide/english/c/for/index.md b/guide/english/c/for/index.md index 102d8e1a56..e205ba5f36 100644 --- a/guide/english/c/for/index.md +++ b/guide/english/c/for/index.md @@ -47,7 +47,7 @@ int main () { > Item on index 3 is 4 > Item on index 4 is 5 ``` -## Example for printing star pattern for pyramid +### Example for printing star pattern for pyramid ```c #include @@ -101,7 +101,7 @@ for ( ; ; ) { An infinite loop occurs when the condition will never be met, due to some inherent characteristic of the loop. An infinite loop also called an endless loop, and it is a piece of coding that lacks a functional exit so that it repeats indefinitely. -## Warning! +### Warning! Some older versions of compilers don't support declaration inside the for loop: ```C @@ -131,3 +131,50 @@ int main () { } } ``` + +## Break and Continue statements +When "break" statement is executed, the loop stops executing all other statements in it and immediately comes out of the loop. + + ```C +#include + +int main(void) { + int n = 5,i; + for(i=0;i + +int main(void) { + int n = 5,i; + for(i=0;i