# Help me in solving AOCV215 problem

### My issue

include <bits/stdc++.h>
using namespace std;

int main()
{
int t;
cin >> t;

``````while(t--)
{
int N;
int product=1;
cin >> N;
int A[N];
for(int i = 0; i < N; i++)
{
cin >> A[i];
}
for(int i=0;i<N;i++){
product=product*A[i];
}
if(product<0){
cout<<"1"<<endl;
}
else if(product>=0)
{
cout<<"0"<<endl;
}

}
return 0;
``````

}
this is my code can you guys help me find out the error

### My code

``````// this code has some logical error - debug this code to solve the problem

#include <bits/stdc++.h>
using namespace std;

int main()
{
int t;
cin >> t;

while(t--)
{
int N;
int product=1;
cin >> N;
int A[N];
for(int i = 0; i < N; i++)
{
cin >> A[i];
}
for(int i=0;i<N;i++){
product=product*A[i];
}
if(product<0){
cout<<"1"<<endl;
}
else if(product>=0)
{
cout<<"0"<<endl;
}

}
return 0;
}
``````

Learning course: C++ for problem solving - 2
Problem Link: CodeChef: Practical coding for everyone

@priyaranjan11
u can do it like this

``````// Solution as follows

#include <bits/stdc++.h>
using namespace std;

int main()
{
int t;
cin >> t;

while(t--)
{
int N;
cin >> N;
int A[N];
for(int i = 0; i < N; i++)
{
cin >> A[i];
}
int count_neg = 0;
int count_zero = 0;
for(int i = 0; i < N; i++)
{
if(A[i] == 0)
{
count_zero++;
}
else if(A[i] < 0)
{
count_neg++;
}
}
// The condition to check the count of zeros was missing
if((count_zero > 0) || (count_neg%2 == 0))
{
cout << 0 << endl;
}
// The condition where count_neg is odd was missing
else
{
cout << 1 << endl;
}
}
}
``````