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>
2
3using namespace std;
4
5int main(){
6
7 int i; //initialize integer
8 //i starts at 0 and stops at 4, as 5 is not < 5
9 for (i = 0; i < 5; i++){ //i++ means add 1 to i each iteration
10 cout << "number " + i << endl; //print 5 times
11 }
12 return 0;
13}
14//output:
15/*
16number 0
17number 1
18number 2
19number 3
20number 4
21*/
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
1for(int i =0; i<6;++i){//initialize;condition;updation
2 cout<<i<<endl;//code block
3}//first it initializes, then checks the condition, then runs the code block and at last updates 'i'
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
12
13
14
15loop c++C++ By Zearz on Feb 25 2020
16for (int i = 0; i < 5; i++) {
17 cout << i << "\n";
18}