DELHI'S ODD EVEN test

Question is
Due to growing Traffic Problem Kejriwal wants to devise a new scheme. The scheme is as follows, each car will be allowed to run on Sunday if the sum of digits which are even is divisible by 4 or sum of digits which are odd in that number is divisible by 3. However, to check every car for the above criteria can’t be done by the Delhi Police. You need to help Delhi Police by finding out if a car numbered N will be allowed to run on Sunday?

My program

#include
using namespace std;
int main()
{
/* int arr[1000];
int n;
long long x,y;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>arr[i];
}
for(int i=0;i<n;i++)
{
x=0;
y=0;
while(arr[i]!=0)
{
x=arr[i]%10;
arr[i]=arr[i]/10;
y=y+x;
}
if(y%4==0||y%3==0)
{
cout<<“Yes”<<endl;
}else
cout<<“No”<<endl;
}*/
int t,n;
long long x,y,z;
cin>>t;
while(t!=0)
{
x=0;
cin>>n;
while(n!=0)
{
z=0;
y=0;
x=n%10;
n=n/10;
if(x%2==1)
{
z=z+x;
}
else
if(x%2==0)
{
y=y+x;
}
}
if(y%4==0||z%3==0)
{
cout<<“Yes”<<endl;
}else
{
cout<<“No”<<endl;
}
//else{
//break;
//}
t–;
}
return 0;
}
here is my code please tell me the solution .

Hey Prabhjot, just initialise z=0 and y=0 in outer while loop instead of inner while loop

Thanks for helping now my program test case is passed.

#include
using namespace std;
int main(){
int n;
int ans=0;

cin>>n;
for(int i=1;i<=n;i++){
 int number;
	cin>>number;
	while(number>0){
		int n=number%10;
		number=number/10;
		ans=ans+n;
	}
	if(ans%2==0 and ans%4==0){
		cout<<"Yes"<<endl;
	}
	else if(ans%2==0 and ans%4!=0){
		cout<<"No"<<endl;
	}
	else if(ans%2!=0 and ans%3==0){
		cout<<"Yes"<<endl;
	}
	else if(ans%2!=0 and ans%3!=0){
		cout<<"No"<<endl;
	}

	}
	return 0;

}

can anyone please review it? ilts showing wrong test results.