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// initialization of variables
2
3#include <iostream>
4using namespace std;
5
6int main ()
7{
8 int a=5; // initial value: 5
9 int b(3); // initial value: 3
10 int c{2}; // initial value: 2
11 int result; // initial value undetermined
12
13 a = a + b;
14 result = a - c;
15 cout << result;
16
17 return 0;
18}