Wrong output for C language solution


#1

If i give an input with the array of length 7 which is [1,0,2,0,3,0,3]
expected output here is 4
but the solution for language c gives output 3


#2
        #include<iostream>
        using namespace std;
        int main()
        {
            int A=7, B[]={1,0,2,0,3,0,3};
            int i,j,k,s1=0,s2=0,s3=0,count=0;
            for(i=0;i<A-2;i++)
            {
                s1=s1+B[i];
                j=i+1;
                s2=0;
                while(j<A-1)
                {
                    s2=s2+B[j];
                    j++;
                    if(s2==s1)
                    {
                        s3=0;
                        k=j;
                        while(k<A)
                        {
                            s3=s3+B[k];
                            //cout<<B[k]<<" ";
                            k++;
                        }
                        //cout<<"\n";
                        if(s3==s1)
                        {
                            count++;
                            //cout<<"Count"<< count++<< "\n";
                        }
                    }
                    //cout<<s2<<" ";
                }

            }
            //cout<<s1<<" "<<s2<<" "<<s3;
            cout<<count;
        }

Try this one its coming 4… its in c++ but I guess the only difference between the two language would be the output statement