title: CodeChef Runtime Error “NZEC” on Problem “Vaccine Production” (C Language)
body: <p>I am trying to solve this beginner problem using C language:
  <a href="https://www.codechef.com/problems/VACCINE1" rel="nofollow noreferrer">https://www.codechef.com/problems/VACCINE1</a></p>
  <p>Would you please give me a hint of what can be wrong with the code below? I am getting the runtime error “NZEC”.</p>
  <p>I was suspecting it was a problem with the enum so I replaced it with an in variable, but the problem did not go away.</p>
  <p>Here is the solution code in CodeChef page (if you prefer to view like that):
  <a href="https://www.codechef.com/viewsolution/40469687" rel="nofollow noreferrer">https://www.codechef.com/viewsolution/40469687</a></p>
  <p>I am running it in a C++ project in Visual Studio. It runs normally in Visual Studio and the outputs matches the given outputs in the problem statements.</p>
  <p>Here is my code:</p>
  <pre><code>#include &lt;stdio.h&gt;
  
  void main(void)
  {
      enum productionStatus {
          CompanyA,
          CompanyB,
          BothCompanies
      } companyProducing;
  
      short int D1, V1, D2, V2, P, d = 0, day = 0, dayProductionStarts = 0, vaccineNo = 0;
      scanf(&quot;%hd %hd %hd %hd %hd&quot;, &amp;D1, &amp;V1, &amp;D2, &amp;V2, &amp;P);
  
      if (D1 &lt; D2) {
          companyProducing = CompanyA;
          day = D1;
      } else if (D1 &gt; D2) {
          companyProducing = CompanyB;
          day = D2;
      } else {
          companyProducing = BothCompanies;
          day = D1;
      }
  
      if (companyProducing == CompanyA) {
          while (1) {
              vaccineNo += V1;
              if (vaccineNo &gt;= P) {
                  d = day;
                  break;
              }
              if (day == D2) {
                  companyProducing = BothCompanies;
                  break;
              }
              day++;
          }
      }
  
      if (companyProducing == CompanyB) {
          while (1) {
              vaccineNo += V2;
              if (vaccineNo &gt;= P) {
                  d = day;
                  break;
              }
              if (day == D1) {
                  companyProducing = BothCompanies;
                  break;
              }
              day++;
          }
      }
  
      if (companyProducing == BothCompanies) {
          while (1) {
              vaccineNo += (V1 + V2);
              if (vaccineNo &gt;= P) {
                  d = day;
                  break;
              }
              day++;
          }
      }
  
      printf(&quot;%hd\n&quot;, d);
  }
  </code></pre>