User:ProtichCode/sandbox

C++ Prime number generator code.


 * 1) include

using namespace std;

main {

int number, flag=0;

cout<<"Enter the number"<>number;//number represent the maximum range of numbers where the prime numbers will be display that is (0-number)

int prime[number];

for(int n=2;n<=number; n++){

for(int i=2;i<=n/2; i++){ if(n%i==0) {       cout<<n<<" is not a prime number"<<endl; flag=1; break;

}

} if(flag==0) {         cout<<n<<" is a prime number"<<endl;

}    flag=0; } return 0; }