can someone optimise this code

int main()

{

long n,k;

scanf("%ld
",&n);

long a[n];

for(long i= 0;i<n;i++)

scanf("%ld
",&a*);

for(long i=0;i<n;i++)

{

k=0;

for(long j=3;j<a*;j++)

if(j%3==0 || j%5==0)

k=k+j;

if(k>0)

printf("%ld
",k);

else

printf("%ld
",k);

}

return 0;

}

Is it for https://www.hackerrank.com/contests/projecteuler/challenges/euler001 ?

The code has to be corrected first since it does not read input properly. You need to remove **
** from the scanf calls.

Secondly, there are a lot of references on the net how to solve problem #1 of Project Euler. See for example https://www.mathblog.dk/project-euler-problem-1/