You either use just space to separate and put a space before every item. Or, you print a comma before every item, but you only do it after the first (0th) item:
#include <iostream>
int main()
{
const int count = 5;
int numbers[count] = { 1, 2, 3, 4, 5 };
// List just with space separator
std::cout << "The numebers are:";
for (int i = 0; i < count; i++)
std::cout << " " << numbers[i];
std::cout << std::endl;
// List with come separator
std::cout << "The numebers are: ";
for (int i = 0; i < count; i++)
{
if (i > 0)
std::cout << ", ";
std::cout << numbers[i];
}
std::cout << std::endl;
return 0;
}
I hope this helps. :)