From 4618195026d78e15733b0085075a67c5807734a2 Mon Sep 17 00:00:00 2001 From: kushan2018 <38235669+kushan2018@users.noreply.github.com> Date: Sat, 8 Dec 2018 09:05:29 +0530 Subject: [PATCH] Update index.md , adding for loop examples (#24388) * Update index.md * Added code formatting to changes --- guide/english/c/loops/index.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/guide/english/c/loops/index.md b/guide/english/c/loops/index.md index 07bf37633b..d10d2ef0ab 100644 --- a/guide/english/c/loops/index.md +++ b/guide/english/c/loops/index.md @@ -97,6 +97,25 @@ If this were a while loop, the code within the brackets would never get run beca ## For loops For loops are for when we want something to run a set number of times. +## Here is an example to print from A to Z +```c +#include +int main() +{ + char c; + + for(c = 'A'; c <= 'Z'; ++c) + printf("%c ", c); + + return 0; +} +``` +**Output** +```c +A B C D E F G H I J K L M N O P Q R S T U V W X Y Z +``` + + ### Syntax ``` for(initialisation; condition; changer)