In the below code, I have used bitmasking for generating primes butunfortunately it doesn't work properly rather this programme is crashing while running.
#include <bits/stdc++.h>
#define maxn 65540
using namespace std;
int _c[(maxn>>6)+1]; //as we will be neede max
int primes[maxn];
#define IsComp(n) (_c[n>>6]&(1<<((n>>1)&31)))//to compare bit
#define SetComp(n) _c[n>>6]|=(1<<((n>>1)&31))//to set the bit
void prime_sieve() {
for (int i = 3; i <=maxn; i += 2)
if (!IsComp(i))
for (int j = i*i; j <=maxn; j += i+i)
SetComp(j);//if the number is not primes then it is changed to 1
primes[0]=2;//first prime is 2;
int j=1;
for (int i=3; i <= maxn; i += 2)
if (!IsComp(i))
primes[j++]=i;//putting the value in primes array;
}
int main()
{
prime_sieve();//calling the function
//Prime();
}