My issue
why it shows wrong answer?
why it is not satisfying? please let me know!
My code
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 product=1;
for(int i = 0; i < N; i++)
{
product=product*A[i];
}
if(product>=0){
cout<<0<<endl;
}
else
{
cout<<1<<endl;
}
}
return 0;
}
// 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;
cin >> N;
int A[N];
for(int i = 0; i < N; i++)
{
cin >> A[i];
}
int product=1;
for(int i = 0; i < N; i++)
{
product=product*A[i];
}
if(product>=0){
cout<<0<<endl;
}
else
{
cout<<1<<endl;
}
}
return 0;
}
Learning course: C++ for problem solving - 2
Problem Link: CodeChef: Practical coding for everyone