What is the error in this code

Problem code: Intest (beginner)
It says runtime error
plz help me i m a beginner…

#include<stdio.h>
#define size 100000
int main()
{
        long A[size],k;
        int n,c=0;
        
        scanf("%d%ld",&n,&k);
        printf("Input\n%d  %ld",n,k);
        
        for(int i=0;i<n;i++)
        {
            scanf("\n%ld",&A[i]);
            printf("\n%ld",A[i]);
            
            if(A[i]%k==0)
                c++;    
        }
        printf("\n\nOutput:\n%d",c);
        
        return 0;
}
1 Like

Hey,
First of all you should remove all the unnecessary statements like printf(“Input\n%d %ld”,n,k); and
Output and only print the answer. Also try and use long instead of int for n and c, since outputs can be large.

You can refer to my solution for clarifications. CodeChef: Practical coding for everyone

1 Like

scanf("\n%ld",&A[i]);
that is an error because array You remove the & only A[i]; that will be run

1 Like