CSEB314 Programming Language

CSEB314 Programming Language - UNIVERSITI TENAGA NASIONAL...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
Background image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: UNIVERSITI TENAGA NASIONAL College of Information Technology BACHELOR OF COMPUTER SCIENCE (HONS.) FINAL EXAMINATION SEMESTER II 2008/2009 PROGRAMMING LANGUAGE (CSEB314) March 2009 Time allowed: 2 hours 30 minutes + 10 minutes for reading INSTRUCTIONS TO CANDIDATES l. The total marks for this exam is 100 marks. 2. There are THREE (3) SECTIONS to this paper: Section A, Section B and Section C. 3. Answer ALL questions in the answer booklet provided. DO NOT OPEN THIS QUESTION PAPER UNTIL YOU ARE INSTRUCTED TO DO SO THIS QUESTION PAPER CONSISTS OF 5 PRINTED PAGES INCLUDING THIS PAGE SECTION A : TRUE OR FALSE (10 QUESTIONS, 10 MARKS) Instruction : For each of the following question, answer TRUE or FALSE. 1. Variable can be characterized based on how it’s bound to the storage. Binding is a process to group variables which have same attributes. In some language like C, variables can be in different types in different time of execution points. Type conversion will always be widened in an assignment statement. It is proven that sequence, selection and pretest logical loops are not enough to express most computation problems, that is Why Djikstra’s guarded command was introduced. The unconditional branch, or goto, had been very important in most of modern languages. Coroutines is a special kind of subprogram which allows only single entry point to a subpro gram. A function is a subprogram which only suitable to models complex mathematical computations. Static chains are primary method to access local variables in subprograms which implement static scoping and static binding. 10. Shallow access is an alternative method to deep access for tracing variable Semester II 2008/2009 referencing environment in a static scoping. Page 2 of 5 Programming Language SECTION B : SHORT ANSWER (13 QUESTIONS, 40 MARKS) Instruction : Give an accurate answer for each question. Question 1 Describe the terms writability and readability in the context of evaluating programming language. [2 marks] I Question 2 Explain how does readability and writability influence the reliability of programming languages. [2 marks] Question 3 Explain why, when a program is compiled, it is faster (to compile and run) compared to interpreted program? [2 marks] Question 4 Describe the term syntax and semantic. [2 marks] Question 5 Describe the terms token and lexeme. Give an example of tokens and lexemes extracted from a language syntax. [4 marks] Question 6 Terminals and non-terminals are used in BNF grammar. By giving example of a BNF grammar, explain the terms terminal and non-terminal. [4 marks] Page 3 of 5 Semester [1 2008/2009 Programming Language Question 7 With appropriate example, explain the relationship between operator precedence rules and parse tree. [4 marks] Question 8 Explain the sextuple attributes of a variable. [6 marks] Question 9 Storage binding for a variable can be either static or dynamic. Explain why static storage binding is more efficient compared to dynamic storage binding. [2 marks] Question 10 Explain the relationship between variable scope and lifetime. [2 marks] Question 11 Explain and give an example of situation where short-circuit evaluation occurs. [4 marks] Question 12 “Unconditional branching provides great flexibility in program writing, but also leads to serious readability problem.” Explain the statement. [4 marks] Question 13 Explain the relationship between static chain, dynamic chain and variable scoping. [2 marks] Page 4 of 5 Semester 11 2008/2009 Programming Language SECTION C : PROBLEM SOLVING (2 QUESTIONS, 50 MARKS ) Instruction : Answer all questions. Question 1 Given to you a BNF grammar for a language called Z as below: <Z> a program <header><body> <header> a <prog_name><prog_id> : <progflname> a <identifier> <prog_id> a <digit> <body> —+ <stmt> I <stmt>;<body> <stmt> a <identifier> = <int_val> | <identifier> = <expr> <expr> a <identifier> + <identifier> <int_val> a <digit> ] <digit><int_value> <identifier> a <alpha> I <alpha><identifier> <alpha> a a|b|c...lz <digit> a o|1|2m|9 (a) Write an example of a complete program syntax based on the BNF grammar given above. [10 marks] (b) Produce a symbol table for the syntax in (a) [5 marks] (c) Assuming a complete lex function had been constructed, using recursive descent algorithm, write syntax analyzer functions for <header>, <prog_name>, <body>, <stmt> and <expr>. [25 marks] Question 2 When passing a multidimensional array to a subprogram, compiler must be able to build the mapping function for that array while seeing only the text of the subprogram. Show how the mapping can be done for a row-major order when the lower-bound of all indices is ZERO (0) and the element size is FOUR (4) bytes. [10 marks] --- End of Questions --- Page 5 of 5 Semester 11 2008/2009 Programming Language ...
View Full Document

This document was uploaded on 03/11/2010.

Page1 / 5

CSEB314 Programming Language - UNIVERSITI TENAGA NASIONAL...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online