Reputation:
Help! I am trying to print my code is giving the correct output BUT with an extra space that is not supposed to be there.
for (int i = i; i <= input; i++)
{
cout << factorial(input)/ (factorial(i) * factorial (input - i)) << " ";
}
return 0;
}
Upvotes: 0
Views: 280
Reputation: 50190
Dont pad with space at the end on the last element
for (int i = 1; i <= input; i++)
{
cout << factorial(input)/ (factorial(i) * factorial (input - i));
if(i < input)
cout << " ";
}
Upvotes: 1