# NOTE: Answer ANY FOUR of the following 6 sections:

Size: px
Start display at page:

Transcription

2 (B) Consider the ALGOL-like declaration: procedure SWAP ( x, y : integer ); var z: integer; begin z := x; x := y; y:= z; end; and suppose that x and y are parameters called by name. If a[1] = 2, a[2] = 5, and i = 1, what would be the effect of SWAP ( i, a[i] )? [4 marks] (C) Write the three numbers that the following C++ program will output when function test is called with argument y (1) by value (2) by reference [4 marks] #include <iostream.h> int y; void test ( int x ) { x = x + 2; cout << "x = "<<x <<" y = "<<y<<endl; } void main( ) { y = 5; test (y); cout <<" y = "<<y<<endl; } Question 4 (9 marks) Consider the following function: int fun ( int n ) { if (n < 1) return 1 ; else return 5 + f un ( n 1 ); } Answer ANY THREE of the following 4 sections: (A) Trace the function to find the value of the function call fun(5). (B) Rewrite the function to use iteration instead of recursion. Which version will evaluate the call fun(50) quickest? (C) What are the advantages and disadvantages of using recursion? [3 marks] [3 marks] [3 marks] (D) Rewrite the above function fun in the functional language SCHEME. [3 marks]... Concepts of Programming Languages (750321) Final Exam First Semester 2005/2006 February 4,

3 Question 5 (8 marks) (A) Show the stack with all activation record instances, using static chain mechanism, when executing the following Pascal program. Notice the calling sequence: MAIN calls P; P calls R; R calls S; S calls Q. [5 marks] program MAIN; var x : integer; procedure P; var a, b, c : integer; procedure Q; var a, d : integer; begin { Q } a := b + c; < end; { Q } (B) To what declaration of variable a will the reference to a be bound at each of the positions 1, 2, and 3 in the program of section (A). [3 marks] procedure R ( x : integer); var b, e : integer; begin P ; procedure S ; end. { MAIN var c, } e : integer; begin { S } Q; { calling Q } e := b + a: < end; {S} begin { R } S; { calling S} a := d + e; < end; { R } begin { P } R ( 7 ); { calling R } end; { P } begin { MAIN } P ; { calling P } end. { MAIN } III. Unfamiliar Problems Solving Objective: The aim of the question in this part is to evaluate that you can solve problems using functional languages concepts, and can set out reasoning and explanation in a clear and coherent manner about storage management. Question 6 (9 marks) (A) [3 marks] What does the following function (written in SCHEME language) do? (DEFINE ( f s lis ) ( COND ( ( NULL? Lis ) '( ) ) ( ( EQ? s ( CAR lis ) ) lis ) ( ELSE ( f s ( CDR lis ) ) ) ) ) (B) [3 marks] Explain why LISP-like (functional) languages require more run-time support than ALGOL-like (imperative) languages and why ALGOL-like languages require more run-time support than FORTRAN. Is this fact a function of the compiler/interpreter, or is it inherent in the language? Give some conclusions about the comparative run-time efficiency of these languages. How about space efficiency? Programming efficiency? (C) [3 marks] Write a function in SCHEME functional language that checkes whether a symbol is a member in a list. GOOD LUCK! Concepts of Programming Languages (750321) Final Exam First Semester 2005/2006 February 4,

5 Question 2 (5 marks) (a) How is a reference to a nonlocal variable in a static scoped program connected to its definition? [1 mark] (b) Consider the following program: program main; var x, y, z : integer ; procedure sub1; var a, y, z : integer; procedure sub2; var a, b, z : integer; begin { sub2 }... end; { sub2 } begin { sub1 }... end; { sub1 } procedure sub3; var a, x, w : integer; begin { sub3 }... end; { sub3 } begin { main }... end; { main } List all the variables, along with the program units where they are declared, that are visible in the bodies of sub1, sub2, and sub3, assuming static scoping is used. [4 marks]... II. Familiar Problems Solving Objectives: This part aims to evaluate that you have some basic knowledge of the key aspects of the lecture material and can attempt to solve familiar problems. The question tests your ability in designing simple string operation which could have some similarity to what you have practiced. Question 3 (5 marks) (a) What are the design issues for cchracter string type? [1 mark] (b) Consider the following storage structure for a limited dynamic length string (with descriptor) Maximum length current length 10 8 A B C D E F G H /// /// Eight-bit character code packed 4 per word with no extension Unused Design a concatentation operation CAT. CAT is called with three parameters X, Y, and Z. X and Y are poiters to the two storage blocks containing the string to be concatenated, and Z is the receiving block, which initially contains some other character string. [4 marks] GOOD LUCK! Concepts of Programming Languagess (750321) First Exam First Semester 2005/2006 November 21,

7 II. Familiar Problems Solving Objectives: This part aims to evaluate that you have some basic knowledge of the key aspects of the lecture material and can attempt to solve familiar problems. The question tests your ability in designing simple control constructs, which could have some similarity to what you have practiced. Question 3 (6 marks) Suppose that you are given the following Pascal-like If statement. if ( color = 1 ) then write ( ' Red Color ' ) else if ( color = 2 ) then write ( ' Blue Color ' ) else if ( color = 3 ) then write ( ' Green Color ' ) else if ( color = 4 ) then write ( ' Black Color ' ) ; (a) Write the equivalent switch statement for the above if statement. [3 marks] (b) Declare an enumerated type Colors that includes 4 colors and rewrite the above If statement [3 marks] Question 4 (3 marks) Rewrite the following C++ code so that the only control structures it uses are if-then (with no else) and goto. The body of an if-then statement should contain a single goto statement. i = 10; while (i > 0) { i = i - 1; for (j = 0; j < i; j++) { cout << i << j ; } } cout << i ; GOOD LUCK! Concepts of Programming Languagess (750321) Second Exam First Semester 2005/2006 December 26,

8 Philadelphia University Faulty of Information Technology Department of Computer Science Department of Applied Computer Science Marking Scheme and Outline Solutions of the Final Exam Module: Concepts of Programming Languages (750321) (Section 3) Programming Paradigms (710315) (Section 1) Exam Date: February 4, 2006 Lecturer: Dr. Nadia Y. Yousif First Semester 2005 / There are three parts in this exam paper. Part I contains two questions: Question (1) carries 8 marks and contains 6 sections and Question (2) carries 8 marks with 2 sections. Part II contains three questions: Questions (3) carries 8 marks, Question (4) carries 9 marks, and Question (5) carries 8 marks. Part III has only one question (Question (6)) which carries 9 marks. In some Questions, students can select any of the sections. The following is the marking scheme and the set of outline solutions for the questions. It includes breakdown of the marks to each part of the question and the steps of the solution. It also describes the type of answer required to gain the stated marks. 1- Question 1 (8 marks) NOTE: Answer ANY FOUR of the following 6 sections: (A) Why is useful for a programmer to have some background in language design, even though he/she may never actually design a programming language? [2 marks] (B) What does Orthogonality in programming languages mean? Give examples. [2 marks] (C) What is the difference between the static scoping and dynamic scoping? [2 marks] (D) What are the design issues for character string type? How Java language uses strings? [2 marks] (E) What is a coroutine? What language supports this concept? Give an example. [2 marks] (F) Explain the differences between the imperative programming languages, the object-oriented languages, and the functional programming languages. [2 marks].. The aim of this question is to evaluate student's required minimal knowledge and understanding skills in different programming languages concepts and paradigms. Students can select any four sections. The student s answer is preferred to look like the following: (A) It is useful because: 1- to increase capacity to express programming concepts 2- to improve background for choosing appropriate languages 3- to increase ability to learn new languages 4- to understand the significance of implementation 5- to increase ability to design new languages (B) Orthognality in a PL means that a small set of primitive construct can be combined in a relatively small number of ways to build the control and data structures of the language. Example: C language has integer type, arrays, and pointers from which many data structures can be built. (C) Static scoping is to connect a name reference to a variable. In imperative languages static scope is associated with program unit definition. To search for variable binding, first search locally, then in increasingly larger enclosing scopes until one is found for the given name. Dynamic scoping is based on calling sequences of program units, not their textual layout. References to variables re connected to declarations by searching back through the chain of subprogram calls that forced execution to this point. 2 marks 2 marks 1 mark 1 mark Marking Scheme Final Exam -1 st Semester 2005/2006 Concepts of Programming Languages (750321) (Section 3) 1

9 (D) The design issues of strings are: 1- Is it a primitive type or jut a special kind of array? 2- Is the length of objects static or dynamic? 2 marks 3- What operations can be implemented on them? Java has class String and class StringBuffer to handle objects of static and dynamic lengths respectively. (E) A coroutine is a subprogram that has multiple entries and controls them itself. The first resume of a coroutine is to it beginning, but subsequent calls enter at the point just after the last executed statement in 1 mark the coroutine. Coroutines provide quasi concurrent execution of program units. Their execution is irrelevant. Modula2, Ada, Java can support coroutines. Example: Procedure A calls procedure B: Procedure A 1 mark Begin. B; End; Procedure B Begin. A; End; (F) Imperative languages depend on Von Neumann architecture that has to store variables. They use 1 mark iterative process for repetition. E.g. Pascal, C, Algol, Fortran Functional languages does not depend on Von Neumann architecture, therefore, they have no notion of 1 mark store variables. They use recursion for repeating a process. They rely heavily on mathematical functions. They are used for AI applications. Object-oriented languages depend on objects. A program in these languages is a collection of objects that 1 mark can implement encapsulation and hide information to give better software design. E.g. Java, C Question 2 (8 marks) (B) Consider the following declaration in (A) The declaration of an integer one-dimensional array with its initialization is given in C++ and Ada as follows: [4 marks] In C++: int score[ ] = {65, 70, 55, 87}; In Ada: SCORE: array (1.. 6) of INTEGER := (1 => 54, 2 => 76, 3 => 80, others => 35); Explain the effects of these two declarations. Pascal: [4 marks] type arr = array [0.. 3] of integer; rec = record a : real; b : arr; c : integer; end; var R : rec; Determine (by a diagram) the storage structure representation of variable R... This question is to test students understanding of some programming concepts concerning different data types and data structures with their storage representation. It is intended to students of intermediate level that need to know the basic concepts of programming. The outline solution and marking scheme are given as follows: (A) The declaration in C++ will allow the compiler to allocate a space of 4 locations (4 bytes each - for integer) to array named score, indexed from 0 to 3 and the initial values are stored in the array as follows: 65 goes to location 0, 70 to location 1, 55 to location 2, and 87 to location 3. The declaration in Ada will allow the compiler to allocate a space of 6 locations (4 bytes each - for integer) to array named SCORE, indexed from 1 to 6 and the initial values are stored in the array as follows: 54 goes to location 1, 76 to location 2, 80 to location 3, and 35 to locations 4, 5, and 6. 2 marks 2 marks Marking Scheme Final Exam -1 st Semester 2005/2006 Concepts of Programming Languages (750321) (Section 3) 2

10 (B) Record a real Offset: 1 b arr Offset: 2 c Integer Offset: 6 Address Array integer subrange 0 3 address 4 marks.. 3- Question 3 (8 marks) NOTE: Answer ANY TWO of the following 3 sections: (A) Consider the following Pascal case statement. Rewrite it using only two-way selection. [4 marks] case index - 1 of 2, 4: even := even + 1; 1, 3: odd := odd + 1; 0: zero := zero + 1; else error := true end (B) Consider the ALGOL-like declaration: [4 marks] procedure SWAP ( x, y : integer ); var z: integer; begin z := x; x := y; y:= z; end; and suppose that x and y are parameters called by name. If a[1] = 2, a[2] = 5, and i = 1, what would be the effect of SWAP ( i, a[i] )? (C) Write the three numbers that the following C++ program will output when function test is called with argument y (1) by value (2) by reference [4 marks] #include <iostream.h> int y; void test ( int x ) { x = x + 2; cout << "x = "<<x <<" y = "<<y<<endl; } void main( ) { y = 5; test (y); cout <<" y = "<<y<<endl; }... Marking Scheme Final Exam -1 st Semester 2005/2006 Concepts of Programming Languages (750321) (Section 3) 3

11 This question is to evaluate that students have some basic knowledge of the key aspects of the lecture material and can attempt to solve familiar problems using different control constructs and some parameter passing mechanisms. It is intended to students of intermediate level that need to know different concepts. Students can select any two sections. The following is one possible solution and the breakdown of marks: (A) if (( index 1) = 2 or ( index 1 ) = 4 ) then even := even + 1; else if (( index 1) = 1 or ( index 1 ) = 3 ) then odd := odd + 1; else if (( index 1) = 0 ) then zero := zero + 1; else error := true; (B) On calling SWAP ( i, a[i] ) by name, the names of the parameters are passed. Therefore, the address and contents of parameters are recognized in the body of the procedure SWAP. The result will be: x will be bound to i and y to a[i] z := i z := 1 x := y i := a[i] i := a[1] i := 2 y := z a[i] := z a[i] := 1 a[2] := 1 This means that the values of i and a[2] are swapped; not the values of i and a[1]. (C) 1- Call by value The update on the parameter x does not affect the argument y. Then the output is x = 7 y = 5 y = 5 2- Call by reference The update on the parameter x affects the argument y. Then the output is x = 7 y = 7 y = 7 1 mark 1 mark 1 mark 1 mark 1 mark 1 mark 1 mark 1 mark 2 marks 2 marks 4- Question 4 (9 marks) Consider the following function: int fun ( int n ) { if (n < 1) return 1 ; else return 5 + fun ( n 1 ); } Answer ANY THREE of the following 4 sections: (A) Trace the function to find the value of the function call fun(5). [3 marks] (B) Rewrite the function to use iteration instead of recursion. Which version will evaluate the call fun(50) quickest? [3 marks] (C) What are the advantages and disadvantages of using recursion? [3 marks] (D) Rewrite the above function fun in the functional language SCHEME. [3 marks].. This question is to evaluate that students have some basic knowledge of the key aspects of the lecture material and can attempt to solve familiar problems using functions and functional languages. It is intended to students of intermediate level. Students can select any three sections. The following is the solution and the breakdown of marks: (A) The returned value will be 21 that is obtained as follows: fun (5) means n is bound to 5, then n is tested and a recursive call occurs to give 5 + fun (4) this gives (5 + (5 + fun (3))) (10 + (5 + fun (2)) (15 + (5 + fun(1))) (20 + (5 + fun(0)) (25 + fun(0)). Recursion stops now and fun will return 1, and the total result will be 26 3 marks Marking Scheme Final Exam -1 st Semester 2005/2006 Concepts of Programming Languages (750321) (Section 3) 4

12 (B) The iterative version of fun function is as follows: int fun ( int n ) { int sum = 1; if ( n < 1 ) return 1; else for ( int I = n; I > 1; I--) sum = sum + 5; return sum; } The iterative version will evaluate fun (50) faster than the recursive version, because of the required large number of activation record instances that are needed to be created during execution. (C) The advantages of using recursion is that the function code could be shorter than iterative version. The disadvantages: It could take more stack space because of the multiple instances of activation records created during execution. Whereas the iterative function needs only one activation record for the first call. (D) The function fun written in the functional language SCHEME: ( DEFINE ( fun n ) ( IF ( > n 1 ) 1 ( + 5 ( fun ( - n 1 ) ) ) ) ) 1 mark 1 mark 1 mark 1.5 marks 1.5 marks 3 marks.. 5- Question 5 (8 marks) (A) Show the stack with all activation record instances, using static chain mechanism, when executing the following Pascal program. Notice the calling sequence: MAIN calls P; P calls R; R calls S; S calls Q. [5 marks] program MAIN; var x : integer; procedure P; var a, b, c : integer; procedure Q; var a, d : integer; begin { Q } a := b + c; < end; { Q } (B) To what declaration of variable a will the reference to a be bound at each of the positions 1, 2, and 3 in the program of section (A). [3 marks] procedure R ( x : integer); var b, e : integer; begin P ; procedure S ; end. { MAIN var c, } e : integer; begin { S } Q; { calling Q } e := b + a: < end; {S} begin { R } S; { calling S} a := d + e; < end; { R } begin { P } R ( 7 ); { calling R } end; { P } begin { MAIN } P ; { calling P } end. { MAIN } Marking Scheme Final Exam -1 st Semester 2005/2006 Concepts of Programming Languages (750321) (Section 3) 5

13 This question is to evaluate that students can attempt to solve problems with procedures. It is intended to students of intermediate level. The following is the solution and the breakdown of marks: (A) (5 marks) The stack with instances of activation records is shown in Figure (1). (B) At position 1, a is a reference to the local declaration in procedure Q. At position 2, a is a reference to a declared in procedure P, because it is not declared in R or S procedures. At position 3, a is a reference to a declared in procedure P. 1 mark 1 mark 1 mark.. 6- Question 6 (9 marks) (A) [3 marks] What does the following function (written in SCHEME language) do? (DEFINE ( f s lis ) ( COND ( ( NULL? Lis ) '( ) ) ( ( EQ? s ( CAR lis ) ) lis ) ( ELSE ( f s ( CDR lis ) ) ) ) ) (B) [3 marks] Explain why LISP-like (functional) languages require more run-time support than ALGOL-like (imperative) languages and why ALGOL-like languages require more run-time support than FORTRAN. Is this fact a function of the compiler/interpreter, or is it inherent in the language? Give some conclusions about the comparative run-time efficiency of these languages. How about space efficiency? Programming efficiency? (C) [3 marks] Write a function in SCHEME functional language that checkes whether a symbol is a member in a list.. The aim of this question is to evaluate that students can solve problems using functional languages concepts, and can set out reasoning and explanation in a clear and coherent manner. Therefore, it is intended to students of more than intermediate level that can write programs with functional paradigm and give reasoning about storage management. The following is the solution and the breakdown of marks: (A) The function f first checks if a given list is empty, then ( ) will be returned. Otherwise, the recursive calls will check if an atom exists in the list, then it will return a list with atoms starting from the matched one. For example, if f is applied as follows: f ( 'B '( A B C)) Then f will return with the list ( B C ) (B) * LISP-like languages are functional type; they have dynamic type checking and they need dynamic allocation for their programs and data structures, thus a heap storage management is required (i.e. dynamic storage management) because of the linked lists required during run-time together with the stack because of the recursive use of functions. A garbage collector should be working during execution to manage the work space. Thus they require more run-time. * ALGOL-like languages are imperative languages; they have static type checking; that is done during compilation-time. Thus the execution time is reduced. The program & data will be stored in memory in a static area. A stack is required for activation record instances for procedure calls and a heap is required for dynamically allocated data (pointer type). A pointer variable could be deallocated explicitly in the program and this can put some efforts on the programmer but the program will be considered efficient. The static and dynamic storage managements are required. The space required for activation record instances put some space overhead and the dynamic 3 marks 1 mark 1 mark Marking Scheme Final Exam -1 st Semester 2005/2006 Concepts of Programming Languages (750321) (Section 3) 6

14 management add extra overhead on run-time. 1 mark * FORTRAN does not support recursion; therefore it has only static storage management as it has only one instance of activation record, a space for it can be allocated in memory during compilation. Thus no extra space is required for that. This storage management is the simplest one and no runtime overhead is required. But from the programming point of view, a FORTRAN program can be considered efficient, although recursion could be needed in some cases. (C) The member function can be written as: ( DEFINE ( member atm lis ) ( COND ( ( NULL? lis '( ) ) ( ( EQ? atm ( CAR lis ) ) #T ) ( ELSE ( member atm ( CDR lis ) ) ) ) ) 1 mark 1 mark 1 mark Marking Scheme Final Exam -1 st Semester 2005/2006 Concepts of Programming Languages (750321) (Section 3) 7

15 Figure (1) Stack Contents for MAIN Program of Q5 Local d AR for Q Local a (called from S) Dynamic link Static link Return (to R) Local e Local c AR for S Dynamic link (called from R) Static link Return (to R) Local e Local b AR for R Parameter 7 x (called from P) Dynamic link Static link Return (to P) Local c Local b AR for P Local a (called from Dynamic link MAIN_2) Static link Return (to MAIN_2) AR for MAIN_2 Local x

16 Philadelphia University Lecturer : Daed Al-Halabi Coordinator : Daed Al-Halabi Internal Examiner: Dr. Ahamed Al-Khateeb Faculty of Information Technology Department of CS Examination Paper Concept of Programming Language (750321) 1 st exam 2 nd Section (1) Semester 2005/2006 Time: 50 minutes Information for Candidates 1. This examination paper contains 3 questions, totaling 20 marks. 2. The marks for parts of questions are shown in round brackets. Advice to Candidates 1. You should attempt all questions. 2. You should write your answers clearly. I. Basic Notions Objectives. The aim of the questions in this part is to evaluate the required minimal student knowledge and skills. Answers in the pass category represent the minimum acceptable standard. Q1. (10 Marks) Quick Answers: 1. (0.5 Mark) (T/ F) It is important to make programs understandable to other humans 2. (0.5 Mark) (T/ F) Variable is a data object with a name which is bound to a value permanently during its life time. 3. (0.5 Mark) (T/ F) Compiler languages have fast execution than interpreter languages. 4. (1 Mark) By using Type inference, F (a): integer { a * 2.5;} F will be of type integer. 5. (1 Mark) Declare a variable x of type integer and its value 5 using explicit declaration (1.5 Mark) Name three different possible binding times (5 Marks) Match each term with the appropriate definition. Seq Stmt Seq Stmt 1 Type A Are not defined in terms of other types. 2 Subrange B is a word of programming language that is special only in certain contexts. 3 Local variable C Symbolic constant 4 Descriptor D Determine the range of values the variable can have. 5 Primitive data types E Those that are bound to memory cells before program execution begins and remain bound to those same memory cells until program execution terminates. 6 Enumeration type 7 Float-point 8 Keyword 9 Static variable 10 Scope of program variable Answers: (5, A ), (8, B ), ( 6, C ), ( 1, D ), ( 9, E ) 1

17 II. Familiar Problems Solving Objectives. The aim of the questions in this part is to evaluate that the student has some basic knowledge of the key aspects of the lecture material and can attempt to solve familiar problems. Q2. (6 Marks) Name, Bindings, Type Checking and scope: A.(2 Marks) Assume a language L, use Name type compatibility, for the following C-syntax code: int x = 7; float y = 2.7; Can we write x = y; why/ why not False, since x of type integer and y of type float where integer <> float B. (4 Marks) Here is a program written in a Pseudo code. Explain what the result would be printed under static scoping, and what the result would be under dynamic scoping. Determine the variable x belongs to what subprogram in the last call. var x; void two ( ) { var x; x= 3; three(); } void three ( ) { if (x < 5) cout<< (x + 1); else cout<< (x - 1); } void main ( ) {x = 7; two();} Static Scoping: Output: 6 X belongs to global Dynamic Scoping: 2 X belongs to two Q3. (4 Marks) Data Type: A. (2 Marks) Define Ordinal, subrange data type. Ordinal: SubRange: B. (2 Marks) Assume the language L use static length string, for the following C-Syntax: String S[10]; - What is the minimum number of characters that S can hold? - What is the maximum number of characters that S can hold? 2

18 Philadelphia University Lecturer : Daed Al-Halabi Coordinator : Daed Al-Halabi Internal Examiner: Dr. Ahamed Al-Khateeb Faculty of Information Technology Department of CS Examination Paper Concept of Programming Language (750321) 1 st exam Section (1) 2 nd Semester 2005/2006 Time: 50 minutes Information for Candidates 1. This examination paper contains 3 questions, totaling 20 marks. 2. The marks for parts of questions are shown in round brackets. Advice to Candidates Student Name: Student Number: 1. You should attempt all questions. 2. You should write your answers clearly. I. Basic Notions Objectives. The aim of the questions in this part is to evaluate the required minimal student knowledge and skills. Answers in the pass category represent the minimum acceptable standard. Q1. (10 Marks) Quick Answers: 1. (0.5 Mark) (T/ F) It is important to make programs understandable to other humans 2. (0.5 Mark) (T/ F) Variable is a data object with a name which is bound to a value permanently during its life time. 3. (0.5 Mark) (T/ F) Compiler languages have fast execution than interpreter languages. 4. (1 Mark) By using Type inference, F(a): integer { a * 2.5;} F will be of type. 5. (1 Mark) Declare a variable x of type integer and its value 5 using explicit declaration (1.5 Mark) Name three different possible binding times (5 Marks) Match each term with the appropriate definition. Seq Stmt Seq Stmt 1 Type A Are not defined in terms of other types. 2 Subrange B is a word of programming language that is special only in certain contexts. 3 Local variable C Symbolic constant 4 Descriptor D Determine the range of values the variable can have. 5 Primitive data types E Those that are bound to memory cells before program execution begins and remain bound to those same memory cells until program execution terminates. 6 Enumeration type 7 Float-point 8 Keyword 9 Static variable 10 Scope of program variable Answers: (, A ), (, B ), (, C ), (, D ), (, E ) 1

19 II. Familiar Problems Solving Objectives. The aim of the questions in this part is to evaluate that the student has some basic knowledge of the key aspects of the lecture material and can attempt to solve familiar problems. Q2. (6 Marks) Name, Bindings, Type Checking and scope: A.(2 Marks) Assume a language L, use Name type compatibility, for the following C-syntax code: int x = 7; float y = 2.7; Can we write x = y; why/ why not B. (4 Marks) Here is a program written in a Pseudo code. Explain what the result would be printed under static scoping, and what the result would be under dynamic scoping. Determine the variable x belongs to what subprogram for the last call. var x; void two ( ) { var x; x= 3; three(); } void three ( ) { if (x < 5) cout<< (x + 1); else cout<< (x - 1); } void main ( ) {x = 7; two();} Static Scoping: Output: X belongs to: Dynamic Scoping: Output: X belongs to: Q3. (4 Marks) Data Type: A. (2 Marks) Define Ordinal, subrange data type. Ordinal: SubRange: B. (2 Marks) Assume the language L use static length string, for the following C-Syntax: String S[10]; - What is the minimum number of characters that S can hold? - What is the maximum number of characters that S can hold? 2

20 Philadelphia University Lecturer : Daed Al-Halabi Coordinator : Daed Al-Halabi Internal Examiner: Dr. Ahamed Al-Khateeb Faculty of Information Technology Department of CS Examination Paper Concept of Programming Language (750321) 1 st exam Section (1) 2 nd Semester 2005/2006 Time: 50 minutes Information for Candidates 1. This examination paper contains 3 questions, totaling 20 marks. 2. The marks for parts of questions are shown in round brackets. Advice to Candidates Student Name: Student Number: 1. You should attempt all questions. 2. You should write your answers clearly. I. Basic Notions Objectives. The aim of the questions in this part is to evaluate the required minimal student knowledge and skills. Answers in the pass category represent the minimum acceptable standard. Q1. (10 Marks) Quick Answers: 1. (0.5 Mark) (T/ F) It is not important to make programs understandable to other humans 2. (0.5 Mark) (T/ F) Variable is a data object with a name which is bound to a value temporarily during its life time. 3. (0.5 Mark) (T/ F) Compiler languages have slow execution than interpreter languages. 4. (1 Mark) By using Type inference, F(a) { a * 2.5;} F will be of type. 5. (1 Mark) Declare a variable x of type float and its value 9 using implicit declaration (1.5 Mark) What is an alias? (5 Marks) Match each term with the appropriate definition. Seq Stmt Seq Stmt 1 Enumeration type A Are not defined in terms of other types. 2 Float-point B is a word of programming language that is special only in certain contexts. 3 Keyword C Symbolic constant 4 Static variable D Determine the range of values the variable can have. 5 Scope of program variable 6 Type 7 Subrange 8 Local variable 9 Descriptor 10 Primitive data types Answers: (, A ), (, B ), (, C ), (, D ), (, E ) E Those that are bound to memory cells before program execution begins and remain bound to those same memory cells until program execution terminates. II. Familiar Problems Solving Page 1

21 Objectives. The aim of the questions in this part is to evaluate that the student has some basic knowledge of the key aspects of the lecture material and can attempt to solve familiar problems. Q2. (6 Marks) Name, Bindings, Type Checking and scope: A.(2 Marks) Assume a language L, use structure type compatibility, for the following C-syntax code: int x = 7; float y = 2.7; Can we write x = y; why/ why not B. (4 Marks) Here is a program written in a Pseudo code. Explain what the result would be printed under static scoping, and what the result would be under dynamic scoping. Determine the variable x belongs to what subprogram for the last call. var x; void two ( ) { var x; x= 10; three(); } void three ( ) { if (x < 8) cout<< (x + 1); else cout<< (x - 1); } void main ( ) {x = 2; two();} Static Scoping: Output: X belongs to: Dynamic Scoping: Output: X belongs to: Q3. (4 Marks) Data Type: A. (2 Marks) Define subrange, Ordinal data type. SubRange: Ordinal: B. (2 Marks) Assume the language L use static length string, for the following C-Syntax: String S[5]; - What is the maximum number of characters that S can hold? - What is the minimum number of characters that S can hold? Page 2

22 Philadelphia University Lecturer : Daed Al-Halabi Coordinator : Daed Al-Halabi Internal Examiner: Dr. Ahamed Al-Khateeb Faculty of Information Technology Department of CS Examination Paper Concept of Programming Language (750321) 1 st exam Section (2) 2 nd Semester 2005/2006 Time: 50 minutes Information for Candidates 1. This examination paper contains 3 questions, totaling 20 marks. 2. The marks for parts of questions are shown in round brackets. Advice to Candidates Student Name: Student Number: 1. You should attempt all questions. 2. You should write your answers clearly. I. Basic Notions Objectives. The aim of the questions in this part is to evaluate the required minimal student knowledge and skills. Answers in the pass category represent the minimum acceptable standard. Q1. (10 Marks) Quick Answers: 1. (0.5 Mark) (T/ F) It is important to make programs understandable to other humans 2. (0.5 Mark) (T/ F) constant is a data object with a name which is bound to a value temporarily during its life time. 3.(0.5 Mark) (T/ F) Interpreter languages have fast execution than complier languages. 3. (1 Mark) By using Type inference, F (a: integer) { a * 2.5;} F will be of type. 4. (1 Mark) Declare a variable x of type float and its value 9 using explicit declaration (1.5 Marks) What is the l-value of a variable? What is the r-value? (5 Marks) Match each term with the appropriate definition. Seq Stmt Seq Stmt 1 Constant A Designed to support business system 2 Location B Answers: (, A ), (, B ), (, C ), (, D ), (, E ) Is a word of programming language that can not be used as user defined name. 3 Subrange Type C The collection of the attributes of a variable. 4 Keyword D Is bound to a value only at the time it is bound to storage 5 Binding E Contiguous subsequence 6 Static variables 7 Reserved word 8 Descriptor 9 Primitive data types 10 Enumeration type 11 Decimal 12 Scope of program variable 13 Value Page 1

23 II. Familiar Problems Solving Objectives. The aim of the questions in this part is to evaluate that the student has some basic knowledge of the key aspects of the lecture material and can attempt to solve familiar problems. Q2. (6 Marks) Name, Bindings, Type Checking and scope: A.(2 Marks) Assume a language L, use structure type compatibility, for the following C-syntax code: int x = 7; float y = 2.7; Can we write x = y; why/ why not B. (4 Marks) Here is a program written in a Pseudo code. Explain what the result would be printed under static scoping, and what the result would be under dynamic scoping. Determine the variable x belongs to what subprogram for the last call. var x; void two ( ) { var x; x= 10; three(); } void three ( ) { if (x > 8) cout<< (x + 1); else cout<< (x - 1); } void main ( ) {x = 2; two();} Static Scoping: Output: X belongs to: Dynamic Scoping: Output: X belongs to: Q3. (4 Marks) Data Type: A. (2 Marks) Define Enumeration, Ordinal data type. Enumeration: Ordinal: B. (2 Marks) Assume the language L use dynamic length string, for the following C-Syntax: String S[5]; - What is the maximum number of characters that S can hold? - What is the minimum number of characters that S can hold? Page 2

24 Philadelphia University Lecturer : Daed Al-Halabi Coordinator : Daed Al-Halabi Internal Examiner: Dr. Ahamed Al-Khateeb Faculty of Information Technology Department of CS Examination Paper Concept of Programming Language (750321) 1 st exam Section (2) 2 nd Semester 2005/2006 Time: 50 minutes Information for Candidates 1. This examination paper contains 3 questions, totaling 20 marks. 2. The marks for parts of questions are shown in round brackets. Advice to Candidates Student Name: Student Number: 1. You should attempt all questions. 2. You should write your answers clearly. I. Basic Notions Objectives. The aim of the questions in this part is to evaluate the required minimal student knowledge and skills. Answers in the pass category represent the minimum acceptable standard. Q1. (10 Marks) Quick Answers: 1. (0.5 Mark) (T/ F) It is important to make programs well understandable to other humans 2. (0.5 Mark) (T/ F) constant is a data object with a name which is bound to a value permanently during its life time. 3. (0.5 Mark) (T/ F) Interpreter languages have slow execution than complier languages. 4. (1 Mark) By using Type inference, F (a: integer) { a * 2.5;} F will be of type. 5. (1 Mark) Declare a variable x of type float and its value 9 using explicit declaration (1.5 Marks) What is the l-value of a variable? What is the r-value? (5 Marks) Match each term with the appropriate definition. Seq Stmt Seq Stmt 1 Static variables A Designed to support business system 2 Local variable B Answers: (, A ), (, B ), (, C ), (, D ), (, E ) Is a word of programming language that can not be used as user defined name. 3 Descriptor C The collection of the attributes of a variable. 4 Primitive data types D Is bound to a value only at the time it is bound to storage 5 Enumeration type E Contiguous subsequence 6 Decimal 7 Scope of program variable 8 Value 9 Constant 10 Reserved word 11 Subrange Type 12 Keyword 13 Binding Page 1

25 II. Familiar Problems Solving Objectives. The aim of the questions in this part is to evaluate that the student has some basic knowledge of the key aspects of the lecture material and can attempt to solve familiar problems. Q2. (6 Marks) Name, Bindings, Type Checking and scope: A.(2 Marks) Assume a language L, use name type compatibility, for the following C-syntax code: int x = 7; float y = 2.7; Can we write x = y; why/ why not B. (4 Marks) Here is a program written in a Pseudo code. Explain what the result would be printed under static scoping, and what the result would be under dynamic scoping. Determine the variable x belongs to what subprogram for the last call. var x; void two ( ) { if (x > 8) cout<< (x + 1); else cout<< (x - 1); } void three ( ) { var x = 15; Two ();} void main ( ) {x = 3; three();} Dynamic Scoping: Output: X belongs to: Static Scoping: Output: X belongs to: Q3. (4 Marks) Data Type: A. (2 Marks) Define Ordinal, Enumeration data type. Ordinal: Enumeration: B. (2 Marks) Assume the language L use dynamic length string, for the following C-Syntax: String S[5]; - What is the minimum number of characters that S can hold? - What is the maximum number of characters that S can hold? Page 2

### Chapter 5 Names, Binding, Type Checking and Scopes

Chapter 5 Names, Binding, Type Checking and Scopes Names - We discuss all user-defined names here - Design issues for names: -Maximum length? - Are connector characters allowed? - Are names case sensitive?

### Programming Languages, Summary CSC419; Odelia Schwartz

Programming Languages, Summary CSC419; Odelia Schwartz Chapter 1 Topics Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation Criteria Influences on Language Design

### Chapter 5 Names, Bindings, Type Checking, and Scopes

Chapter 5 Names, Bindings, Type Checking, and Scopes 長庚大學資訊工程學系 陳仁暉 助理教授 Tel: (03) 211-8800 Ext: 5990 E-mail: jhchen@mail.cgu.edu.tw URL: http://www.csie.cgu.edu.tw/jhchen All rights reserved. No part

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

### Chapter 5. Names, Bindings, and Scopes

Chapter 5 Names, Bindings, and Scopes Chapter 5 Topics Introduction Names Variables The Concept of Binding Scope Scope and Lifetime Referencing Environments Named Constants 1-2 Introduction Imperative

### Type Bindings. Static Type Binding

Type Bindings Two key issues in binding (or associating) a type to an identifier: How is type binding specified? When does the type binding take place? N. Meng, S. Arthur 1 Static Type Binding An explicit

### 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

### 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?

### Introduction Primitive Data Types Character String Types User-Defined Ordinal Types Array Types. Record Types. Pointer and Reference Types

Chapter 6 Topics WEEK E FOUR Data Types Introduction Primitive Data Types Character String Types User-Defined Ordinal Types Array Types Associative Arrays Record Types Union Types Pointer and Reference

### Question No: 1 ( Marks: 1 ) - Please choose one One difference LISP and PROLOG is. AI Puzzle Game All f the given

MUHAMMAD FAISAL MIT 4 th Semester Al-Barq Campus (VGJW01) Gujranwala faisalgrw123@gmail.com MEGA File Solved MCQ s For Final TERM EXAMS CS508- Modern Programming Languages Question No: 1 ( Marks: 1 ) -

### 9/7/17. Outline. Name, Scope and Binding. Names. Introduction. Names (continued) Names (continued) In Text: Chapter 5

Outline Name, Scope and Binding In Text: Chapter 5 Names Variable Binding Type bindings, type conversion Storage bindings and lifetime Scope Lifetime vs. Scope Referencing Environments N. Meng, S. Arthur

### 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

### COS 140: Foundations of Computer Science

COS 140: Foundations of Computer Science Variables and Primitive Data Types Fall 2017 Introduction 3 What is a variable?......................................................... 3 Variable attributes..........................................................

### 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

### References and pointers

References and pointers Pointers are variables whose value is a reference, i.e. an address of a store location. Early languages (Fortran, COBOL, Algol 60) had no pointers; added to Fortran 90. In Pascal,

### CSC 533: Organization of Programming Languages. Spring 2005

CSC 533: Organization of Programming Languages Spring 2005 Language features and issues variables & bindings data types primitive complex/structured expressions & assignments control structures subprograms

### Fifth Generation CS 4100 LISP. What do we need? Example LISP Program 11/13/13. Chapter 9: List Processing: LISP. Central Idea: Function Application

Fifth Generation CS 4100 LISP From Principles of Programming Languages: Design, Evaluation, and Implementation (Third Edition, by Bruce J. MacLennan, Chapters 9, 10, 11, and based on slides by Istvan Jonyer

### 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

### 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

### 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

### Principles of Programming Languages. Lecture Outline

Principles of Programming Languages CS 492 Lecture 1 Based on Notes by William Albritton 1 Lecture Outline Reasons for studying concepts of programming languages Programming domains Language evaluation

### 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)

### 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

### COS 140: Foundations of Computer Science

COS 140: Foundations of Variables and Primitive Data Types Fall 2017 Copyright c 2002 2017 UMaine School of Computing and Information S 1 / 29 Homework Reading: Chapter 16 Homework: Exercises at end of

### 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

### Programmiersprachen (Programming Languages)

2016-05-13 Preface Programmiersprachen (Programming Languages) coordinates: lecturer: web: usable for: requirements: No. 185.208, VU, 3 ECTS Franz Puntigam http://www.complang.tuwien.ac.at/franz/ps.html

### Chapter 8 :: Composite Types

Chapter 8 :: Composite Types Programming Language Pragmatics, Fourth Edition Michael L. Scott Copyright 2016 Elsevier 1 Chapter08_Composite_Types_4e - Tue November 21, 2017 Records (Structures) and Variants

### 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

### Imperative Programming

Naming, scoping, binding, etc. Instructor: Dr. B. Cheng Fall 2004 1 Imperative Programming The central feature of imperative languages are variables Variables are abstractions for memory cells in a Von

### Chapter 6. Data Types ISBN

Chapter 6 Data Types ISBN 0-321 49362-1 Chapter 6 Topics Introduction Primitive Data Types Character String Types User-Defined Ordinal Types Array Types Associative Arrays Record Types Union Types Pointer

### Introduction. Primitive Data Types: Integer. Primitive Data Types. ICOM 4036 Programming Languages

ICOM 4036 Programming Languages Primitive Data Types Character String Types User-Defined Ordinal Types Array Types Associative Arrays Record Types Union Types Pointer and Reference Types Data Types This

### CS 415 Midterm Exam Fall 2003

CS 415 Midterm Exam Fall 2003 Name KEY Email Address Student ID # Pledge: This exam is closed note, closed book. Questions will be graded on quality of answer. Please supply the best answer you can to

### CS 415 Midterm Exam Spring SOLUTION

CS 415 Midterm Exam Spring 2005 - SOLUTION Name Email Address Student ID # Pledge: This exam is closed note, closed book. Questions will be graded on quality of answer. Please supply the best answer you

### 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

### Names, Bindings, Scopes

Names, Bindings, Scopes Variables In imperative l Language: abstractions of von Neumann machine Variables: abstraction of memory cell or cells Sometimes close to machine (e.g., integers), sometimes not

### Organization of Programming Languages (CSE452) Why are there so many programming languages? What makes a language successful?

Organization of Programming Languages (CSE452) Instructor: Dr. B. Cheng Fall 2004 1 Why are there so many programming languages? Evolution -- we've learned better ways of doing things over time Socio-economic

### Organization of Programming Languages CS320/520N. Lecture 06. Razvan C. Bunescu School of Electrical Engineering and Computer Science

Organization of Programming Languages CS320/520N Razvan C. Bunescu School of Electrical Engineering and Computer Science bunescu@ohio.edu Data Types A data type defines a collection of data objects and

### 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

### 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

### Chapter 6. Data Types ISBN

Chapter 6 Data Types ISBN 0-321 49362-1 Chapter 6 Topics Introduction Primitive Data Types Character String Types User-Defined Ordinal Types Array Types Associative Arrays Record Types Union Types Pointer

### 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

### Chapter 6. Data Types

Chapter 6 Data Types Introduction A data type defines a collection of data objects and a set of predefined operations on those objects A descriptor is the collection of the attributes of a variable Copyright

### CS 3360 Design and Implementation of Programming Languages. Exam 1

1 Spring 2016 (Monday, March 21) Name: CS 3360 Design and Implementation of Programming Languages Exam 1 This test has 18 questions and pages numbered 1 through 6. Reminders This test is closed-notes and

### CS 415 Midterm Exam Spring 2002

CS 415 Midterm Exam Spring 2002 Name KEY Email Address Student ID # Pledge: This exam is closed note, closed book. Good Luck! Score Fortran Algol 60 Compilation Names, Bindings, Scope Functional Programming

### 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

### 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

### Test 1 Summer 2014 Multiple Choice. Write your answer to the LEFT of each problem. 5 points each 1. Preprocessor macros are associated with: A. C B.

CSE 3302 Test 1 1. Preprocessor macros are associated with: A. C B. Java C. JavaScript D. Pascal 2. (define x (lambda (y z) (+ y z))) is an example of: A. Applying an anonymous function B. Defining a function

### 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

### CS 430 Spring Mike Lam, Professor. Data Types and Type Checking

CS 430 Spring 2015 Mike Lam, Professor Data Types and Type Checking Type Systems Type system Rules about valid types, type compatibility, and how data values can be used Benefits of a robust type system

### The SPL Programming Language Reference Manual

The SPL Programming Language Reference Manual Leonidas Fegaras University of Texas at Arlington Arlington, TX 76019 fegaras@cse.uta.edu February 27, 2018 1 Introduction The SPL language is a Small Programming

### Concepts of Programming Languages (750321)

(750321) A-PDF MERGER DEMO A module For students in Departments CS, CIS, SE, ACS Faculty of IT / Philadelphia University Second Semester 2006/2007 1 (750321) Lecturer: Dr. Nadia Y. Yousif Email: nyaaqob@philadelphia.edu.jo

### CS 230 Programming Languages

CS 230 Programming Languages 11 / 20 / 2015 Instructor: Michael Eckmann Questions/comments? Chapter 6 Arrays Pointers Today s Topics We all know what arrays are. Design issues Legal types for subscripts

### Concepts of Programming Languages

Concepts of Programming Languages COMP322 Fall 2012/2013 1-1 Textbook ISBN 0-321-49362-1 Chapter 1 Preliminaries ISBN 0-321-49362-1 Chapter 1 Topics Reasons for Studying Concepts of Programming Languages

### CS558 Programming Languages

CS558 Programming Languages Winter 2017 Lecture 7b Andrew Tolmach Portland State University 1994-2017 Values and Types We divide the universe of values according to types A type is a set of values and

### 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

### Organization of Programming Languages CS3200 / 5200N. Lecture 06

Organization of Programming Languages CS3200 / 5200N Razvan C. Bunescu School of Electrical Engineering and Computer Science bunescu@ohio.edu Data Types A data type defines a collection of data objects

### 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

### Weeks 6&7: Procedures and Parameter Passing

CS320 Principles of Programming Languages Weeks 6&7: Procedures and Parameter Passing Jingke Li Portland State University Fall 2017 PSU CS320 Fall 17 Weeks 6&7: Procedures and Parameter Passing 1 / 45

### R13 SET Discuss how producer-consumer problem and Dining philosopher s problem are solved using concurrency in ADA.

R13 SET - 1 III B. Tech I Semester Regular Examinations, November - 2015 1 a) What constitutes a programming environment? [3M] b) What mixed-mode assignments are allowed in C and Java? [4M] c) What is

### Final-Term Papers Solved MCQS with Reference

Solved MCQ(S) From FinalTerm Papers BY Arslan Jan 14, 2018 V-U For Updated Files Visit Our Site : Www.VirtualUstaad.blogspot.com Updated. Final-Term Papers Solved MCQS with Reference 1. The syntax of PHP

### INSTITUTE OF AERONAUTICAL ENGINEERING

INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad -500 043 INFORMATION TECHNOLOGY TUTORIAL QUESTION BANK Name : PRINCIPLES OF PROGRAMMING LANGUAGES Code : A40511 Class : II B. Tech

### 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

### Introduction. A. Bellaachia Page: 1

Introduction 1. Objectives... 2 2. Why are there so many programming languages?... 2 3. What makes a language successful?... 2 4. Programming Domains... 3 5. Language and Computer Architecture... 4 6.

### Lecture Overview. [Scott, chapter 7] [Sebesta, chapter 6]

1 Lecture Overview Types 1. Type systems 2. How to think about types 3. The classification of types 4. Type equivalence structural equivalence name equivalence 5. Type compatibility 6. Type inference [Scott,

### Chapter 6. Structured Data Types. Topics. Structured Data Types. Vectors and Arrays. Vectors. Vectors: subscripts

Topics Chapter 6 Structured Data Types Vectors Arrays Slices Associative Arrays Records Unions Lists Sets 2 Structured Data Types Virtually all languages have included some mechanisms for creating complex

### Run-time Environments

Run-time Environments Status We have so far covered the front-end phases Lexical analysis Parsing Semantic analysis Next come the back-end phases Code generation Optimization Register allocation Instruction

### Programming Languages: Lecture 11

1 Programming Languages: Lecture 11 Chapter 9: Subprograms Jinwoo Kim jwkim@jjay.cuny.edu Chapter 9 Topics 2 Introduction Fundamentals of Subprograms Design Issues for Subprograms Local Referencing Environments

### Run-time Environments

Run-time Environments Status We have so far covered the front-end phases Lexical analysis Parsing Semantic analysis Next come the back-end phases Code generation Optimization Register allocation Instruction

### Programming Languages Third Edition. Chapter 9 Control I Expressions and Statements

Programming Languages Third Edition Chapter 9 Control I Expressions and Statements Objectives Understand expressions Understand conditional statements and guards Understand loops and variation on WHILE

### COSC252: Programming Languages: Basic Semantics: Data Types. Jeremy Bolton, PhD Asst Teaching Professor

COSC252: Programming Languages: Basic Semantics: Data Types Jeremy Bolton, PhD Asst Teaching Professor Copyright 2015 Pearson. All rights reserved. Common Types and Design Concerns Primitive Data Types

### Topic IV. Parameters. Chapter 5 of Programming languages: Concepts & constructs by R. Sethi (2ND EDITION). Addison-Wesley, 1996.

References: Topic IV Block-structured procedural languages Algol and Pascal Chapters 5 and 7, of Concepts in programming languages by J. C. Mitchell. CUP, 2003. Chapter 5 of Programming languages: Concepts

### Name, Scope, and Binding. Outline [1]

Name, Scope, and Binding In Text: Chapter 3 Outline [1] Variable Binding Storage bindings and lifetime Type bindings Type Checking Scope Lifetime vs. Scope Referencing Environments N. Meng, S. Arthur 2

### Special Topics: Programming Languages

Lecture #17 0 V22.0490.001 Special Topics: Programming Languages B. Mishra New York University. Lecture # 17 Lecture #17 1 Slide 1 Runtime Representations Variable Names Environment L-values Scope, Extent

### Programming Languages

Programming Languages Tevfik Koşar Lecture - XVIII March 23 rd, 2006 1 Roadmap Arrays Pointers Lists Files and I/O 2 1 Arrays Two layout strategies for arrays Contiguous elements Row pointers Row pointers

### Topic IV. Block-structured procedural languages Algol and Pascal. References:

References: Topic IV Block-structured procedural languages Algol and Pascal Chapters 5 and 7, of Concepts in programming languages by J. C. Mitchell. CUP, 2003. Chapters 10( 2) and 11( 1) of Programming

### Storage. Outline. Variables and Updating. Composite Variables. Storables Lifetime : Programming Languages. Course slides - Storage

Storage 1 Variables and Updating Outline Composite Variables Total and selective updating Array variables Storables Lifetime Local and global variables Heap variables Persistent variables Garbage collection

### 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

### 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

### 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

### Outline. Programming Languages 1/16/18 PROGRAMMING LANGUAGE FOUNDATIONS AND HISTORY. Current

PROGRAMMING LANGUAGE FOUNDATIONS AND HISTORY Dr. John Georgas, Northern Arizona University Copyright John Georgas All Rights Reserved Outline Current Programming languages Compiled and interpreted implementations

### Functional Programming. Big Picture. Design of Programming Languages

Functional Programming Big Picture What we ve learned so far: Imperative Programming Languages Variables, binding, scoping, reference environment, etc What s next: Functional Programming Languages Semantics

### 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

### UNIT 3

UNIT 3 Presentation Outline Sequence control with expressions Conditional Statements, Loops Exception Handling Subprogram definition and activation Simple and Recursive Subprogram Subprogram Environment

### Subprograms. Bilkent University. CS315 Programming Languages Pinar Duygulu

1 Subprograms CS 315 Programming Languages Pinar Duygulu Bilkent University Introduction 2 Two fundamental abstraction facilities Process abstraction Emphasized from early days Data abstraction Emphasized

### 1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine. 2. true / false ML can be compiled. 3. true / false FORTRAN can reasonably be considered

### 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

### 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

### MIDTERM EXAMINATION - CS130 - Spring 2005

MIDTERM EAMINATION - CS130 - Spring 2005 Your full name: Your UCSD ID number: This exam is closed book and closed notes Total number of points in this exam: 231 + 25 extra credit This exam counts for 25%

### Compiler Construction

Compiler Construction Lecture 18: Code Generation V (Implementation of Dynamic Data Structures) Thomas Noll Lehrstuhl für Informatik 2 (Software Modeling and Verification) noll@cs.rwth-aachen.de http://moves.rwth-aachen.de/teaching/ss-14/cc14/

### DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Year & Semester : I Year / II Semester Section : CSE - I Subject Code : CS7203 Subject Name : PRINCIPLES OF PROGRAMMING LANGUAGES Degree & Branch : M.E C.S.E.

### 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,

### Functional Programming. Pure Functional Programming

Functional Programming Pure Functional Programming Computation is largely performed by applying functions to values. The value of an expression depends only on the values of its sub-expressions (if any).

### Chapter 6 part 1. Data Types. (updated based on 11th edition) ISBN

Chapter 6 part 1 Data Types (updated based on 11th edition) ISBN 0-321 49362-1 Chapter 6 Topics Introduction Primitive Data Types Character String Types User-Defined Ordinal Types Array Types Associative

### 11/6/17. Functional programming. FP Foundations, Scheme (2) LISP Data Types. LISP Data Types. LISP Data Types. Scheme. LISP: John McCarthy 1958 MIT

Functional programming FP Foundations, Scheme (2 In Text: Chapter 15 LISP: John McCarthy 1958 MIT List Processing => Symbolic Manipulation First functional programming language Every version after the

### CPS 506 Comparative Programming Languages. Programming Language Paradigm

CPS 506 Comparative Programming Languages Functional Programming Language Paradigm Topics Introduction Mathematical Functions Fundamentals of Functional Programming Languages The First Functional Programming

### Pace University. Fundamental Concepts of CS121 1

Pace University Fundamental Concepts of CS121 1 Dr. Lixin Tao http://csis.pace.edu/~lixin Computer Science Department Pace University October 12, 2005 This document complements my tutorial Introduction

### CS558 Programming Languages. Winter 2013 Lecture 3

CS558 Programming Languages Winter 2013 Lecture 3 1 NAMES AND BINDING One essential part of being a high-level language is having convenient names for things: variables constants types functions etc. classes