how to remove the last comma between 2 prime number

    #include <iostream>
using namespace std;
int main(){
    int a=0 , b=0;
    cin>>a>>b;
    for(int i = a+1;i < b;i++){
        int counter = 0;
        for(int j = 2;j <= i / 2;j++){
            if(i % j == 0){
                counter++;
                break;
            }
        }
        if(counter == 0 && i!= 1){
            cout<<i<<",";
        }
    }

    return 0;
} 

hi guys how to remove the last comma from this code? i think we have to add 1 if statement but i dont know what should i do... please help me thanks



Read more here: https://stackoverflow.com/questions/68473791/how-to-remove-the-last-comma-between-2-prime-number

Content Attribution

This content was originally published by user16497151 at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: