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...
// static demonstration float global=11.1;
void foo(int k){
  ...
» static int sum; » sum+=k; » if (k%2) // if k is odd foo(k+1); » printf("k is %d new global is %f\n", sum, ++global);
} int main(){
  ...
» int i, sum=0; » for (i=1; i<5; ++i) foo(i); » printf("Done, global is %f sum is %d\n", global, sum); » return 0;
}
Memory

Static variables

128
129
130
131
132
133
134
135
global = 11.1000004
?
?
?
?
176
177
178
179
foo:
sum =
0

foo-2()

312
313
314
315
k = 4

foo-2()

312
313
314
315
k = 2

foo()

360
361
362
363
k = 1

foo()

360
361
362
363
k = 2

foo()

360
361
362
363
k = 3

foo()

360
361
362
363
k = 4

main()

396
397
398
399
i = 134536434
400
401
402
403
sum = 0

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

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

k is 3 new global is 12.100000
k is 3 new global is 13.100000
k is 5 new global is 14.100000
k is 12 new global is 15.100000
k is 12 new global is 16.100000
k is 16 new global is 17.100000
Done, global is 17.100000 sum is 0
                                                                                                                                                                                                                                                                       

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