SIGABRT Error

#include
using namespace std;

int main() {

long t;
long long n,c,d;
cin>>t;
for(long long i=0;i<t;i++)
{
   cin>>n;
   c=0;
   d=0;
   long long *a=new long long[n];
    for(long j=0;j<n;j++)
       {
           cin>>a[i];
           if(a[i>0])
            c++;
           else
            d++;
       }
       if(c>d)
       cout<<c<<" "<<d;
       else
        cout<<d<<" "<<c;
       
        
}

}

I get SIGABRT error in this code. Everything seems fine. I need help to solve this.

I think you has mistakenly used i instead of j in the inner for loop for indexing array a .

YOU RAN A LOOP FOR J=1->N AND USED A[I] …THIS IS RESULTING IN THE ERROR

I think this is just a basic error. You have used the loop for j and you have used i as the index. Please fix that and let us know if it works :slight_smile: