I have problem understanding this code:
#include <iostream>
using namespace std;
void Print_numm(int numm){
cout<<numm;
if (numm<=4) {
Print_numm(numm+1);
}
cout<<numm;
}
int main() {
Print_numm(1);
return 0;
}
The output is 1234554321. I understand the recursion up until it prints 123455. But why the compiler prints the rest of of numbers down to 1? Does the compiler do the second "cout" every time? And if so how it keeps the numbers until they are printed up to 5 and then prints the rest downward?
cout<<numm;, it stops at everyPrint_numm(numm+1)and continues when its done.