Please tell whats the problem in the code

Showing the correct answer for sample case but wrong answer in submission.
#include
using namespace std;
int sum(int x)
{ int s=0;
while(x>0)
{
s+=x%10;
x=x/10;
}
return s;
}
int main() {
int n;long cn;
cin>>n;
for(int i=0;i<n;i++)
{
cn=0;

   cin>>cn;
    if(cn%2==0)
    {
        if (sum(cn)%4==0)
          cout<<"\nYes";
        else
          cout<<"\nNo"; 
    }
    else
    {
        if(sum(cn)%3==0)
          cout<<"\nYes";
        else
           cout<<"\nNo";
    }
    if(i==n-1)
      break;
}
return 0;

}

@parastandon4 You have to find the sum of all digits which are even and the sum of all digits which are odd separately. If the sum of all even digits is divisible by 4 or sum of all odd digits is divisible by 3, then only print β€œYes”. In all other cases print β€œNo”.
Check that you have done the same thing as i said.