Using c Create a program to find all the prime numbers betwe
Using c++
Create a program to find all the prime numbers between 1 and max . This time, use a classic
method called the \"Sieve of Eratosthenes.\" Write your program using this method.
Solution
here is the code:
#include <iostream>
using namespace std;
const int limit=100;
int main()
{
int arr[limit] = {0};
for (int i = 2; i < limit; i++)
{
for (int j = i * i; j < limit; j+=i)
{
arr[j - 1] = 1;
}
}
for (int i = 1; i < limit; i++)
{
if (arr[i - 1] == 0)
cout << i << \"\\t\";
}
return 0;
}
for further queries kindly get back
