Different answers on custom input and submit, even after not using a global variable

interview-questions
Tags: #<Tag:0x00007f2428387d38>

#1

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?


#2

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.