PPL Question Paper
PPL Question Paper
R13
JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY HYDERABAD
B.Tech Third Year First Semester Examinations, February/March - 2016
PRINCIPLES OF PROGRAMMING LANGUAGES
(Computer Science and Engineering)
3 hours Max. Marks: 75
Part- A
(25 Marks)
1.a) Differentiate between static and dynamic semantics. 2
union ::= 'union' identifier '{' union_member_list '}' union_member_list ::= union_member (',' union_member)*
[3] union_member ::= type identifier type ::= 'int' | 'char' | 'float' | 'double' | 'struct' identifier | 'union' identifier | other_type other_type ::= identifier
Part-B
(50 Marks)
2.a) Explain the attribute grammar and also write the attribute grammar for simple
assignment statements
Denotational semantics is a formal method for expressing the meaning of programs in a mathematical manner. It defines the meaning of a program by describing its behavior in terms of mathematical objects, allowing for a clear and concise understanding of program execution. Each construct in the programming language is associated with a mathematical function that describes the transformation of inputs to outputs, thus providing a way to reason about programs abstractly.
6. Generic subprograms in Ada allow you to define subprograms that work with any data type. This feature enhances
[10] code reusability and flexibility by allowing the same logic to be applied to different types without rewriting code. For example, you can define a generic function for swapping two values of any type. Here is a simple example: ```ada generic type T is private; procedure Swap (A, B: in out T); procedure Swap (A, B: in out T) is Temp: T; begin Temp := A; A := B; B := Temp; end Swap; procedure Swap_Integer is new Swap (Integer); procedure Swap_Float is new Swap (Float); ``` In this example, the `Swap` procedure is defined generically for type `T`. Two specific instances of the `Swap` procedure are then created for `Integer` and `Float` types. This allows you to use the same swapping logic for different types.
OR
7. An overloaded subprogram is a function or method that has the same name as another function or method but differs
[10]in the types or number of its parameters. The programming language uses these differences to determine which version of the subprogram to execute. For example, in a programming language like Python, you may have two functions named 'add'. One function takes two integers and returns their sum, while the other takes two strings and concatenates them. Here's how it might look: ```python def add(a: int, b: int) -> int: return a + b def add(a: str, b: str) -> str: return a + b ``` In this case, the 'add' function is overloaded because it has two versions: one for integers and one for strings.
--ooOoo--
www.ManaResults.co.in