Skip to content
EMPS intranet

Back to top
Hi!   Hi!           Start main()

Try stepping through the code


  Value and type of last evaluated expression: Address of array element: Address of array elementx:  (none)

Your browser does not support the canvas element which will make some the features unavailable.

If you are using Internet Explorer within the University of Exeter try going to the Settings menu (probably the gear shape at the top right of this page), selecting "Compatibility View settings", unchecking "Display intranet sites in Compatibility View" and reloading this page.

Code

 Header...
long factorial (int i);
int main(){
  ...
» printf("%ld\n", factorial(3)); » return 0;
} // The actual factorial function long factorial_real(int i){
  ...
» if (i<=1) return 1; » return i*factorial_real(i-1);
} // Publically-callable front-end to the // factorial function with error checking long factorial(int i){
  ...
» if (i<0) {// Error check » fprintf(stderr, "Factorial must be positive\n"); » return -1; } » return factorial_real(i);
}
Memory

factorial_real-3()

128
129
130
131
i = 1

factorial_real-2()

176
177
178
179
i = 2

factorial_real()

224
225
226
227
i = 3

factorial()

272
273
274
275
i = 3

NB: the actual memory address of each variable is the
address shown plus 4289269088 (0xFFA90D60).

Show Advanced options

.
Show output (Before looking at the output, work out what you think it put should be and see if you are right.)

Output

6
                                                                                                                                                                                                                                                                       

Validate   Link-check © Copyright & disclaimer Share
Back to top