title: How can I calculate how many times the program has been run in C?
body: <p>Is it possible to count how many times that a program has been run in C?
  Do I need to setup a counter? For example:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main()
  {
      int var1;
      scanf("%d", &amp;var1);
  
      int var2;
      scanf("%d", &amp;var2);
  
      int var3;
  
      var3 =var1 + var2;
  
      printf("The answer is  = %d" , var3);
  
     /* if (The program ran for more than two times) {
          printf("The program is only allowed to run once or twice\n");
      }
      else {
        printf("The answer = %d" , var3);
      }*/
  
      return 0;
  }
  </code></pre>
  
  <p>If the program had been run over two times, the program will display the error message once and restart to count.</p>