When i write this code, It does the job but also prints some random stuff.
If my input is 32, it prints 23 followed a line of random numbers . example:
23 983748572819937482
I wanna know what these random numbers are and why they are being printed
#include <iostream>
using namespace std;
int reverse(int n) {
if (n == 0) {
cout << " ";
return 0;
}
else {
int lastdigit = n % 10;
int firstdigit = n / 10;
cout << lastdigit << reverse(firstdigit);
}
}
int main() {
int n;
cin >> n;
reverse(n);
}