3 Number - | | |============| int fact (int n)
5 | | | |------------| if (0 == n) {
6 | | | | f = ? | return 1; <-------- PC
7 #4 main() < | | |------------| }
9 | | -+->|------------| ---> return n * fact (n - 1);
11 = | | |============| | }
13 | | | |------------| | main ()
14 #3 fact (3) < | | | o---------+- {
15 | -+-+->|------------| | | int i;
17 = | | |============| | | for (i = 0; i < 10; i++) {
18 | | | | n = 2 | | -> int f = fact (i);
19 | | | |------------| | printf ("%d! = %d\n", i , f);
20 #2 fact (2) < | | | o------+--| }
21 | | | ->|------------| | }
23 = | | |============| |
25 | | | |------------| |
26 #1 fact (1) < | | | o------+--|
27 | | | |------------| |
28 | ---|--+-----o |<-+------- FP
29 = | |============| | |
31 | | |------------| | |
32 #0 fact (0) < | | o--------- |
34 | --+-----o |<--------- SP |
37 | \/\/\/\/\/\/\/ Direction of
38 #-1 < \/\/\/\/\/\/\/ stack growth