Page 1 of 1

Q2 (a) Give a sketch of the implementation of the printf function in the C programming language. Just to mention, the pr

Posted: Mon May 09, 2022 6:09 am
by answerhappygod
Q2 (a) Give a sketch of the implementation of the printf
function in the C programming language. Just to mention, the printf
function takes variable number of arguments. (4)
(b) In many PL implementations, the hardware registers are
divided into two sets to implement the calling sequence. Why is
this done? (2)
Q3 What is the advantage of providing block structuring in
programming languages? Using an example, illustrate the static
scoping rules in block structured languages. For the example above,
explain how a compiler can implement static scoping? (6)
Q4 Give an example demonstrating the utility of having a local
array of a function, whose size is decided at run time. How is this
facility implemented by a programming language? (6)
Q5 (a) Give an example of the utility of an intern static
variable in the C programming language. How can intern static
variables be implemented? Where are they allocated space by typical
compilers? (3)
(b) Give an example of the utility of an extern static variable
in the C programming language. How is the facility of an extern
static variable implemented? (3)
Q6 Giving reasons, explain how a compiler optimizes the calling
sequence if it recognises a tail-recursive call. Can this
optimization be done by the interpreter as well?(3)