#include<iostream>
using namespace std;
int main()
{
    int i=2, j=2, n;
    
    cout<<"Enter a number to print Prime Number: ";
    cin>>n;
    
    cout<<i<<" ";
    
    for(i=2; i<=n; i++)
             for(j=2; j<i; j++)
             {
                      if(i%j == 0)
                      break;
                      else if(i==j+1)
                      cout<<i<<" ";
             }
             
    cout<<endl;
    
    system("pause");
    return 0;
}