Update index.md , adding for loop examples (#24388)
* Update index.md * Added code formatting to changes
This commit is contained in:
@@ -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)
|
||||||
|
Reference in New Issue
Block a user