JNTU

JNTU B.Tech II PRINCIPLES OF PROGRAMMING LANGUAGES Previous Question Paper (July/August - 2021 - R13)

B.Tech | II | II-II | R13 | July/August - 2021

Answer PaperPaper Code: 114DJMaximum Marks: 75Time: 3 hours

Answer any five questions

All questions carry equal marks

Main

1

Explain about formal methods of describing syntax.

15 marks

Answer

Formal methods of describing syntax are essential in programming language design to provide a precise, unambiguous definition of the language's structure. These methods allow for the systematic generation and recognition of valid programs.

The primary formal methods include:

  1. Backus-Naur Form (BNF): Developed by John Backus and Peter Naur, this is the most widely used notation for context-free grammars. It uses a set of production rules where a non-terminal symbol is defined by a sequence of terminals and non-terminals. The symbol ::= represents 'is defined as', and | denotes an alternative.
  2. Extended Backus-Naur Form (EBNF): This is an enhancement of BNF that introduces shorthand notations to improve readability and conciseness. It includes brackets [] for optional items, braces {} for repetition (zero or more times), and parentheses () for grouping alternatives.
  3. Syntax Graphs (Syntax Diagrams): These provide a visual representation of syntax rules. They use directed graphs where rectangles represent non-terminals, circles or ovals represent terminals, and arrows indicate the flow of valid sequences. They are often used in language manuals for easier human comprehension.
  4. Attribute Grammars: These extend context-free grammars by adding attributes to the symbols of the grammar. These attributes are used to describe context-sensitive aspects of a language, such as type checking, scope rules, and declaration requirements, which cannot be captured by standard BNF.
  5. Regular Expressions: Used primarily for defining the lexical structure (tokens) of a language. They describe patterns using operators like concatenation, union (|), and the Kleene star (*) for repetition.

These formal methods ensure that language processors, such as compilers and interpreters, can reliably parse source code by validating it against the defined grammatical rules.

2

Mention and explain about various control structures with a suitable example for each.

15 marks

Answer

Control structures are fundamental constructs in programming languages that dictate the flow of execution of statements. They are broadly categorized into three types: selection (conditional), iteration (looping), and unconditional branching.

1. Selection Control Structures: These allow a program to choose between different paths of execution based on a condition.

  • if-else: Executes a block of code if a condition is true, and an optional block if false. Example: if (x > 0) { print("Positive"); } else { print("Non-positive"); }
  • switch/case: Selects one block of code to execute from multiple options based on the value of an expression. Example: switch(day) { case 1: print("Monday"); break; default: print("Other"); }

2. Iteration Control Structures (Loops): These enable the repeated execution of a block of code as long as a specified condition remains true.

  • while loop: Checks the condition before executing the loop body. Example: while (i < 5) { print(i); i++; }
  • for loop: Combines initialization, condition, and increment/decrement in a single line for controlled iteration. Example: for (int i = 0; i < 5; i++) { print(i); }
  • do-while loop: Executes the body at least once before checking the condition. Example: do { print(i); } while (i < 0);

3. Unconditional Branching: These structures alter the flow of control without requiring a condition.

  • goto: Transfers control directly to a labeled statement within the same function. While powerful, its use is generally discouraged as it can lead to "spaghetti code" that is difficult to maintain. Example: goto label1; ... label1: print("Jumped here");
  • break and continue: Used within loops to exit the loop prematurely (break) or skip the current iteration and proceed to the next (continue). Example: for (int i = 0; i < 10; i++) { if (i == 5) break; print(i); }
315 marks
a

Explain about design issues of subprograms.

9 marks

Answer

Sign in to view the complete answer paper.

b

Explain about scope and lifetime of variable.

6 marks

Answer

Sign in to view the complete answer paper.

4

Explain about Java threads with a suitable example.

15 marks

Answer

Sign in to view the complete answer paper.

515 marks
a

Write short notes on LISP.

7 marks

Answer

Sign in to view the complete answer paper.

b

Distinguish between procedural and data abstraction giving examples.

8 marks

Answer

Sign in to view the complete answer paper.

6

Mention and explain about programming paradigms.

15 marks

Answer

Sign in to view the complete answer paper.

7

Explain: a) type checking and b) type compatibility with an example each.

15 marks

Answer

Sign in to view the complete answer paper.

8

Explain about parameter passing methods with an example.

15 marks

Answer

Sign in to view the complete answer paper.

About this paper

This page contains the question paper of PRINCIPLES OF PROGRAMMING LANGUAGES from JNTU for B.Tech IT II II-II, July/August - 2021, R13.

For the solved question paper with answers, switch to the Answer Paper tab.

Other papers in PRINCIPLES OF PROGRAMMING LANGUAGES

Loading Question Papers

Fetching data from database...