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