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:
#include <stdio.h>
int main()
{
int var1;
scanf("%d", &var1);
int var2;
scanf("%d", &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;
}
If the program had been run over two times, the program will display the error message once and restart to count.