title: Generating random number in sorted order
body: <p>I want to generate random number in sorted order.
  I wrote below code:</p>
  
  <pre><code>void CreateSortedNode(pNode head)
  {
      int size = 10, last = 0;
      pNode temp;
      while(size-- &gt; 0) {
          temp = (pnode)malloc(sizeof(struct node));
          last += (rand()%10);
          temp-&gt;data = last;//randomly generate number in sorted order
          list_add(temp);
      }
  }
  </code></pre>
  
  <p>[EDIT:]
  Expecting number will be generated in increased or decreased order: i.e {2, 5, 9, 23, 45, 68 }</p>
  
  <pre><code>int main()
  {
  int size = 10, last = 0;
          while(size-- &gt; 0) {
              last += (rand()%10);
              printf("%4d",last);
          }
  return 0;
  }
  </code></pre>
  
  <p>Any better idea?</p>