So here is what I have.
(Note I did add a swap in for if end < start)
//Requires: start > 0; end > 0; 0 <= digit <= 9
//Modifies: nothing
//Effects: runs the range of numbers from start to end inclusive
// if (end < start), it will swap start and end
// prints the number if any digit of the number is the
// same as 'digit'
// printIfHoldsDigit(5, 10, 7) //prints: 7
// printIfHoldsDigit(5, 30, 8) //prints: 8, 18, 28
// printIfHoldsDigit(1, 30, 2) prints: 2, 12, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
1 2 3 4 5 6 7 8 9 10
|
void printIfHoldsDigit(int start, int end, int digit)
{
for(start = start; start <= end; start++)
{
if (equalsDigit(start,digit) == true)
{
cout << start << ", ";
}
}
}
|
equalsDigit just returns true if a number holds a digit.
My issue is on my last print I can not have the ", " printing.
Anyone have an suggestions as to how to solve this issue.