#include <iostream>

#include <iomanip>

#include <cstdlib>

using namespace std;

int lowlim, uplim;

int total_non = 0;

int total_prime = 0;

int flag;

int main ()

{

cout<<"This program will check for prime numbers.\n";

cout<<"Please enter an upper limit lower than 100:\n";

cin>> uplim;

if (uplim>100){

cout<<"Please enter a number lower than 100.\n";

cin>>uplim;

if (uplim>100) {

cout<<"You entered an invalid number again - goodbye!\n";

exit(0); }}

cout<<"Please enter a lower limit which is lower than the upper limit.\n";

cin >> lowlim;

if (lowlim<0){lowlim=-(lowlim);

if (lowlim>uplim) {

cout<<"Please enter a number lower than the upper limit.\n";

cin>>lowlim;

if (lowlim>uplim){

exit(1); } }}

else if (lowlim>uplim) {

cout<<"Please enter a number lower than the upper limit.\n";

cin>>lowlim;

if (lowlim>uplim){

exit(2);}}

for(int counter=lowlim; counter <= uplim; counter++)

{

flag=0 ;

for(int counter2 = 2; counter2 <= uplim; counter2++)

{

if((counter!=counter2)&&(counter % counter2 == 0))

{

flag=1 ;

total_non=total_non + 1;

break;

}

if (flag==0)

{

total_prime=total_prime+1;

cout << setw(4) << counter;

break;

} } }

return 0;

}