Update index.md , adding for loop examples (#24388)

* Update index.md

* Added code formatting to changes
This commit is contained in:
kushan2018
2018-12-08 09:05:29 +05:30
committed by Manish Giri
parent ca96fd91a6
commit 4618195026

View File

@@ -97,6 +97,25 @@ If this were a while loop, the code within the brackets would never get run beca
## For loops ## For loops
For loops are for when we want something to run a set number of times. 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 <stdio.h>
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 ### Syntax
``` ```
for(initialisation; condition; changer) for(initialisation; condition; changer)