title: Check for validation if Input exceeds the available stocks
body: <p>Can anybody help me fix the validation of my program</p>
  
  <p>actual output of my program:</p>
  
  <p>choice <code>1. Import</code> I input 2 times, my 1st input is <code>100</code> 2nd input is <code>200</code></p>
  
  <p>so when viewing the choice <code>2. Storage</code> output will be this</p>
  
  <pre><code>Year    sets
   1      100
   2      200
  </code></pre>
  
  <p>total of <code>300</code> sets of computer in storage</p>
  
  <p>now in choice <code>3. Sell Order</code> I input <code>400</code> so it will display <code>Sorry we have No enough Stocks !</code></p>
  
  <p>my problem is when viewing my <code>3. Storage</code> again all stocks are now empty</p>
  
  <pre><code>Year    sets
   1        0
   2        0
  </code></pre>
  
  <p>I am expecting that when my Input exceeds the available stocks it will not continue reduced the stocks in my storage</p>
  
  <pre><code>int main(void) {
      int choice = 0;
      int year = 1, i, com;
      int storage[99] = { 0 };
  
      for (;;) {
          clrscr();
  
          printf("Year %d\n\n", year);
  
          printf("1. Import\n");
          printf("2. Storage\n");
          printf("3. Sell Order\n");
  
          printf("\nchoice: ");
  
          scanf("%d", &amp;choice);
  
          if (choice == 1) { // import
              clrscr();
              printf("Enter sets of computer's imported: ");
              scanf("%d", &amp;storage[year]);
              year++;
          }
          if (choice == 2) { // storage
              clrscr();
              printf("Year    sets\n");
  
              for (i = 1; i &lt; year; i++) {
                  printf("%2d     %4d\n", i, storage[i]);
              }
              getch();
          }
          if (choice == 3) { //order
              printf("Enter Sets of Computer ordered: ");
              scanf("%d", &amp;com);
  
              for (i = 0; com &amp;&amp; i &lt; 99; i++) {
                  if (com &lt;= storage[i]) {
                      storage[i] = storage[i] - com;
                      com = 0;
                  } else {
                      com = com - storage[i];
                      storage[i] = 0;
                  }
              }
              if (com &gt; storage[i]) { // validation
                  printf("Sorry we have No enough Stocks !");
                  getch();
              }
          }
      }
  }
  </code></pre>