c262f98t2

# c262f98t2 - CSc 262 Test 1 Friday 23 October 1998 >ANSWERS<...

• Notes
• nizhes
• 3

This preview shows pages 1–2. Sign up to view the full content.

CSc 262 Test 1 Friday 23 October 1998 >>>>>>>>>>>>>>>>>ANSWERS<<<<<<<<<<<<<<<<<<< 1. (15 pts) Suppose we have the program ONE below, which is written in some programming language, say ELBONIAN. PROGRAM ONE; INTEGER GLOBAL; INTEGER ARRAY LIST[1..3]; PROCEDURE SUB(PARAM1:INTEGER; PARAM2:INTEGER); BEGIN PARAM1=6; PARAM2=PARAM2+1; GLOBAL=GLOBAL+1; PARAM1=5; END; BEGIN LIST[1]=1; LIST[2]=2; LIST[3]=3; GLOBAL=1; SUB(LIST[GLOBAL],GLOBAL); END. Fill out the following table, giving the values of GLOBAL and LIST after returning from the call to SUB, with the given method of passing the parameter. method of passing parameter GLOBAL LIST[1] LIST[2] LIST[3] ---------------------------------------------------------------- RESULT ? 5 2 3 VALUE 2 1 2 3 VALUE-RESULT 2 5 2 3 REFERENCE 3 5 2 3 NAME 3 6 2 5 ---------------------------------------------------------------- 2. (15 pts) In designing a language in which @ and # are binary operators, explain what rules you must consider in deciding how the compiler will evaluate the syntactically correct expression 4#2#[email protected](x#f(x))@4, where f(x) is a function call. We have to have a rule for determining the precedence of # versus @, i.e., whether one should be evaluated before the other. We have to have an associativity rule for #, i.e., whether a#b#c should be evaluated as (a#b)#c or a#(b#c), and an assoicativity rule for @. We have to have a rule for when the contents of parentheses, (), should be evaluated. We have to have a rule for which member of a the pair in the express a#b should be evaluated first before applying the # operator.

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

This is the end of the preview. Sign up to access the rest of the document.
• Spring '08
• varies
• pts, Subroutine, different data types, implicit GOTOs

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern