0% found this document useful (0 votes)
34 views2 pages

PPL Question Paper

This document is an examination paper for the Principles of Programming Languages course at Jawaharlal Nehru Technological University Hyderabad, intended for B.Tech Third Year students. It consists of two parts: Part A, which is compulsory and carries 25 marks, and Part B, which includes questions from five units where students must answer one question from each unit for a total of 50 marks. The questions cover various topics related to programming languages, including semantics, parameter passing, logic programming, and specific language features.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views2 pages

PPL Question Paper

This document is an examination paper for the Principles of Programming Languages course at Jawaharlal Nehru Technological University Hyderabad, intended for B.Tech Third Year students. It consists of two parts: Part A, which is compulsory and carries 25 marks, and Part B, which includes questions from five units where students must answer one question from each unit for a total of 50 marks. The questions cover various topics related to programming languages, including semantics, parameter passing, logic programming, and specific language features.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Code No: 115AN

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

Note: This question paper contains two parts A and B.


Part A is compulsory which carries 25 marks. Answer all questions in Part A.
Part B consists of 5 Units. Answer any one full question from each unit.
Each question carries 10 marks and may have a, b, c as sub-questions.

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

c) Explain about the named constants. [2]


d) Distinguish between Pascal union types and Ada union[3] types.
e) Explain the lifetime of the variable.
f) Parameter passing in C refers to how arguments are passed to functions. In C, there are two main methods for
[3]passing parameters: pass by value and pass by reference. 1. Pass by Value: When arguments are passed by value, a copy of the actual value is made in the function's stack frame. Changes made to the parameters inside the function do not affect the original arguments. This is the default method of passing parameters in C. For example: ```c void function(int x) { x = x + 10; } int main() { int a = 5; function(a); // a is still 5 here. } ``` 2. Pass by Reference: C does not support pass by reference directly, but it can be simulated using pointers. When using pointers, the address of the variable is passed to the function, allowing it to modify the original value. For example: ```c void function(int *x) { *x = *x + 10; } int main() { int a = 5; function(&a); // a is now 15. } ``` In summary, pass by value makes a copy, while pass by reference allows for modification of the original variable.
g) What are the applications of logic programming. [2]
h) Compare semaphores with monitors. [3]
i) What are the benefits of data abstraction. [2]
j) Functional programming languages typically have the following features: first-class functions, higher-order [3]
functions, pure functions, immutability, free from side effects, recursion, and lazy evaluation. They emphasize the application of functions and the use of expressions rather than statements, promoting a declarative approach to programming.

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.

programming language features. 10


OR
3.a) Explain the parse tree for the sum and average program by using the grammar.
b) Differentiate between syntax and semantics. 10

4.a) Discuss about guarded commands with an example.


b) Explain the unconditional statements with an example. 5+5
OR
5.a) Explain type compatibility with an example.
b) Describe the different types of assignment statements. 10

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.

8.a) Describe the basic elements of Prolog.


b) Distinguish between java thread and C# thread.
OR www.ManaResults.co.in[5+5]
9. What is an exception? How to handle exceptions in Ada with an example.

10.a) Explain the comparison of functional and imperative languages.


b) Write about Haskell. Explain the functions in Haskell. 10
OR
11.a) Describe the scoping rule in common LISP, ML and Haskell.
b) Explain the applications of functional programming languages. [5+5]

--ooOoo--

www.ManaResults.co.in

You might also like