Instead of always printing like this:
printf("%d,", i);
you need to be a little cleverer - ort you list will always end with a comma:
2, 3, 5, 7, 11, 13, 17,
So ... set a variable before the loop to zero and check it in the loop:
if (isPrime)
{
if (isNotFirst)
{
printf(",");
}
printf("%d", i);
isNotFirst = 1;