text: C ++ program for the above approach
code: #include <bits/stdc++.h> NEW_LINE #include <iostream> NEW_LINE using namespace std ; bool prime [ 10000001 ] ; void swap ( int * a , int * b ) { int temp = * a ; * a = * b ; * b = temp ; }