title: C Programming Array Loop
body: <p>Any help would be much appreciated with this problem I've been having.
  I'm trying to create a loop to find a 30x30 array whose main diagonal values are all greater or equal than 7.
  The arrays are filled with random integers.</p>
  
  <p>My issue is the loop itself, I can't seem to figure out how to create such a large series of loops.. driving me nuts!</p>
  
  <p>When I've managed to create an array that meets the criteria, I need to display how many attempts it took. If it takes more than 1 million attempts, the program should simply "give up", displaying that it is not possible.</p>
  
  <p>This is what i've managed to come up with so far (not the entire code, just the bit I need help with), however the output is literally nothing. 
  I guarantee I'm not even close to the right solution... but I would appreciate a point in the right direction!</p>
  
  <p>Thanks in advance :) </p>
  
  <pre><code>count=0;
  
  for(a=0;a&lt;30;++a)
  for(b=0;b&lt;30;++b)
      random2[a][b]=rand()%10;
  
  while(count&lt;=1000000)
  {
  for(a=0;a&lt;30;++a)
  {
      if(random2[a][a]&gt;=7)
      {    
          ++a;
          if(a==30&amp;&amp;random2[a][a]&gt;=7)
              printf("%d", count);
      }
          else
          {
              ++count;
              for(a=0;a&lt;30;++a)
                  for(b=0;b&lt;30;++b)
                      random2[a][b]=rand()%10;
          }
  }
  }
  
  printf("%d", count);                    
  </code></pre>