Problems with Static Allocation
int Fact( N )
int N ;
{
if ( N > 0)
return Fact( N-1 ) * N ;
else
return 1 ;
}
Problems:
1. Nested procedure calls
2. Recursion
We need a STACK !
Fact assumes
N is in 0x1024
Overwrite value
of N with N-1
when we call
Fact( N-1) from
Fact (N) !
Previous slide
Next slide
Back to first slide
View graphic version