C Language 👨‍💻
47.6K subscribers
This channel will serve you programs of C language.
Admin : @jeNiShsoNi

Useful channels :
@c_channels
@DeCODE_C
@pyGuru
Download Telegram
135. Sieve of Eratosthenes : An algorithm to generate all the prime numbers within an range.

#include <stdio.h>
#define size 1000

int main (void)
{
int n;
scanf("%d",&n);
int arr[size]={0};

for(int i=2;i*i<=n;i++)
{
for(int j=i;i*j<=n;j++)
{
arr[i*j]=1;
}
}
for(int i=2;i<=n;i++)
{
if(!arr[i])
printf("%d ",i);
}
return 0;
}
#program_by : @freakyLuffy