Infinite for loop (#23252)

* Infinite for loop

A brief description of the infinite for loop was given along with an example.

* Added syntax highlighting
This commit is contained in:
wolfwhocodes
2018-12-02 08:22:31 +05:30
committed by Manish Giri
parent 37d71e01c7
commit 8848487622

View File

@ -133,6 +133,15 @@ The next section is a boolean condition that will be checked for true or false,
The final section is referred to as the 'increment/decrement'. Its job is to perform some operation every loop - usually adding or subtracting from the initial variable - after the code within the brackets has been run through. In this case, it's just adding one to the count. This is the most common way for the increment to be used, because it lets you keep count of how many times you've run through a for loop. The final section is referred to as the 'increment/decrement'. Its job is to perform some operation every loop - usually adding or subtracting from the initial variable - after the code within the brackets has been run through. In this case, it's just adding one to the count. This is the most common way for the increment to be used, because it lets you keep count of how many times you've run through a for loop.
An infinite loop is also possible in the for loop. An infinite for loop has absolutely no items in the paranthesis except for the two semi colons.
```C
for(;;) {
printf("This will also get printed forever unless the program is stopped!");
}
```
### Syntax Comparison ### Syntax Comparison
```C ```C