COMP.CS.400 Principles of Programming Languages exam 7.12.2020 NOTE: REMOTE EXAM & GOOGLE ETC ALLOWED 1. What phases does compiling typically contain (also explain briefly what is done is each phase?) *How does the situation change, if we have an interpreter and not a compiler* (i.e. how does it affect the phases and what is done in them)? 2. In which phase of compilation is the following error noticed? Justify your choice with one sentence: a. A semicolon is missing between two statements (in a language that requires semicolons between statements). b.A function call and the corresponding function definition contain a different number of parameters. c.In "a=f()" the return value of the function "f" has the wrong type so it cannot be assigned to variable "a". d.An undefined variable is used. e.A string literal is missing the final quotation mark. f.An illegal character (like @) is used in a variable name. g.A function call is missing the final parenthesis. h.In "a/b" division by zero happens because earlier "b" got its value from user input and the user entered 0. 3.Terminology Explain the terms (i.e., prove that you understand the term) AND how the terms in each pair are related to each other (i.e., how one affects the other, or some other relevant connection) a."Activation record" and "value semantics" b."Heap" (memory management) and "garbage collection" c."Static typing" and "type inference" (type deduction) d."Variable's scope" and "variable's lifetime" e."Abstract syntax tree" and "symbol table" 4. Below is a simple C++ function based on imperative programming. Tell which parts of the code would be impossible using the functional programming paradigm, and why. bool average(vector v, double& result) { // Count the average if all values are positive, fail otherwise int sum = 0; for (int i=0; i v, double& result) { // Count the average if all values are positive, fail otherwise int sum = 0; for (int i=0; i