The Question:- https://www.codechef.com/JUNE17/problems/NEO01
My solution, which according to me should be the right solution to the aforementioned question but I am constantly getting a RTE.
#include<stdio.h>
int main()
{
    long arr[10000];
    int t,n,p=0;
    scanf("%d",&t);
    while(t--)
    {
        long hap1=0,hap2=0;
        scanf("%d",&n);
        for(int i=0;i<n;i++)
        {
            scanf("%d",&arr[i]);
        }
        for(int i=0;i<n;i++)
        {
            if(arr[i]>=0)
            {
                hap1+=arr[i];
                p++;
            }
            else
            {
                hap2+=arr[i];
            }   
        }
        printf("%d\n",hap1*p+hap2);
    }
    return 0;
} 
Edit: Sorry, I am a beginner who usually uses cout and cin, used scanf and printf to save time, and just forgot to add & while using scanf.
Although my code works fine on Dev-C++ 5.11 it shows a Runtime error(SIGSEGV) and I have no idea why is it happening.
 
     
    