Here is a program to find prime numbers using sieve of Eratosthenes. The program is compiling but on execution, it becomes non responsive.The print statement itself is not executed. Can I know where I have gone wrong?
#include<stdio.h>
int main()
{
printf("Enter the range");
int n,i;
scanf("%d",&n);
int j;
int a[--n];
for(i=0;i<n;i++)
a[i]=i+2;
for(i=0;i<n;i++)
if(a[i])
{
printf("%d",a[i]);
for(j=2;(i*j)<n;j++)
a[i*j]=0;
}
return 0;
}
Thanks