Wrong output in answer

I dont get what is wrong with my code as when i execute it in on sublime i get the answer which is 60 but here my answer keeps varying even when i divide the answer by 10^9+7

#include
using namespace std;

void printarray(int a[], int n){
int i,j,k,l;
for(i=0;i<n;i++){

}

}

int sumarr(int a[],int n){
int sum,i,j,k;
sum = 0;

for(i=0;i<n;i++){
	sum = sum + a[i];
}
return sum;

}

int main(){
int size,n,numop,backshift;
cin>>size;

if(size>0 && size<=100000){
	int arr[size] = {};

	int i,j,k,l;
	for(i=0;i<size;i++){
		cin>>n;
		if(n>0 && n<=1000000000){
			arr[i] = n;
		}
		else{
			break;
		}
	}
	printarray(arr,size);
	cin>>numop;

	if(numop>=0 && numop<=1000000){

		int b[size] = {};

		for(i=1;i<=numop;i++){
			cin>>backshift;

			for(j=0;j<size;j++){
				int x,y;
				x = arr[j];
				if(i-backshift<0){
					y = arr[size-backshift];
				}
				else{
					y = arr[j-backshift];
				}
				b[j] = x+y;
			}
			for(j=0;j<size;j++){
				arr[j] = b[j];
			}
			//printarray(b,size);
		}
		//printarray(b,size);

		int ans = sumarr(b,size);
		cout<<ans;
	}
}

}

hi @gunjit27_94aa0450736b408e
refer this–>

1 Like

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.