Coding Global Background
Coding Global

need help understanding recursive function

Archiviert 2 years ago
6 Nachrichten
1 Mitglieder
Erstellt 2 years ago
Aktualisiert 2 years ago
In Discord öffnen
K
korg03
i want to understand the backtracking as the recursion unwinds in the following code. Can somebody please explain the output.
#include<stdio.h>
void solve(int x);
int main()
{
  solve(3);
  return 0;
}
void solve(int x)
{
  if(x==0)
  {
    printf(" %d", x);
    return;
  }
  printf(" %d", x);
  solve(x-1);
  printf(" %d", x);
}

Antworten (6)