for loop ++i or i++ code example
Example 1: ++i vs i++ java
int i = 3;
int a = i++; // a = 3, i = 4
int b = ++a; // b = 4, a = 4
Example 2: ++i vs i++ java
int a = 0;
int b = a++; // b = 0; a = 1
a = 0;
b = ++a: // b = 1; a = 1
Example 3: for loop in c++
for ( int i = 0; i < 5; i++)
{
cout << "Hello" << endl;
}
// prints hello 5 times.
Example 4: for loop in c++
for (int i = 0; i < 10; i++)
{
cout << i << endl;
}