All pastes #978168 Raw Edit

Anonymous

public text v1 · immutable
·published 2008-04-09 10:49 UTC
rendered paste body
/* recur.c -- recursion illustration */

#include <stdio.h>

void up_and_down(int);



int main(void)

{

    up_and_down(1);

    return 0;

}



void up_and_down(int n)

{

    printf("Level %d: n location %p\n", n, &n); /* 1 */

    if (n < 4)

         up_and_down(n+1);

    printf("LEVEL %d: n location %p\n", n, &n); /* 2 */



}




The output looks like this:








Level 1: n location 0x0012ff48

Level 2: n location 0x0012ff3c

Level 3: n location 0x0012ff30

Level 4: n location 0x0012ff24

LEVEL 4: n location 0x0012ff24

LEVEL 3: n location 0x0012ff30

LEVEL 2: n location 0x0012ff3c

LEVEL 1: n location 0x0012ff48