Consider the following function
int fun(int a[ ],int l, int target){
int i=0,j=0,sum=0,count=0;
while(j<l){
if(sum<target){
sum=sum+a[j];
j++;
}
else if(sum>target){
sum=sum-a[i];
i++;
}
else{
count++;
sum=sum-a[i];
i++;
}
}
if(sum==target)
count++;
return count;
}
If $a[ ]$ states the element
$a\left [ \right ]=\left \{ 2,3,3,2,.5,4,1,3,6,8,2,3,4,4,2,2 \right \}$
What will be return value of function call $fun\left ( a,16,8 \right )=$_______________
Given ans $6,$ but I got $4.$ Which one correct?? Any shortcut to evaluate??