Programming Languages Test 2 Revision 1 CMSC 4023 CRN Spring 2007

Size: px
Start display at page:

Download "Programming Languages Test 2 Revision 1 CMSC 4023 CRN Spring 2007"

Transcription

1 1. Pr your name on your scantron in the space labeled NAME. 2. Pr CS 4023 in the space labeled SUBJECT. 3. Pr , the date in the space labeled DATE. 4. Pr your 24290, your CRN-number in the space labeled PERIOD. 5. You may not consult your neighbors, colleagues, or fellow students to answer the questions on this test. 6. Mark all selections that satisfy the question. If selection b, c, and d satisfy a question then mark selections b, c, and d. 7. Darken your selections completely. Make a heavy black mark that completely fills your selection. 8. Answer all 50 questions. 9. Record your answers on SCANTRON form 882-E (It is green!) 10. Submit your answers on Monday, April 2, 2007 at 7:30 a.m. in Room MCS 115 1

2 1. Select the correct binding time for the maximum number of significant digits in a real number. a. Language definition time b. Language implementation time c. Translation time d. Execution time 2. Select the correct binding time for the location of a local variable. a. Language definition time b. Language implementation time c. Translation time d. Execution time 3. Select the correct binding time for the meaning of a native type. a. Language definition time b. Language implementation time c. Translation time d. Execution time #include <iostream> using namespace std; a,b; void pr(void){cout << "a=" << a << " b=" << b;} p(& a){ p=2;a=0;b=1;return p;} void q(void){ b=4;a=3;pr();} main(){a=p(a);q();return 0;} Figure 4. C++ Program for Questions 4 and What is pred by the program in figure 4 assuming the symbol table employs static scope? a. a=1 b=3 b. a=2 b=4 c. a=3 b=1 d. a=3 b=4 5. What is pred by the program in figure 4 assuming the symbol table employs dynamic scope? a. a=1 b=3 b. a=2 b=4 c. a=3 b=1 d. a=3 b=4 2

3 program q06; var i,j,k:eger; procedure pr; begin{pr} write(' i=,i:2); write(' j=',j:2); write(' k=',k:2); writeln end{pr}; procedure p; var j:eger; procedure q; var k:eger; begin{q} k:=3; pr; end{q}; begin{p} j:=2; q end{p}; procedure r(var j:eger); begin{r} i:=-i; j=-j; end{r}; begin{q06} i:=-1;j:=-2;k:=-3; r(j); p; end{q06}. Figure 6. Pascal program for question What is pred by the program in figure 6 assuming the symbol table employs static scope? a. i=-1 j= 2 k=-3 b. i=-1 j=-2 k=-3 c. i= 1 j= 2 k=-3 d. i= 1 j= 2 k= 3 7. What is pred by the program in figure 6 assuming the symbol table employs dynamic scope? a. i=-1 j= 2 k=-3 b. i=-1 j=-2 k=-3 c. i= 1 j= 2 k= 3 d. i= 1 j= 2 k=-3 3

4 Variable Symbol Descriptor TypeKind ptype pid VariableS Color Offset 128 Enumerated Type Descriptor TypeKind pclist ptype EnumT Clist Type Descriptor TypeKind Size L Count CListT 2 3 Constant Type Descriptor TypeKind pid Value ptype ConstantT red 0 Constant Type Descriptor TypeKind pid Value ptype ConstantT green 1 Constant Type Descriptor TypeKind pid Value ptype ConstantT blue 2 Type Descriptor TypeKind TypeLength Alignment CardinalT Figure 8. Diagram for question Select the declaration(s) that match the representation shown in figure 8? a. type Color=(red,green,blue); {Pascal} b. var Color:(red,green,blue); {Pascal} c. enum Color {red,green,blue}; {C++} d. enum {red,green,blue} Color; {C++} 4

5 1. #include <iostream> 2. using namespace std; 3. a; 4. b; 5. p(& a) 6. { p=2; 7. a=0; 8. b=1; 9. return p; 10. } 11. void q(void) 12. { b=4; 13. a=3; 14. } 15. main() 16. { a=p(a); 17. q(); 18. return 0; 19. } Figure 9. C++ Program for question Assuming that compilation proceeds from line 1 to line 19 in figure 9, select the diagram(s) below that represent the symbol table at line 7. a & local to p() global a local to p() global b global b global p local to p() function global p local to p() function global diagram a Diagrams 9a and 9b. diagram b 5

6 a & a b b p function symtab p function symtab a a & p p diagram c diagram d Diagrams 9c and 9d. 6

7 1. #include <iostream> 2. using namespace std; 3. a; 4. b; 5. p(& a) 6. { p=2; 7. a=0; 8. b=1; 9. return p; 10. } 11. void q(void) 12. { static b=4; 13. a=3; 14. } 15. main() 16. { a=p(a); q(); 17. return 0; 18. } Figure 10. C++ Program for questions 10, 11, and What is the lifetime of variable b declared on line 12? a. Storage for variable b is allocated when function q is called and its storage is reclaimed when function q returns. b. Storage for variable b is allocated when function main is called and its storage is reclaimed when function main returns. c. Storage for variable b is allocated at load time and reclaimed when the program in figure 10 returns control to the operating system. d. Storage for variable b is allocated during translation and reclaimed when the file containing executable form of the program in figure 10 is deleted. 11. What is the lifetime of variable p declared on line 6? a. Storage for variable p is allocated when function p is called and its storage is reclaimed when function p returns. b. Storage for variable p is allocated when function main is called and its storage is recla imed when function main returns. c. Storage for variable p is allocated at load time and reclaimed when the program in figure 10 returns control to the operating system. d. Storage for variable p is allocated during translation and reclaimed when the file containing executable form of the program in figure 10 is deleted. 12. What is the lifetime of variable b declared on line 4? a. Storage for variable b is allocated when function q is called and its storage is reclaimed when function q returns. b. Storage for variable b is allocated when function main is called and its storage is reclaimed when function main returns. c. Storage for variable b is allocated at load time and reclaimed when the program in figure 10 returns control to the operating system. d. Storage for variable b is allocated during translation and reclaimed when the file containing executable form of the program in figure 10 is deleted. 7

8 #include <iostream> using namespace std; void swap(& m,& w){ b=m;m=w;w=b;} main() { a(1),b(2); swap(a,b); return 0; } Figure 13. C++ Program for question Select all valid characterizations of parameter m? a. Parameter m is an alias of variable a. b. Parameter m is a dangling reference. c. Parameter m is garbage. d. Parameter m contains the address of variable a while function swap is active. 1. #include <iostream> 2. using namespace std; 3. main() 4. { * a=new ; 5. * b=a; 6. delete b; 7. return 0; 8. } Figure 14. C++ Program for question Select all valid characterizations of variable a? a. On line 7 of figure 14, variable a contains the address of unnamed eger storage. b. On line 7 of figure 14, variable a is a dangling reference. c. On line 7 of figure 14, variable a references garbage. d. On line 7 of figure 14, variable a is an alias of variable b. 1. #include <iostream> 2. using namespace std; 3. main() 4. { * a; 5. a=new ; 6. a=new ; 7. return 0; 8. } Figure 15. C++ Program for question Select all valid statements? a. On line 6 of figure 15, a dangling reference is created. b. On line 6 of figure 15, an alias is created. c. On line 6 of figure 15, garbage is created. d. On line 6 of figure 15, a polymorphic reference to dual memory locations is created. 8

9 #include <iostream> using namespace std; double min( a, b){return (double)a<b?a:b;} double min( a,double b){return (double)a<b?a:b;} double min(double a, b){return (double)a<b?a:b;} double min(double a,double b){return (double)a<b?a:b;} main() { cout << min(1,2.); return 0; } Figure 16. Program for question Which C++ function min is called in function main? a. double min( a, b){return (double)a<b?a:b;} b. double min( a,double b){return (double)a<b?a:b;} c. double min(double a, b){return (double)a<b?a:b;} d. double min(double a,double b){return (double)a<b?a:b;} 17. Which C++ declaration(s) matches set T I R C = where I is the set of egers implemented on computer S, R is the set of floating-po numbers implemented on computer S, and C is the set of characters implemented on computer S? a. struct T { i;double d;char c;}; b. struct T {double d; i;char c;}; c. type T = record i:eger;r:real;c:char end; d. type T = record r:real;i:eger; c:char end; 18. Which set definitions match the Pascal type definition type T = 1..10; a. = { t I 1 t 10} b. T {( i, r) i I, r R} numbers c. = { t I 1 t < 10} d. = { t I 11 > t > 0} T where I is the set of egers = where I is the set of egers and R is the set of floating-po T where I is the set of egers T where I is the set of egers 19. In which of the following C++ code fragments is variable x assignment-compatible to variable y? a. double (*x)(); double (*y)(); b. * x=new [10]; * y=new [20]; c. enum {blue} x; enum {red } y; d. class T { i;double d;}; T x; T y; 20. Which C++ declaration(s) matches set L C L characters? a. union L {char c; L* p;}; b. class L {char c; L* p;}; c. struct L {char c; L* p;}; d. typedef L {char c; L* p;}; = {} where {} is the empty set and C is the set of 9

10 21. Which kind of type checking makes type X equivalent to type Y? type X = array[1..10] of eger; type Y = array[1..10] of eger; a. static b. dynamic c. structural d. polymorphic 22. Select the explicit type conversions that are implied in C++ for the statements: x(1); x=2+x/2.3; a. x(1); x=2+x/()2.3; b. x(1); x=(double(2)+double(x)/2.3); c. x(1); x=2+x/(2.3); d. x(1); x=()((double)2+(double)x/2.3); template <class T> class Stack { size; tos; T* S; public: struct StackException {StackException(char* m){cout << endl << Stack << m;}}; //... }; Figure 23. template class Stack implemented as a dynamically allocated array. 23. Consider the partially completed definition of template class Stack in figure 23. Which of the following are correct implementations of member function IsFull for a stack that is implemented using a dynamically allocated array? a. void IsFull(void){return size<tos;} b. bool IsFull(void){return size-1<=tos;} c. bool IsFull(void){return tos>=size-1;} d. bool IsFull(void){return tos>size;} 24. Consider the partially completed definition of template class Stack in figure 23. Which of the following are correct implementations of member function Push for a stack that is implemented using a dynamically allocated array? a. void Push(T v) { if (IsFull()) throw StackException( Full ); S[++tos]=v; } b. void Push(T v) { if (IsFull()) throw StackException( Full ); tos+=1; S[tos]=v; } 10

11 c. void Push(T v) { if (IsFull()) throw StackException( Full ); tos++; S[tos]=v; } d. void Push(T v) { if (IsFull()) throw StackException( Full ); tos=tos+1; *(S+tos)=v; } + + j * to i [] * [] * j a i * Figure 25. Attributed expression tree for question What C++ expressions are represented by the attributed expression tree in figure 25? a. a[i][j]+i+j b. a[i,j]+i+j c. a[i + j]+i+j d. *(a+4*(i+j))+i+j / * Figure 26. Expression tree for question What is the infix form of the expression given by the expression tree shown in figure 26? a. 7+6*5/4-3 b. / * c. (7+6)*5/(4-3) d * / 11

12 27. What is the prefix form of the expression given by the expression tree shown in figure 26? a *5 / b. / * c * / d * 5/ What is the postfix form of the expression given by the expression tree shown in figure 26? a * / b. 7+6*5/4-3 c. / * d. (7+6)*5/(4-3) 29. Evaluate the expression 3+6/2. Mark selection a if figure 29a contains the correct answer. Mark selection b if figure 29b contains the correct answer. Mark selection c if figure 29c contains the correct answer. Mark selection d if figure 29d contains the correct answer. expression expression + term expression + term / factor expression + term / 2 expression + factor / 2 expression + 6 / 2 term + 6 / 2 factor + 6 / / 2 Figure 29a. Answer for question Figure 29b. Answer for question / 6 2 Figure 29c. Answer for question 29. expression expression + term term term factor / factor factor Figure 29d. Answer for question

13 30. Select the grammars shown in figures 30a, 30b, 30c, and 30d that are ambiguous? Mark selection a if the grammar of figure 30a is ambiguous. In a similar way, mark selections b, c, and d, if the grammars of figures 30b, 30c, and 30d, respectively, are ambiguous. expression fi expression operation expression expression fi ( expression ) expression fi - expression expression fi id operation fi + operation fi - operation fi * operation fi / operation fi ^ Figure 30a. Grammar for question 30. expression fi operation expression expression expression fi id operation fi + operation fi - operation fi * operation fi / operation fi ^ Figure 30b. Grammar for question 30. expression fi expression expression operation expression fi id operation fi + operation fi - operation fi * operation fi / operation fi ^ Figure 30c. Grammar for question 30. expression fi term expression fi term addop expression term fi factor term fi factor mulop term factor fi power factor fi power powop factor power fi ( expression ) power fi - power power fi id addop fi + addop fi - mulop fi * mulop fi / powop fi ^ Figure 30d. Grammar for question

14 31. Select the grammar(s) that can produce the sentence given in figure 31. Mark selection a if the grammar of figure 30a can be used to produce the sentence. In a similar way, mark selections b, c, and d, if the grammars of figures 30b, 30c, and 30d, respectively, can be used to produce the sentence. id + id * id Figure 31. Sentence for question Mark the selections that satisfy the relation given in figure 32a for the grammar of figure 32b. Function p(op) returns the precedence of the argument. op Argument op is an operator in the grammar given in figure 32b. The operators given in the grammar of figure 32b include +, -, unary -, *, /, and ^. The operator, unary-, appears in production 8 p( op1) p( op2 ) L p( opn ) opi { +,,*, /,^, unary } a. p( + ) p( ) p(*) p(^ ) b. p( + ) p( unary ) p(*) p (^ ) p(*) p(/) p( d. p ( unary ) p( ) p( + ) c. ) Figure 32a. Relation for question expression fi term 2 expression fi term addop expression 3 term fi factor 4 term fi factor mulop term 5 factor fi power 6 factor fi power powop factor 7 power fi ( expression ) 8 power fi - power 9 power fi id 10 addop fi + 11 addop fi - 12 mulop fi * 13 mulop fi / 14 powop fi ^ Figure 32b. Grammar for question Mark the selections that correctly specify the association of the operators in the grammar of figure 32b. a. All the operators except unary- associate to the left and unary- associates to the right. b. All the operators associate to right. c. All the operators associate to the left. d. All the operators associate to the left except unary- and ^ which associate to the right. 14

15 34. Mark the selections that are equivalent to the C++ expression given in figure 34. if (x!=0&&x% y==0) Figure 34. C++ expression for question 34. Language Expression a. Pascal if x<>0 and x mod y = 0 then b. Ada if x/>0 and then x mod y = 0 then c. Java if (x!=0&x% y==0) d. ML if x<>0 andalso x mod y=0 then 35. Select the gra mmars shown in figures 35a, 35b, 35c, and 35d that are ambiguous? Mark selection a if the grammar of figure 35a is ambiguous. In a similar way, mark selections b, c, and d, if the grammars of figures 35b, 35c, and 35d, respectively, are ambiguous. 1 statement fi if expression then statement 2 statement fi matched-statement 3 matched-statement fi if expression then matched-statement else statement 4 matched-statement fi other Figure 35a. Grammar for question statement fi if expression then statement 2 matched-statement fi if expression then matched-statement else statement 3 statement fi other 4 matched-statement fi other Figure 35b. Grammar for question statement fi matched-statement 2 statement fi unmatched-statement 3 matched-statement fi if expression then matched-statement else matched-statement 4 matched-statement fi other 5 unmatched-statement fi if expression then statement 6 unmatched-statement fi if expression then matched-statement else statement Figure 35c. Grammar for question statement fi if expression then statement 2 -statement fi if expression then statement else statement 3 statement fi other Figure 35d. Grammar for question

16 36. Select the program fragment that is equivalent to the C++ fragment given in figure 36. for ( i=0;i<size;i++)sum+=a[i]; Figure 36. C++ Program fragment for question 36. Language Program fragment a. Pascal for i:=0 to size-1 do sum:=sum+a[i]; b. Ada for i in 0..size-1 loop sum:=sum+a(i); end loop; c. C++ i=0; while (i<size;) { sum+=a[i];i++} d. C { i=0; for(;;){if (i<size) break;sum+=a[i];i++;}} void swap( a, b) { temp; temp = a; a = b; b = temp; } main() { value = 2; list[5] = {1, 2, 3, 4, 5}; swap(value, list[value]); } Figure 37. C++ Program for questions 37 and What are the values of variable value and eger array list after function swap returns assuming such values were passed by name? Please find the relevant code in figure 37. a. value = 2, list = {1, 2, 3, 4, 5}. b. value = 2, list = {1, 2, 3, 4, 5}. c. value = 3, list = {1, 2, 3, 2, 5}. d. value = 3, list = {1, 2, 2, 4, 5}. 38. What are the values of variable value and eger array list after function swap returns assuming such values were passed by value-result? Please find the relevant code in figure 37. a. value = 2, list = {1, 2, 3, 4, 5}. b. value = 2, list = {1, 2, 3, 4, 5}. c. value = 3, list = {1, 2, 3, 2, 5}. d. value = 3, list = {1, 2, 2, 4, 5}. 16

17 program q39; var c:eger; procedure P(i:eger); procedure Q(j:eger); begin{q} if c>0 then begin writeln('c=',c); c:=c-j; Q(j-1) end end{q}; begin{p} c:=i; Q(5); end{p}; begin{q39} P(15) end{q39}. Figure 39. Pascal program for questions 39, 40, and How many activation record (stack frames) are on the activation record stack when program q39 shown in figure 39 prs c=6? a. 5 b. 4 c. 3 d How many static links must be traversed in program q39 from procedure Q to access the activation record in which variable c is allocated? a. 5 b. 4 c. 3 d How many activations of procedure Q are present when program q39 prs c=3? a. 5 b. 4 c. 3 d Historically, in the programming language FORTRAN, arguments were passed a. by reference b. by value c. by name d. by value-result 17

18 INTEGER COUNT, INC COUNT=1 INC=2 CALL EXP(COUNT+INC) END SUBROUTINE EXP(A) INTEGER A A=A+1 RETURN END Figure 43. FORTRAN program for question How is the argument, COUNT+INC, passed to parameter A in SUBROUTINE EXP? Please refer to figure 43. a. The value of the expression, COUNT+INC, is computed and assigned to parameter A. b. The address of the expression, COUNT+INC, is assigned to parameter A. c. Storage for a temporary eger is allocated in the activation record of SUBROUTINE EXP. The value of the expression is assigned to the temporary and the address of the temporary is assigned to parameter A. d. Storage for a temporary eger is allocated in the activation record of the main program. The value of the expression is assigned to the temporary and the address of the temporary is assigned to parameter A. 44. Which programming language environments require a static (lexical) link? a. Lisp b. C. c. Java. d. Pascal. 45. What programming language environments require garbage collection? a. Lisp b. C. c. Java. d. Pascal. 46. What programming languages contain constructs that support exceptions? a. Lisp b. C. c. Java. d. Pascal. 47. Garbage collection is required because a. the aggregate total of free store is insufficient to support program execution. b. operations that reclaim storage, such as delete, do not address garbage and dangling reference. c. programmatic methods are required to coalesce and compact blocks of memory on the free list. d. reference counting does not adequately reclaims storage having circular references. 48. What programming languages employ prefix notation? a. Lisp b. C. c. Java. d. Pascal. 18

19 49. What programming languages employ infix notation? a. Lisp b. C. c. Java. d. Pascal. 50. What programming languages restrict parameter passing mechanisms to pass-by-value? a. Ada b. C. c. Java. d. Pascal. 19

Programming Languages CRN Test 2 Version 1 CMSC 4023 Autumn 2013

Programming Languages CRN Test 2 Version 1 CMSC 4023 Autumn 2013 1. Print your name on your scantron in the space labeled NAME. 2. Print CMSC 4023 in the space labeled SUBJECT. 3. Print the test number and version, T2/V1, in the space labeled TEST NO. 4. Print the date,

More information

Programming Languages Test 3 Version 1 CMSC 4023 CRN Autumn 2012

Programming Languages Test 3 Version 1 CMSC 4023 CRN Autumn 2012 1. Print your name and your student account number on your scantron in the space labeled NAME. 2. Print CMSC 4023 in the space labeled SUBJECT. 3. Print the test number and version, T3/V1, in the space

More information

Programming I Test 2 Version 1 CS 1613 Summer 2011

Programming I Test 2 Version 1 CS 1613 Summer 2011 1. Record your answers on SCANTRON form 882-E (It is green!) 2. Print your name on your scantron in the space labeled NAME. 3. Print CMSC 1613 in the space labeled SUBJECT. 4. Print the date, 7-13-2011,

More information

Attributes, Bindings, and Semantic Functions Declarations, Blocks, Scope, and the Symbol Table Name Resolution and Overloading Allocation, Lifetimes,

Attributes, Bindings, and Semantic Functions Declarations, Blocks, Scope, and the Symbol Table Name Resolution and Overloading Allocation, Lifetimes, Chapter 5 Basic Semantics Attributes, Bindings, and Semantic Functions Declarations, Blocks, Scope, and the Symbol Table Name Resolution and Overloading Allocation, Lifetimes, and the Environment Variables

More information

Agenda. The main body and cout. Fundamental data types. Declarations and definitions. Control structures

Agenda. The main body and cout. Fundamental data types. Declarations and definitions. Control structures The main body and cout Agenda 1 Fundamental data types Declarations and definitions Control structures References, pass-by-value vs pass-by-references The main body and cout 2 C++ IS AN OO EXTENSION OF

More information

CMSC 4023 Chapter 11

CMSC 4023 Chapter 11 11. Topics The Concept of Abstraction Introduction to Data Abstraction Design Issues for Abstract Data Types Language Examples Parameterized Abstract Data Types Encapsulation Constructs Naming Encapsulations

More information

Programming Languages Third Edition. Chapter 7 Basic Semantics

Programming Languages Third Edition. Chapter 7 Basic Semantics Programming Languages Third Edition Chapter 7 Basic Semantics Objectives Understand attributes, binding, and semantic functions Understand declarations, blocks, and scope Learn how to construct a symbol

More information

Programming II Test 3 Revision 1 CS 2613 Autumn 2003

Programming II Test 3 Revision 1 CS 2613 Autumn 2003 1. Write your name on your scantron in the space labeled NAME. 2. Write your CRN number in the space labeled HOUR. 3. Write the date in the space labeled DATE. 4. Write the handwritten test number of this

More information

G Programming Languages - Fall 2012

G Programming Languages - Fall 2012 G22.2110-003 Programming Languages - Fall 2012 Lecture 2 Thomas Wies New York University Review Last week Programming Languages Overview Syntax and Semantics Grammars and Regular Expressions High-level

More information

Programming II Test 1 Revision 1 CMSC 2613 Autumn 2003

Programming II Test 1 Revision 1 CMSC 2613 Autumn 2003 CMSC 2613 Autumn 2003 1. Write your name on your scantron in the space labeled NAME. 2. Write your CRN number in the space labeled HOUR. 3. Write the date in the space labeled DATE. 4. Write the handwritten

More information

Names, Scopes, and Bindings II. Hwansoo Han

Names, Scopes, and Bindings II. Hwansoo Han Names, Scopes, and Bindings II Hwansoo Han Scope Rules A scope is textual region where bindings are active A program section of maximal size Bindings become active at the entry No bindings change in the

More information

Programming Languages Third Edition. Chapter 10 Control II Procedures and Environments

Programming Languages Third Edition. Chapter 10 Control II Procedures and Environments Programming Languages Third Edition Chapter 10 Control II Procedures and Environments Objectives Understand the nature of procedure definition and activation Understand procedure semantics Learn parameter-passing

More information

TYPES, VALUES AND DECLARATIONS

TYPES, VALUES AND DECLARATIONS COSC 2P90 TYPES, VALUES AND DECLARATIONS (c) S. Thompson, M. Winters 1 Names, References, Values & Types data items have a value and a type type determines set of operations variables Have an identifier

More information

CS 330 Lecture 18. Symbol table. C scope rules. Declarations. Chapter 5 Louden Outline

CS 330 Lecture 18. Symbol table. C scope rules. Declarations. Chapter 5 Louden Outline CS 0 Lecture 8 Chapter 5 Louden Outline The symbol table Static scoping vs dynamic scoping Symbol table Dictionary associates names to attributes In general: hash tables, tree and lists (assignment ) can

More information

Principles of Programming Languages Topic: Scope and Memory Professor Louis Steinberg Fall 2004

Principles of Programming Languages Topic: Scope and Memory Professor Louis Steinberg Fall 2004 Principles of Programming Languages Topic: Scope and Memory Professor Louis Steinberg Fall 2004 CS 314, LS,BR,LTM: Scope and Memory 1 Review Functions as first-class objects What can you do with an integer?

More information

Fundamentals of Programming Languages

Fundamentals of Programming Languages Fundamentals of Programming Languages 1. DEFINITIONS... 2 2. BUILT-IN TYPES AND PRIMITIVE TYPES... 3 TYPE COMPATIBILITY... 9 GENERIC TYPES... 14 MONOMORPHIC VERSUS POLYMORPHIC... 16 TYPE IMPLEMENTATION

More information

G Programming Languages - Fall 2012

G Programming Languages - Fall 2012 G22.2110-003 Programming Languages - Fall 2012 Lecture 3 Thomas Wies New York University Review Last week Names and Bindings Lifetimes and Allocation Garbage Collection Scope Outline Control Flow Sequencing

More information

CPSC 3740 Programming Languages University of Lethbridge. Data Types

CPSC 3740 Programming Languages University of Lethbridge. Data Types Data Types A data type defines a collection of data values and a set of predefined operations on those values Some languages allow user to define additional types Useful for error detection through type

More information

Short Notes of CS201

Short Notes of CS201 #includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

More information

Informatica 3 Syntax and Semantics

Informatica 3 Syntax and Semantics Informatica 3 Syntax and Semantics Marcello Restelli 9/15/07 Laurea in Ingegneria Informatica Politecnico di Milano Introduction Introduction to the concepts of syntax and semantics Binding Variables Routines

More information

CS201 - Introduction to Programming Glossary By

CS201 - Introduction to Programming Glossary By CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with

More information

6. Names, Scopes, and Bindings

6. Names, Scopes, and Bindings Copyright (C) R.A. van Engelen, FSU Department of Computer Science, 2000-2004 6. Names, Scopes, and Bindings Overview Names Binding time Object lifetime Object storage management Static allocation Stack

More information

CS 345. Functions. Vitaly Shmatikov. slide 1

CS 345. Functions. Vitaly Shmatikov. slide 1 CS 345 Functions Vitaly Shmatikov slide 1 Reading Assignment Mitchell, Chapter 7 C Reference Manual, Chapters 4 and 9 slide 2 Procedural Abstraction Can be overloaded (e.g., binary +) Procedure is a named

More information

SEMANTIC ANALYSIS TYPES AND DECLARATIONS

SEMANTIC ANALYSIS TYPES AND DECLARATIONS SEMANTIC ANALYSIS CS 403: Type Checking Stefan D. Bruda Winter 2015 Parsing only verifies that the program consists of tokens arranged in a syntactically valid combination now we move to check whether

More information

Programming Languages

Programming Languages Programming Languages Tevfik Koşar Lecture - VIII February 9 th, 2006 1 Roadmap Allocation techniques Static Allocation Stack-based Allocation Heap-based Allocation Scope Rules Static Scopes Dynamic Scopes

More information

Introduction to C++ Systems Programming

Introduction to C++ Systems Programming Introduction to C++ Systems Programming Introduction to C++ Syntax differences between C and C++ A Simple C++ Example C++ Input/Output C++ Libraries C++ Header Files Another Simple C++ Example Inline Functions

More information

MIDTERM EXAM (Solutions)

MIDTERM EXAM (Solutions) MIDTERM EXAM (Solutions) Total Score: 100, Max. Score: 83, Min. Score: 26, Avg. Score: 57.3 1. (10 pts.) List all major categories of programming languages, outline their definitive characteristics and

More information

Linear Data Structure

Linear Data Structure Linear Data Structure Definition A data structure is said to be linear if its elements form a sequence or a linear list. Examples: Array Linked List Stacks Queues Operations on linear Data Structures Traversal

More information

MIDTERM EXAMINATION - CS130 - Spring 2003

MIDTERM EXAMINATION - CS130 - Spring 2003 MIDTERM EXAMINATION - CS130 - Spring 2003 Your full name: Your UCSD ID number: This exam is closed book and closed notes Total number of points in this exam: 120 + 10 extra credit This exam counts for

More information

Concepts Introduced in Chapter 7

Concepts Introduced in Chapter 7 Concepts Introduced in Chapter 7 Storage Allocation Strategies Static Stack Heap Activation Records Access to Nonlocal Names Access links followed by Fig. 7.1 EECS 665 Compiler Construction 1 Activation

More information

Design Issues. Subroutines and Control Abstraction. Subroutines and Control Abstraction. CSC 4101: Programming Languages 1. Textbook, Chapter 8

Design Issues. Subroutines and Control Abstraction. Subroutines and Control Abstraction. CSC 4101: Programming Languages 1. Textbook, Chapter 8 Subroutines and Control Abstraction Textbook, Chapter 8 1 Subroutines and Control Abstraction Mechanisms for process abstraction Single entry (except FORTRAN, PL/I) Caller is suspended Control returns

More information

Names, Scope, and Bindings

Names, Scope, and Bindings Names, Scope, and Bindings COMS W4115 Prof. Stephen A. Edwards Fall 2007 Columbia University Department of Computer Science What s In a Name? Name: way to refer to something else variables, functions,

More information

Binding and Variables

Binding and Variables Binding and Variables 1. DEFINITIONS... 2 2. VARIABLES... 3 3. TYPE... 4 4. SCOPE... 4 5. REFERENCES... 7 6. ROUTINES... 9 7. ALIASING AND OVERLOADING... 10 8. GENERICS AND TEMPLATES... 12 A. Bellaachia

More information

Example. program sort; var a : array[0..10] of integer; procedure readarray; : function partition (y, z :integer) :integer; var i, j,x, v :integer; :

Example. program sort; var a : array[0..10] of integer; procedure readarray; : function partition (y, z :integer) :integer; var i, j,x, v :integer; : Runtime Environment Relationship between names and data objects (of target machine) Allocation & de-allocation is managed by run time support package Each execution of a procedure is an activation of the

More information

Introduction to C++ 2. A Simple C++ Program. A C++ program consists of: a set of data & function definitions, and the main function (or driver)

Introduction to C++ 2. A Simple C++ Program. A C++ program consists of: a set of data & function definitions, and the main function (or driver) Introduction to C++ 1. General C++ is an Object oriented extension of C which was derived from B (BCPL) Developed by Bjarne Stroustrup (AT&T Bell Labs) in early 1980 s 2. A Simple C++ Program A C++ program

More information

Expressions and Assignment

Expressions and Assignment Expressions and Assignment COS 301: Programming Languages Outline Other assignment mechanisms Introduction Expressions: fundamental means of specifying computations Imperative languages: usually RHS of

More information

HANDLING NONLOCAL REFERENCES

HANDLING NONLOCAL REFERENCES SYMBOL TABLE A symbol table is a data structure kept by a translator that allows it to keep track of each declared name and its binding. Assume for now that each name is unique within its local scope.

More information

COP4020 Programming Languages. Control Flow Prof. Robert van Engelen

COP4020 Programming Languages. Control Flow Prof. Robert van Engelen COP4020 Programming Languages Control Flow Prof. Robert van Engelen Overview Structured and unstructured flow Goto's Sequencing Selection Iteration and iterators Recursion Nondeterminacy Expressions evaluation

More information

SE352b: Roadmap. SE352b Software Engineering Design Tools. W3: Programming Paradigms

SE352b: Roadmap. SE352b Software Engineering Design Tools. W3: Programming Paradigms SE352b Software Engineering Design Tools W3: Programming Paradigms Feb. 3, 2005 SE352b, ECE,UWO, Hamada Ghenniwa SE352b: Roadmap CASE Tools: Introduction System Programming Tools Programming Paradigms

More information

St. MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad

St. MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad St. MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad-00 014 Subject: PPL Class : CSE III 1 P a g e DEPARTMENT COMPUTER SCIENCE AND ENGINEERING S No QUESTION Blooms Course taxonomy level Outcomes UNIT-I

More information

Appendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things.

Appendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things. A Appendix Grammar There is no worse danger for a teacher than to teach words instead of things. Marc Block Introduction keywords lexical conventions programs expressions statements declarations declarators

More information

Chapter 15 - C++ As A "Better C"

Chapter 15 - C++ As A Better C Chapter 15 - C++ As A "Better C" Outline 15.1 Introduction 15.2 C++ 15.3 A Simple Program: Adding Two Integers 15.4 C++ Standard Library 15.5 Header Files 15.6 Inline Functions 15.7 References and Reference

More information

Basic Types & User Defined Types

Basic Types & User Defined Types Basic Types & User Defined Types 1. Objectives... 2 2. Built-in Types and Primitive Types... 2 3. Data Aggregates and Type Constructors... 3 4. Constructors... 3 5. User-defined Types and Abstract Data

More information

Names, Scope, and Bindings

Names, Scope, and Bindings Names, Scope, and Bindings COMS W4115 Prof. Stephen A. Edwards Fall 2003 Columbia University Department of Computer Science What s In a Name? Name: way to refer to something else variables, functions,

More information

CS558 Programming Languages Winter 2018 Lecture 4a. Andrew Tolmach Portland State University

CS558 Programming Languages Winter 2018 Lecture 4a. Andrew Tolmach Portland State University CS558 Programming Languages Winter 2018 Lecture 4a Andrew Tolmach Portland State University 1994-2018 Pragmatics of Large Values Real machines are very efficient at handling word-size chunks of data (e.g.

More information

Names, Scope, and Bindings

Names, Scope, and Bindings Names, Scope, and Bindings COMS W4115 Prof. Stephen A. Edwards Spring 2007 Columbia University Department of Computer Science What s In a Name? Name: way to refer to something else variables, functions,

More information

LECTURE 17. Expressions and Assignment

LECTURE 17. Expressions and Assignment LECTURE 17 Expressions and Assignment EXPRESSION SYNTAX An expression consists of An atomic object, e.g. number or variable. An operator (or function) applied to a collection of operands (or arguments)

More information

Types and Type Inference

Types and Type Inference CS 242 2012 Types and Type Inference Notes modified from John Mitchell and Kathleen Fisher Reading: Concepts in Programming Languages, Revised Chapter 6 - handout on Web!! Outline General discussion of

More information

G Programming Languages Spring 2010 Lecture 6. Robert Grimm, New York University

G Programming Languages Spring 2010 Lecture 6. Robert Grimm, New York University G22.2110-001 Programming Languages Spring 2010 Lecture 6 Robert Grimm, New York University 1 Review Last week Function Languages Lambda Calculus SCHEME review 2 Outline Promises, promises, promises Types,

More information

CMSC 331 Final Exam Section 0201 December 18, 2000

CMSC 331 Final Exam Section 0201 December 18, 2000 CMSC 331 Final Exam Section 0201 December 18, 2000 Name: Student ID#: You will have two hours to complete this closed book exam. We reserve the right to assign partial credit, and to deduct points for

More information

IV. Stacks. A. Introduction 1. Consider the 4 problems on pp (1) Model the discard pile in a card game. (2) Model a railroad switching yard

IV. Stacks. A. Introduction 1. Consider the 4 problems on pp (1) Model the discard pile in a card game. (2) Model a railroad switching yard IV. Stacks 1 A. Introduction 1. Consider the problems on pp. 170-1 (1) Model the discard pile in a card game (2) Model a railroad switching yard (3) Parentheses checker () Calculate and display base-two

More information

Data Types. Outline. In Text: Chapter 6. What is a type? Primitives Strings Ordinals Arrays Records Sets Pointers 5-1. Chapter 6: Data Types 2

Data Types. Outline. In Text: Chapter 6. What is a type? Primitives Strings Ordinals Arrays Records Sets Pointers 5-1. Chapter 6: Data Types 2 Data Types In Text: Chapter 6 1 Outline What is a type? Primitives Strings Ordinals Arrays Records Sets Pointers Chapter 6: Data Types 2 5-1 Data Types Two components: Set of objects in the type (domain

More information

CS2141 Software Development using C/C++ C++ Basics

CS2141 Software Development using C/C++ C++ Basics CS2141 Software Development using C/C++ C++ Basics Integers Basic Types Can be short, long, or just plain int C++ does not define the size of them other than short

More information

Lecture 7: Type Systems and Symbol Tables. CS 540 George Mason University

Lecture 7: Type Systems and Symbol Tables. CS 540 George Mason University Lecture 7: Type Systems and Symbol Tables CS 540 George Mason University Static Analysis Compilers examine code to find semantic problems. Easy: undeclared variables, tag matching Difficult: preventing

More information

NOTE: Answer ANY FOUR of the following 6 sections:

NOTE: Answer ANY FOUR of the following 6 sections: A-PDF MERGER DEMO Philadelphia University Lecturer: Dr. Nadia Y. Yousif Coordinator: Dr. Nadia Y. Yousif Internal Examiner: Dr. Raad Fadhel Examination Paper... Programming Languages Paradigms (750321)

More information

Implementing Subprograms

Implementing Subprograms Implementing Subprograms 1 Topics The General Semantics of Calls and Returns Implementing Simple Subprograms Implementing Subprograms with Stack-Dynamic Local Variables Nested Subprograms Blocks Implementing

More information

G Programming Languages - Fall 2012

G Programming Languages - Fall 2012 G22.2110-003 Programming Languages - Fall 2012 Lecture 4 Thomas Wies New York University Review Last week Control Structures Selection Loops Adding Invariants Outline Subprograms Calling Sequences Parameter

More information

LECTURE 18. Control Flow

LECTURE 18. Control Flow LECTURE 18 Control Flow CONTROL FLOW Sequencing: the execution of statements and evaluation of expressions is usually in the order in which they appear in a program text. Selection (or alternation): a

More information

Lecture 12: Data Types (and Some Leftover ML)

Lecture 12: Data Types (and Some Leftover ML) Lecture 12: Data Types (and Some Leftover ML) COMP 524 Programming Language Concepts Stephen Olivier March 3, 2009 Based on slides by A. Block, notes by N. Fisher, F. Hernandez-Campos, and D. Stotts Goals

More information

Names and Abstractions: What s in a Name?

Names and Abstractions: What s in a Name? Copyright R.A. van Engelen, FSU Department of Computer Science, 2000 Names, Scopes, and Bindings Binding time Object lifetime Object storage management Static allocation Stack allocation Heap allocation

More information

COP4020 Fall 2006 Final Exam

COP4020 Fall 2006 Final Exam COP4020 Fall 2006 Final Exam Name: (Please print) Put the answers on these sheets. You can collect 100 points in total for this exam. 1. Consider the following Ada program fragment: search: loop i := i+1;

More information

September 10,

September 10, September 10, 2013 1 Bjarne Stroustrup, AT&T Bell Labs, early 80s cfront original C++ to C translator Difficult to debug Potentially inefficient Many native compilers exist today C++ is mostly upward compatible

More information

Types. What is a type?

Types. What is a type? Types What is a type? Type checking Type conversion Aggregates: strings, arrays, structures Enumeration types Subtypes Types, CS314 Fall 01 BGRyder 1 What is a type? A set of values and the valid operations

More information

o Counter and sentinel controlled loops o Formatting output o Type casting o Top-down, stepwise refinement

o Counter and sentinel controlled loops o Formatting output o Type casting o Top-down, stepwise refinement Last Time Let s all Repeat Together 10/3/05 CS150 Introduction to Computer Science 1 1 We covered o Counter and sentinel controlled loops o Formatting output Today we will o Type casting o Top-down, stepwise

More information

COP4020 Programming Languages. Names, Scopes, and Bindings Prof. Robert van Engelen

COP4020 Programming Languages. Names, Scopes, and Bindings Prof. Robert van Engelen COP4020 Programming Languages Names, Scopes, and Bindings Prof. Robert van Engelen Overview Abstractions and names Binding time Object lifetime Object storage management Static allocation Stack allocation

More information

Introduction to C++ Professor Hugh C. Lauer CS-2303, System Programming Concepts

Introduction to C++ Professor Hugh C. Lauer CS-2303, System Programming Concepts Introduction to C++ Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2 nd edition, by Kernighan and Ritchie, Absolute C++, by Walter

More information

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS Contents Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS 1.1. INTRODUCTION TO COMPUTERS... 1 1.2. HISTORY OF C & C++... 3 1.3. DESIGN, DEVELOPMENT AND EXECUTION OF A PROGRAM... 3 1.4 TESTING OF PROGRAMS...

More information

CST-402(T): Language Processors

CST-402(T): Language Processors CST-402(T): Language Processors Course Outcomes: On successful completion of the course, students will be able to: 1. Exhibit role of various phases of compilation, with understanding of types of grammars

More information

Data Types In Text: Ch C apter 6 1

Data Types In Text: Ch C apter 6 1 Data Types In Text: Chapter 6 1 Outline What is a type? Primitives Strings Ordinals Arrays Records Sets Pointers 2 Data Types Two components: Set of objects in the type (domain of values) Set of applicable

More information

Your first C++ program

Your first C++ program Your first C++ program #include using namespace std; int main () cout

More information

C++ For Science and Engineering Lecture 27

C++ For Science and Engineering Lecture 27 C++ For Science and Engineering Lecture 27 John Chrispell Tulane University Monday November 1, 2010 Classes and the This pointer Every C++ object has a curious pointer called this. If we want to extend

More information

CS 314 Principles of Programming Languages

CS 314 Principles of Programming Languages CS 314 Principles of Programming Languages Lecture 15: Review and Functional Programming Zheng (Eddy) Zhang Rutgers University March 19, 2018 Class Information Midterm exam forum open in Sakai. HW4 and

More information

Intermediate Representations & Symbol Tables

Intermediate Representations & Symbol Tables Intermediate Representations & Symbol Tables Copyright 2014, Pedro C. Diniz, all rights reserved. Students enrolled in the Compilers class at the University of Southern California have explicit permission

More information

Answer: Early binding generally leads to greater efficiency (compilation approach) Late binding general leads to greater flexibility

Answer: Early binding generally leads to greater efficiency (compilation approach) Late binding general leads to greater flexibility Quiz Review Q1. What is the advantage of binding things as early as possible? Is there any advantage to delaying binding? Answer: Early binding generally leads to greater efficiency (compilation approach)

More information

Informal Semantics of Data. semantic specification names (identifiers) attributes binding declarations scope rules visibility

Informal Semantics of Data. semantic specification names (identifiers) attributes binding declarations scope rules visibility Informal Semantics of Data semantic specification names (identifiers) attributes binding declarations scope rules visibility 1 Ways to Specify Semantics Standards Documents (Language Definition) Language

More information

DATA STRUCTURE UNIT I

DATA STRUCTURE UNIT I DATA STRUCTURE UNIT I 1. What is Data Structure? A data structure is a mathematical or logical way of organizing data in the memory that consider not only the items stored but also the relationship to

More information

CS1622. Semantic Analysis. The Compiler So Far. Lecture 15 Semantic Analysis. How to build symbol tables How to use them to find

CS1622. Semantic Analysis. The Compiler So Far. Lecture 15 Semantic Analysis. How to build symbol tables How to use them to find CS1622 Lecture 15 Semantic Analysis CS 1622 Lecture 15 1 Semantic Analysis How to build symbol tables How to use them to find multiply-declared and undeclared variables. How to perform type checking CS

More information

3. Context-free grammars & parsing

3. Context-free grammars & parsing 3. Context-free grammars & parsing The parsing process sequences of tokens parse tree or syntax tree a / [ / index / ]/= / 4 / + / 2 The parsing process sequences of tokens parse tree or syntax tree a

More information

6.096 Introduction to C++ January (IAP) 2009

6.096 Introduction to C++ January (IAP) 2009 MIT OpenCourseWare http://ocw.mit.edu 6.096 Introduction to C++ January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. Welcome to 6.096 Lecture

More information

CS558 Programming Languages

CS558 Programming Languages CS558 Programming Languages Fall 2016 Lecture 4a Andrew Tolmach Portland State University 1994-2016 Pragmatics of Large Values Real machines are very efficient at handling word-size chunks of data (e.g.

More information

Compiler Theory. (Semantic Analysis and Run-Time Environments)

Compiler Theory. (Semantic Analysis and Run-Time Environments) Compiler Theory (Semantic Analysis and Run-Time Environments) 005 Semantic Actions A compiler must do more than recognise whether a sentence belongs to the language of a grammar it must do something useful

More information

Input And Output of C++

Input And Output of C++ Input And Output of C++ Input And Output of C++ Seperating Lines of Output New lines in output Recall: "\n" "newline" A second method: object endl Examples: cout

More information

C++ Scope Resolution Operator ::

C++ Scope Resolution Operator :: C++ Scope Resolution Operator :: C++The :: (scope resolution) operator is used to qualify hidden names so that you can still use them. You can use the unary scope operator if a namespace scope or global

More information

Structuring the Data. Structuring the Data

Structuring the Data. Structuring the Data 2017-05-12 Structuring the Data Structuring the Data 2017-05-12 Structuring the Data 1 Why Use (Static, Strong) Types? hide machine representation improves programming style and maintainability consistent

More information

Types II. Hwansoo Han

Types II. Hwansoo Han Types II Hwansoo Han Arrays Most common and important composite data types Homogeneous elements, unlike records Fortran77 requires element type be scalar Elements can be any type (Fortran90, etc.) A mapping

More information

Using an LALR(1) Parser Generator

Using an LALR(1) Parser Generator Using an LALR(1) Parser Generator Yacc is an LALR(1) parser generator Developed by S.C. Johnson and others at AT&T Bell Labs Yacc is an acronym for Yet another compiler compiler Yacc generates an integrated

More information

The results for a few specific cases below are indicated. allequal ([1,1,1,1]) should return true allequal ([1,1,2,1]) should return false

The results for a few specific cases below are indicated. allequal ([1,1,1,1]) should return true allequal ([1,1,2,1]) should return false Test 1 Multiple Choice. Write your answer to the LEFT of each problem. 4 points each 1. Which celebrity has not received an ACM Turing Award? A. Alan Kay B. John McCarthy C. Dennis Ritchie D. Bjarne Stroustrup

More information

Infix to Postfix Conversion

Infix to Postfix Conversion Infix to Postfix Conversion Infix to Postfix Conversion Stacks are widely used in the design and implementation of compilers. For example, they are used to convert arithmetic expressions from infix notation

More information

CS 376b Computer Vision

CS 376b Computer Vision CS 376b Computer Vision 09 / 25 / 2014 Instructor: Michael Eckmann Today s Topics Questions? / Comments? Enhancing images / masks Cross correlation Convolution C++ Cross-correlation Cross-correlation involves

More information

l Determine if a number is odd or even l Determine if a number/character is in a range - 1 to 10 (inclusive) - between a and z (inclusive)

l Determine if a number is odd or even l Determine if a number/character is in a range - 1 to 10 (inclusive) - between a and z (inclusive) Final Exam Exercises Chapters 1-7 + 11 Write C++ code to: l Determine if a number is odd or even CS 2308 Fall 2016 Jill Seaman l Determine if a number/character is in a range - 1 to 10 (inclusive) - between

More information

Data types for mcrl2

Data types for mcrl2 Data types for mcrl2 Aad Mathijssen April 5, 2018 We provide a syntax for the standard data types of the mcrl2 language. This syntax is intended to be a practical mix between standard mathematical notation

More information

G Programming Languages - Fall 2012

G Programming Languages - Fall 2012 G22.2110-003 Programming Languages - Fall 2012 Lecture 10 Thomas Wies New York University Review Last class ML Outline Modules Sources: PLP, 3.3.4, 3.3.5, 3.8 McConnell, Steve. Code Complete, Second Edition,

More information

Borland 105, 278, 361, 1135 Bounded array Branch instruction 7 break statement 170 BTree 873 Building a project 117 Built in data types 126

Borland 105, 278, 361, 1135 Bounded array Branch instruction 7 break statement 170 BTree 873 Building a project 117 Built in data types 126 INDEX = (assignment operator) 130, 816 = 0 (as function definition) 827 == (equality test operator) 146! (logical NOT operator) 159!= (inequality test operator) 146 #define 140, 158 #include 100, 112,

More information

Introduction to Programming

Introduction to Programming Introduction to Programming session 6 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Spring 2011 These slides are created using Deitel s slides Sharif University of Technology Outlines

More information

Semantic Processing. Semantic Errors. Semantics - Part 1. Semantics - Part 1

Semantic Processing. Semantic Errors. Semantics - Part 1. Semantics - Part 1 Semantic Processing The Lexer and Parser Found lexical and syntax errors Built Abstract Syntax Tree Now!Find semantic errors.!build information about the program. Later!Generate IR Code!Optimize IR Code!Generate

More information

Compilers. 8. Run-time Support. Laszlo Böszörmenyi Compilers Run-time - 1

Compilers. 8. Run-time Support. Laszlo Böszörmenyi Compilers Run-time - 1 Compilers 8. Run-time Support Laszlo Böszörmenyi Compilers Run-time - 1 Run-Time Environment A compiler needs an abstract model of the runtime environment of the compiled code It must generate code for

More information

This examination has 11 pages. Check that you have a complete paper.

This examination has 11 pages. Check that you have a complete paper. MARKING KEY The University of British Columbia MARKING KEY Computer Science 252 2nd Midterm Exam 6:30 PM, Monday, November 8, 2004 Instructors: K. Booth & N. Hutchinson Time: 90 minutes Total marks: 90

More information

Outline. 1 Function calls and parameter passing. 2 Pointers, arrays, and references. 5 Declarations, scope, and lifetimes 6 I/O

Outline. 1 Function calls and parameter passing. 2 Pointers, arrays, and references. 5 Declarations, scope, and lifetimes 6 I/O Outline EDAF30 Programming in C++ 2. Introduction. More on function calls and types. Sven Gestegård Robertz Computer Science, LTH 2018 1 Function calls and parameter passing 2 Pointers, arrays, and references

More information

By the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program

By the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program 1 By the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program variables. Apply C++ syntax rules to declare variables, initialize

More information

Lecture No.04. Data Structures

Lecture No.04. Data Structures Lecture No.04 Data Structures Josephus Problem #include "CList.cpp" void main(int argc, char *argv[]) { CList list; int i, N=10, M=3; for(i=1; i

More information