#include <iostream> using namespace std; int main(){int q=0; int n; cout<<"Enter:\n"; cin>>n; for(int i =1;i<=n;++i){int k=0; for(int j =0;j<=i;j++){ if(i%j==2){ ++k; } } if(k == 2){ cout<<i; } cout<<"\n"; } return 0;}
The Above code is not working.. when compiled and ran (using CodeBlocks) the top cout statement works, after entering the value of 'n', the ".exe" stops working. Why is that? Please Help
The code was for printing primes till 'n'