C++ Range Prime Number

#include<iostream>
using namespace std;
int main()
{
    int n, m, i, j, c = 0;

    cout << "Enter Positive Number Range : ";
    cin >> n >> m;
    cout << endl;

    if(n < 0 || m < 0)
    {
        cout << "Negative are not allow..\n";
    }
    else
    {
        for(i=n; i<=m; i++)
        {
            c = 0;
            if(i == 0 || i == 1)
            {
                continue;
            }
            for(j=2; j<=i/2; j++)
            {
                if(i % j == 0)
                {
                    c = 1;
                }
            }
            if(c == 0)
            {
                cout << i << " ";
            }
        }
    }
    cout << endl;

    return 0;
}

Comments