I want to find prime numbers in a given range. The output number must be separated by a comma.
#include <iostream>
using namespace std;
int main()
{
int i,j,lower, upper;
cin >> lower;
cin >> upper;
for (i = lower + 1; i < upper; i++)
{
for (j = 2; j < i; j++)
{
if (i % j == 0)
{
break;
}
}
if (j == i)
{
cout << i ;
cout << ",";
}
}
}
Input:11 20
Output must be : 13,17,19
but my code prints an extra comma and it is not just between the numbers. Would you please help me?!