Cs 470 Name Test 1 Spring 2001



Download 17.96 Kb.
Date conversion28.01.2017
Size17.96 Kb.
CS 470 Name___________________________

Test 1 Spring 2001

True/False
1) If an assembler language uses one basic add instruction for register to register, memory to register, register to memory, and memory to memory, then the author would cite this as an example of orthogonality.

2) A variable declared in a function is an example of a stack-dynamic variable in c++.

3) The binding of a value to a variable is most frequently done statically.

4) The binding of a value to a variable must occur at execution time, that is, the only time a value can be assigned to a variable is after program execution begins.

5) Plankalkul supported a single bit type.

6) Some operations in a programming language may be software simulated as opposed to being implemented as a hardware instruction

7 Syntax analysis refers to grammar checking.

8. One of the chief architects of Fortran was also instrumental in the specification of the Algol-60 programming language.

9. Is special word are key words as opposed to being reserved, the readability is improved.

10. Because of the desire to produce the most efficient code, the designers of FORTRAN included language features that could easily be implemented on the underlying hardware of the IBM computers available in the 1950s.

11. Process abstraction is best illustrated by procedures and functions.

12. The desire for easy use, quick turnaround, and free and private access led to time-shared version of BASIC.

13. A pure interpreter frequently leaves a program in its source form or a form that allows for easy recovery of the source.

14. Two variables cannot share the same memory location.

15. The binding of a type to a variable in compiled language is done statically.

16. Some aspects of a programming language, such as the necessity of declaring variables is not easily conveyed by BNF.

17 In c++ the scope of a variable is totally determined by where it is declared.
18 Value cannot be assigned to variables statically in compiled languages.

19. In c++ n explicitly heap dynamic variable technically has no scope since it is not declared.

20 The three hallmarks of object-oriented languages are the notion of data abstraction, process abstraction, and inheritance.
Part 2. Answer the following matching questions from any of the answers below. Any answer may be used any number of times.
1. A translator whose target machine is different from the one on which the translator executes.

2. A basic program entity— a smallest syntactic unit.

3. A program that can be thought of as recognizing the valid statements in a language.

4. A programming language designed, in part, to implement operating systems.

5. Variables created when their declarations are reached during program execution.

6. A variable whose storage is allocated when assigned to

7. A language that is often implemented using a hybrid interpreter.

8. A programming language that tried to combine aspects of COBOL and FORTRAN in an attempt to be the “one programming language.”

9. The language of artificial intelligence

10. A programming language that is complete software interpreted.




a) None of these

b) Algol 60

c) Algol 68

d) c


e) Java

f) postscript

g) Cobol

h) variable

i) reserved word

j) keyword

k) non-local

l) global

m) stack-dynamic

n) implicitly-heap-dynamic

o) explicitly heap dynamic

p) static

q) type

r) data object



s) scope

t) BNF


u) lexeme/token

v) token


w) block

x) compiler

y) interpreter

z) assembler

aa) cross-compiler

Part III
1) Consider the following grammar:


S -> aC

C -> aC | bC | D

D -> aaD | bbD | e

a) Which of the following are valid strings in the language generated by this grammar.

aabbaabbe
abaaaabbe
aabbe
abaaae
aaaae

Using the expressing grammar:


::= id =

::= + | - |

::= * | / |

::= | | (
::= |

::= letter

Find the leftmost derivation of the following string and draw its parse tree (if it is correct)

x := 2 + 3 * (x - 2 * y) - 4*z

) Consider the following program in a c++ type language


int x = 1000;

typedef int * intpointer;

void allocate( intpointer & ptr)

{

int k;



ptr = new int;

*ptr = 100;

{ // block b

intpointer ptr

ptr = & x;

* ptr = 2000;

}

}
int main(void)



{

intpointer myptr;

allocate(myptr);

cout << * myptr << endl;

delete myptr;

cout << x << endl;

{ // Block A

intpointer yourptr;

yourptr = new int(500);

cout << *yourptr << endl;

myptr = yourptr;

}

cout << *myptr << endl;



return 0;

}
a) for each of the variables declared or or created in the code, indicate whether that variable

is static, stack-dynamic, explicitly heap dynamic or implicitly heap dynamic.

b) display the output of the above program



During the execution of allocate, as the program is written,
i )How do the storage for ptr and myptr compare?
ii) How does the lifetime of ptr compare with the lifetime of myptr?
iii) How do the value of ptr and myptr compare?
iv) The scope?


  1. The type?

  2. e) Given that the program above is executed, what would be the lifetime of the object created through operator new in allocate? Be specific as to when that object ceases to exist.

f) Given that the program above is executed, what would be the lifetime of the variable ptr in block b

What is the lifetime of the object that ptr points to in block b?

g) What is the lifetime of the two variables created in block A?






The database is protected by copyright ©ininet.org 2016
send message

    Main page