Q:

sieve c program

#include <stdio.h> 
#include <stdlib.h> 
#include <conio.h> 
#include <math.h> 
 
int main() 
{ 
	
	int n; 
	printf("Enter the limit: "); 
	scanf("%d",&n); 
	int A[n]; 
	 

	for(i=2;i<n;i++)A[i] = 1; 
	 

	 
	for(i=2;i<n;i++) 
	{ 
		for(j=i;i*j<n;j++) 
		{ 
			A[i*j] = 0; 
		} 
	} 
	
	 
	
	 
	for(i=2;i<n;i++) 
	{ 
		if(A[i]) 
		{ 
			printf("\n%d",i); 
		} 
	} 
	getch(); 
	return 0; 
	 
} 
0

New to Communities?

Join the community