Initialise sum to 0 for each test case so that you calculate sum of array values for each test case seperately. Look at the third test case in these programs … your original code and edited code.
@vinayawsm thanks mister…i wish i could give you a positive feedback but sorry i have less reputation…
.