For loop not behaving as expected without nested do-while
<p>I wrote the following code to shuffle a deck of cards:</p>

<pre><code>int i,j;  
for(int x=1;x&lt;53;x++) {
   i=rand()%4;  
   j=rand()%13;  
   if(deck[i][j]=0)  
       deck[i][j]=x;
   else
       x--;
}  
</code></pre>

<p>That didn't produce any result, whereas the following code produced results:</p>

<pre><code>int i,j;  
for(int x=1;x&lt;53;x++) {
    do {
        i=rand()%4;  
        j=rand()%13;
    } while(deck[i][j]!=0);  
    deck[i][j]=x   
}  
</code></pre>

<p>What difference causes this?  </p>
