Coding Global Background
Coding Global

need help understanding recursive function

Archived 2 years ago
6 messages
1 members
Created 2 years ago
Updated 2 years ago
Open in Discord
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);
}

Replies (6)