I am tyring to write a program that reads an integer n from the keyboard, and prints n, n-1, ... n, using a recursive function. The code below works, but I don't completely understand why or the steps involving the recursive function. Could someone please explain?
void countingdown(int n){
if (n == 1){
printf("%d\n", n);
return;
}
else {
printf("%d\n", n);
countingdown(n - 1);
return;
}
}
int main(){
int n;
printf("Enter an integer: ");
scanf("%d", &n);
countingdown(n);
printf("\n");
return 0;
}