I have an assignment to write a recursive function that writes the digits of a positive integer in reverse order. My problem is that the function doesn\'t display the reverse co
This solution will omit trailing zeroes, because it is literally reversing the content of the integer:
int reverse(int number, int n = 0) { if (number == 0) { return n; } else { int nextdigit = number%10; int nextprefix = n*10+nextdigit; return reverse(number/10 ,nextprefix); } }