I have avoided any use of global variables. I have replaced a global variable with a local static variable, which should ideally give what’s wanted. Why does it give different answers on (Test on custom input) and Test then?
static int also doesn’t work.use global variables and reset them in main function.
like int total=0 is global, you again make total=0 in beginning of main.