Fixed some typos. (#26138)

pull/23744/head^2
Hardik Sharma 2018-11-14 20:22:45 +05:30 committed by Aditya
parent c0f3fa124a
commit caaa78346b
1 changed files with 3 additions and 3 deletions

View File

@ -2,7 +2,7 @@
title: For Loop
---
A For Loop is a repetitive statement that is used to check for some condition and then based upon the condition a block of code is executed repeatedly until the specified condition is satisfied.
A For Loop is a repetitive statement that is used to check for some condition and then, based upon the condition a block of code, is executed repeatedly until the specified condition is satisfied.
The for loop is distinguished from other looping statements through an explicit loop counter or loop variable which allows the body of the loop to know the exact sequencing of each iteration.
@ -110,10 +110,10 @@ value of a: 19
```
## Explanation
Here's the initialization condition is first set to a=10. The loop first checks for this condition. It then checks for the condition expression i.e a<20 which holds true as 10<20(for the first case). Now the body of the loop is executed and we get the output "Value of a: 10". Then the update expression is executed which adds the number 1 to 'a' and the value of 'a' gets updated to 11 and the same steps are followed (as above) until the value of v reaches less than 20 i.e 19.
Here, the initialization condition is first set to a=10. The loop first checks for this condition. It then checks for the condition expression i.e. a<20 which holds true as 10<20(for the first case). Now the body of the loop is executed and we get the output "Value of a: 10". Then the update expression is executed which adds the number 1 to 'a' and the value of 'a' gets updated to 11 and the same steps are followed (as above) until the value of v reaches less than 20 i.e 19.
# Range-based for-loop
C++ also has what we call range-based for loops which iterates through all the elements of a container(e.g. array).
C++ also has what we call range-based for loops which iterates through all the elements of a container (e.g. array).
## Syntax