Could anyone explain this ? Help me to understand this statement
This code is c++ and it will display a Christmas Tree I just copied from google /* ---------------------------------------- */ #include <iostream> using namespace std; int main() { int n = 5; for( int i = 1; i <= n; i++ ) { for( int k = i; k <= n - 1; k++ ) { cout << " "; } for( int j = 1; j <= i; j++ ) { if( j % 3 == 0 ) { cout << "o "; } else if( j % 3 == 1 ){ cout << "* "; } else { cout << "# "; } } cout << endl; } } /* ---------------------------------------- */ I am confuse with this statement ( j % 3 == 0 ) and ( j % 3 == 1 ) . I understand the j (var) it will loop and count 1 2 3 4 5 but the following code I dont really understand the % 3 == 0 and % 3 == 1 . Could anyone help me to understand this and give me some explaination bout this.