Boolean which changes its value : <p>In my code boolean value isIndefinite unexpectedly changes it's value to "true" after if (flag = true) {isIndefinite = true;} even though flag wasn't true. Can anybody tell me what kind of trivial mistake I made? :(</p>

<pre><code>#include &lt;iostream&gt;

using namespace std;

int rows = 3;
int columns = 4;
double primaryTab[3][4] = {
    {3, 3, 1, 12},
    {2, 5, 7, 33},
    {1, 2, 1, 8}
};

bool flag = true;
double multi;

int main()
{
    bool isIndefinite = false;
    for(int i = 0; i &lt; rows; i++) {
        for(int j = 0; j &lt; rows; j++) {
            if(i != j &amp;&amp; primaryTab[i][0] != 0) {
                multi = primaryTab[i][0] / primaryTab[j][0];
                for(int k = 0; k &lt; columns; k++) {
                    if((primaryTab[j][k] * multi) != primaryTab[i][k]) {
                        flag = false;
                    }
                } if (flag = true) {isIndefinite = true;} 
            }
        }
    }
    if(isIndefinite == true) {cout&lt;&lt;"Indefinite"&lt;&lt;endl;} 
}
</code></pre>
