/* File: rec_stack.c Demonstrate that local variables are placed on a "stack" even for recursive functions. */ #include double rec_func (int n) { double x, y ; if (n == 0) return 17.9 ; printf("n = %d: Address of n = %u, of x = %u, of y = %u\n", n, &n, &x, &y) ; x = rec_func(n-1) ; return x ; } main() { double x, y ; printf("Size of double = %d\n\n", sizeof(double) ) ; printf("main: Address of x = %u, of y = %u\n", &x, &y) ; x = rec_func(1) ; printf("\n") ; printf("main: Address of x = %u, of y = %u\n", &x, &y) ; x = rec_func(3) ; printf("\n") ; printf("main: Address of x = %u, of y = %u\n", &x, &y) ; x = rec_func(5) ; printf("\n") ; }