This preview shows pages 1–4. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Arizona State University Ira A. Fulton College of Engineering Computer Science and Engineering CSE 340 Fall 2009 TEST 2 State any assumptions you make . TOTAL 70 Write legibly . If I cannot read what you write, I cannot grade it! [10 points] Consider the following declarations. Which variables are structurally equivalent? Which variables are name equivalent (explicitly declared name)? typedef struct A { Answer int i; int j; } ; typedef struct B { int k; int l; } ; struct { int i; int j; } z, z1; A x, x1; B y, y1; [15 points] What is the output of the following program if parameters are passed by: value? name? reference? int a[2], i; int p(int a, int b) { int i; i = a; a = b; b = i+1; } Void main() { a[0] = 1; a[1] = 2; i = 0; p(a[i],a[i]) p rint(%d %d %d\ n, i, a[0], a[1] ); } [10 points] How does HindleyMilner type checking infers the type of the following declaration? fun fac(g, m, n) = if n = 0 then m else g( fac(g,n1),m,n) Assume arithmetic can only be done on values of the same type and that 1 and 0 are integers! Assume arithmetic can only be done on values of the same type and that 1 and 0 are integers!...
View
Full
Document
This note was uploaded on 02/27/2011 for the course CSE 340 taught by Professor Farley,t during the Fall '08 term at ASU.
 Fall '08
 Farley,T
 Computer Science

Click to edit the document details