cs441f10-hw7-key

cs441f10-hw7-key - var a,x: integer; begin a:~—~1; x:=a;...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: var a,x: integer; begin a:~—~1; x:=a; y:= a+x; Z:= 2*y + 2 end { october} ; procedure novembe (d : integer); var a,y: integer; procedure december; var x: in eger; begin x22 3+y; november(x) Lendidecemhen ‘ begin Y3: d; if d> 20 then write(z) else begin october; december end end{november}; begin z:= 10; november(z) end {management} . b-) The deepest nested block is at level 3, given that the main block is at level 0. B} 2 nested levels assuming the main block is Ievei Cl C) Note: execution history using static scoping since dynamic scoping does not end ;{ PROGRAM management Starts management CALLS november(10) november CALLS october october RETURNS november CALLS december december CALLS november(13) november CALLS october october RETURNS november CALIS december december CALLS novemberufii november CALLS october october RETURNS november CALLS december december CALLS november(19) november CALLS october october RETURNS novemlSer CALLS december december CALLS november(21) november CALLS write(21] november RETURNS december RETURNS november RETURNS december RETURNS november RETURNS december RETURNS november RETURNS december RETURNS november RETURNS management RETURNS " december = = 'ribvémberix] I . decamber' _ décémber" fioveijnbéflix}; ’- Hove'ynberfx); I 7. ‘répireifibedfl I éctpfigr niagagemént ' rn'ovemrbedz) 7' Vilc'tpbér E) 100 o Static Link 100 Dynamic Link Return Address 104 105 - 106 novemher 1 107 Static Link 100 108 Dynamic Link 100 109 Return Address 110 1 H H 112 Static Link octoher december 113 Dynamic Link 114 Return Address 11 U1 116 117 Static Link 118 Dynamic Link 119 Return Address 1 _ no 1 _ 107 1 1 10? 07 3 3 121 1 122 Static Link 100 123 Dynamic Link 617 124 Return Address 125 H U.) F) Static Scoping Output: 26 Dynamic Scoping 100 100 Address 100 Static Link 101 Dynamic Link 102 Return Address 103 104 105 14 10 107 Static Link 108 Dynamic Link 100 109 Return Address 110 111 112 Static Link 100 Dynamic Link 107 114 Return Address 115 116 117I Static Link 107 107 — 5 _ november 118 Dynamic Link 119 Return Address 12 O 121 122 Static Link 100 123 Dynamic Link 617 124 Return Address RA 125 126 Dynamic Scoping outputs nothing because dis never larger than 20, thus write(z) never gets called. The program will run indefinitely until a memory limit is reached, or the program is killed. ...
View Full Document

Page1 / 4

cs441f10-hw7-key - var a,x: integer; begin a:~—~1; x:=a;...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online