title: Generating a Sparse Matrix in C
body: <p>Is there a simpler way of generating  sparse matrix other than this?</p>
  
  <pre><code>for (i = 0; i &lt; 1000; i++)
  {
      if (rand() % 3 == 0)
      {
          array[i] = rand() % 3;
      }
      else
      {
          array[i] = ((rand() % 3) - 1);
      }
  }
  </code></pre>
  
  <p>Thanks.</p>
  
  <p>I used array for presentational purposes</p>