c - stack function call problem -


I have a function called fun1 () , which is used for recursive I'm confused about the first call for fun (- n); What will it do and how will my stack pop up after each function ends?

  zero fun (int n) {if (n> gt;) {fun (- n); Printf ("% d", n); Fun (- n); }}   

My main task is given below:

  int a; One = 3; Fun (a);   

I want to know the order of execution and what will happen before, during and after the function call of my stack first funny (n)

Your output will be 0, then 1, then 2, and then 0.

  1. initially called 3
  2. Larger than 0, it makes fun calls (- n), which makes it 2.
  3. It does not go until it stays 0. until it continues.
  4. It continues in printf (), and prints 0 on the console.

    What you are not seeing is an intermediate call, it is a complete output (before n & gt; part):

      Before n fun Call & gt; 0; N = 3 n & gt; Funny call before 0; N = 2 n & gt; Funny call before 0; N = 1 n & gt; Funny call before 0; Fun Call Before N = 0 0 n & gt; 0; N = -1 1n> Funny call before 0; N = 0 2n & gt; Funny call before 0; N = 1 n & gt; Funny call before 0; Fun Call Before N = 0 0 n & gt; 0; N = -1    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -