This program is for printing prime numbers till the input given and separating every prime number with a comma.
void main(){ int N, counter=0, isPrime;
Just decide from a pre condition:
bool first = true; for(j=2;j<=N;j++){ // ... if(k==N) { if(!first) { cout << ','; } else { first = false; } cout<