1//'i' can be any number
2//Can be any comparison operater
3//can be any number compared
4//can be any mathmatic operater
5
6for (int i = 0; i<100; i++){
7//Do thing
8}
9
10//more info on operaters
11//https://www.w3schools.com/cpp/cpp_operators.asp
1#include <iostream>
2using namespace std;
3
4int main()
5{
6 for (int i = 0; i < 20; i++)
7 {
8 cout << i << endl;
9 }
10 //prints the number (i)
11}
1
2
3
4for (int i = 0; i < 10; i++){
5 //Do something as long as i is less than 10,
6 //In that case it will loop 10 times
7 //use break; to restart the loop whenever you want to cancel the loops.
8 cout << i;
9
10 //at the end, remember i will be increased by 1.
11}
12
13//output 0123456789
1// There are 2 loops in ++ :
2
3while(1==1){ }
4// | | |
5// | What happens while condition is true
6// |
7// the condition
8
9
10//for loop
11
12for (int i; i < 10; i++){ }
13// |___| |___| |_| |__|
14// | | | |
15// | | | what happens when conditons is true
16// | | what happens each time loop is reapeted
17// | The condition in wich the loop is true
18// a variable declaratoin
1//limit can be any number
2//you can use any comparison operator
3
4for(int iteration = 0; iteration < limit_number; iteration++)
5{
6 //action in for loop
7}