well im writing a program where the user enters a number from 2 to 1000 and it displays the prime numbers. Its in a loop and i want it to stop when the users enters 'n' or 'N'
well when i type n or N the program goes crazy haha. help me or if you can think of a better way to stop it using N or n !!
#include<iostream.h>
void main()
{
int num,isprime;
do
{
cout<<"Enter a number between 2 and 1000 :";
cin >> num;
for( int i = 2 ; i <= num; i++)
{
isprime = 1;
for( int j = 2 ; j <= i ; j++)
{
if( i == j)
continue;
else if( i % j == 0)
isprime = 0;
}
if(isprime)
cout<<i<<" " << endl;
}
}while (num != 'n' || 'N');
}