Please tell me the error and correct it

question-https://practice.geeksforgeeks.org/problems/subarray-with-given-sum/0

import java.util.Scanner;

public class SUB_ARRAY {

public static void main(String[] args) {
	Scanner input=new Scanner(System.in);
	int T=input.nextInt();
	while(T>0) {
		int i,j,sum=0,k=0;
		int size=input.nextInt();
		int total=input.nextInt();
		int data[]=new int[size+1]; 
		for(i=1;i<=size;i++) {
		   data[i]=input.nextInt();	
		}
		for(i=1;i<=size;i++) {
			   System.out.println(data[i]);
			}
		for(i=1;i<size;i++) {
			sum=sum+data[i];
			for(j=i+1;j<=size;j++) {
				sum=sum+data[j];
				if(sum==total) {
					System.out.println(i+" "+j);
					k=1;
					break;
				}
				else if(sum>total) {
					sum=0;
					break;
				}
			}
			if(k==1) {
				break;
			}
		}
		if(k==0){
		    System.out.println("-1");
		}
	}
}

}

it is running in eclipse ,while on other ide showing error ?

@KUNAL.SHARMA5724510,
https://ide.codingblocks.com/s/241247 corrected code.
You have not written T-- buddy.

Wrong Answer. !!!Wrong Answer Possibly your code doesn’t work correctly for multiple test-cases (TCs). The first test case where your code failed: Input: 5 12 1 2 3 7 5 Its Correct output is: 2 4 And Your Code’s output is: 1

https://practice.geeksforgeeks.org/problems/subarray-with-given-sum/0. CAN YOU GIVE ME A SOLUTION FOR THIS.

@KUNAL.SHARMA5724510,
For the input:
5 12
1 2 3 7 5

The correct input format is:
1
5 12
1 2 3 7 5

Here 1 is the number of test cases. 5 is size of array. 12 is target sum and in the third line we have the array inputs.

@KUNAL.SHARMA5724510,
The code I have sent you is correct. The only change is to the index. Just add 1 to each element you are printing as index.

I have myself submitted the code and validated the answer.

Also, I request you to please maintain the decorum while asking your doubts.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.