Take N as input. Print all prime numbers from 2 to N

#include
using namespace std;
int main() {
int N;
std:: cin>>N;
for (N=1; N<1000; N++)
for (int i=2; i<=N-1; i++)
{
if (N % i == 0)
break;
else if (i==N) {
std:: cout << i <<endl;

        }

}
return 0;
}

i am not getting any output for this code.
we need to print all the prime numbers till N.

In your else if condition i==N is never going to reach because, inner for loop runs for only i=2 to i=N-1.
Just, go through your code again.