PPL-QB

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 11

21CB1503 – FUNDAMENTALS OF MANAGEMENT

COURSE OBJECTIVES
 To understand and describe syntax and semantics of programming languages
 To understand data, data types, and basic statements
 To understand call-return architecture and ways of implementing them
 To understand object-orientation, concurrency, and event handling programming
languages
 To develop programs in non-procedural programming paradigms

UNIT I SYNTAX AND SEMANTICS 9

Evolution of programming languages – describing syntax – context-free grammars –


attribute grammars – describing semantics – lexical analysis – parsing – recursive-
descent – bottom up parsing.

UNIT-II DATA, DATA TYPES, AND BASIC STATEMENTS 9

Names – variables – binding – type checking – scope – scope rules – lifetime and garbage
collection – primitive data types – strings – array types – associative arrays – record
types – union types – pointers and references – Arithmetic expressions – overloaded
operators – type conversions – relational and boolean expressions – assignment statements
– mixed mode assignments – control structures – selection – iterations – branching –
guarded statements

UNIT-III SUBPROGRAMS AND IMPLEMENTATIONS 9

Subprograms – design issues – local referencing – parameter passing – overloaded


methods – generic methods – design issues for functions – semantics of call and return –
implementing simple subprograms – stack and dynamic local variables – nested
subprograms – blocks – dynamic scoping

UNIT-IV OBJECT-ORIENTATION, CONCURRENCY AND 9


EVENT HANDLING

Object-orientation – design issues for OOP languages – implementation of object- oriented


constructs – concurrency – semaphores – monitors – message passing – threads – statement
level concurrency – exception handling – event handling.

UNIT-V FUNCTIONAL AND LOGIC PROGRAMMING LANGUAGES 9

Introduction to lambda calculus – fundamentals of functional programming


languages– Programming with Scheme – Programming with ML– Introduction to logic
and logic programming – Programming with Prolog – multi-paradigm languages.

TOTAL : 45 PERIODS
COURSE OUTCOMES
At the end of the course, the student will be able to
 Describe syntax and semantics of programming languages
 Explain data, data types, and basic statements of programming languages
 Design and implement subprogram constructs
 Apply object-oriented, concurrency, and event handling programming
constructs and develop programs in Scheme, ML, and Prolog
 Understand and adopt new programming languages
 Applying the programming Languages in creating various applications

TEXT BOOKS

 Robert W. Sebesta, “Concepts of Programming Languages”, Twelfth Edition


(GlobalEdition), Pearson, 2022.
 Michael L. Scott, “Programming Language Pragmatics”, Fourth Edition,
Elsevier, 2018.
 R. Kent Dybvig, “The Scheme programming language”, Fourth Edition,
Prentice Hall, 2011.
 Jeffrey D. Ullman, “Elements of ML programming”, Second Edition, Pearson,
1997.
 W. F. Clocksin and C. S. Mellish, “Programming in Prolog: Using the ISO
Standard”, FifthEdition, Springer, 2003.
UNIT I - SYNTAX AND SEMANTICS
PART-A
1. Define Lexeme, sentence and token.
 A sentence is a string of characters over some alphabet A language is a set of
sentences
 A lexeme is the lowest level syntactic unit of a language (e.g. sum, begin)
 A token is a category of lexemes (e.g., identifier)

2. When and whom developed Context Free Grammars and Backus Naur
Form and define its rules.
Context-Free Grammars (1950)
 Developed by Noam Chomsky
 Language generators, meant to describe the syntax of natu- ral languages
Backus-Naur Form (1959)
 Invented by John Backus to describe the syntax of Algol - 58
 BNF is equivalent to context-free grammars
An abstraction (or nonterminal symbol) can have more than one RHS
<stmt> → <single_stmt>
| begin <stmt_list> end The same as…
<stmt> → <single_stmt>
<stmt> → begin <stmt_list> end

3. Define Attribute Grammars and list primary value of AGs. (NOV /DEC 2022)
Attribute grammars (AGs) have additions to CFGs to carry some semantic info on
parse tree nodes
Primary value of AGs:
 Static semantics specification
 Compiler design (static semantics checking)
4. What are the different factors that influence the evolution of programming languages?
 Readability
 Writability
 Expressivity
 Reliability
 Cost
5. What are the different components of the context free grammar used for programming
language construction?
 A set of terminal symbols, which are the characters of the alphabet that appear in the strings
generated by the grammar.
 A set of nonterminal symbols, which are placeholders for patterns of terminal symbols that
can be generated by the nonterminal symbols.
 A set of productions, which are rules for replacing (or rewriting) nonterminal symbols (on
the left side of the production) in a string with other nonterminal or terminal symbols (on the
right side of the production).
 A start symbol, which is a special nonterminal symbol that appears in the initial string
generated by the grammar.

6. List the various syntactic elements of language. (NOV /DEC 2022)


 Character set : The choice of character set is one of the first to be made in designing language
syntax. The character set is nothing but group of characters which are allowed programming
language including special characters such as 'A', '\n'. n'. Each language may have its own
character set or may language can share same set.
 Identifiers: Identifier is a string of letters & digits beginning with a letter. These are names
that are given to various program elements, such as variables, functions.
 Operator Symbols : Most languages use the special characters + and — to represent the two
basic arithmetic operations. Primitive operations may be represented entirely by special
characters like APL.
 Keywords & Reserved Words

7. Define data type.


A data type defines a collection of data values and a set of predefined operations on
those values. Computer programs produce results by manipulating data.

8. Define Binding.
A binding is an association between an attribute and an en- tity, such as between a
variable and its type or value, or be- tween an operation and a symbol.

9. Define Binding time.


The time at which a binding takes place is called binding time.
10.Define Semantics
The meaning of the expressions, statements, and program units
11.When Ambiguity occurs in grammar?
A grammar is ambiguous iff it generates a sentential form that has two or more
distinct parse trees

PART-B

1. Explain in detail different stages in language translation. (NOV /DEC 2022)


2. Explain various syntactic elements of language with the help of examples.
3. Explain various design issues of pointer and pointers in C/C++.
4. Explain the problem caused by uniform evaluation rule while evaluating an expression and the solution
to the problem.
5. Explain various categories of sequence control.
6. Explain the different categories of scalar type variables with their advantage and disadvantages.
7.What is the difference between procedure and function? Explain with suitable example
8. What is the difference between a sentence and a sentential form in a CFG? [4M]
UNIT – II – DATA, DATA TYPES, AND BASIC STATEMENTS

PART-A

1. List the data types used in various languages and describe primitive data types,
string type and array type with its design issues.
a. Primitive Data Types
Data types that are not defined in terms of other types are called primitive data types.
nearly all programming languages provide a set of primitive data types. Some of the
primitive types are merely reflections of the hardware. For example, most integer types.
i. Numeric Type:
 Integer
 Floating point
 Complex
 Decimal
ii. Boolean
iii.Character Type
b. Character String Type
A character string type is one in which the values consist of sequences of characters.
Character string constants are used to label output, and the input and output of all kinds
of data are often done in terms of strings.
c. Array Types
An array is a homogeneous aggregate of data elements in which an individual
element is identified by its position in the aggregate, relative to the first element. The
individual data elements of an array are of the same type. References to individual array
elements are specified using subscript expressions. If any of the subscript expressions in
a reference include variables, then the reference will require an additional run-time
calculation to determine the address of the memory location being referenced.

2.Define variables. (NOV/DEC 2022)


A variable is an abstraction of a memory cell
3. Define Value
The contents of the location with which the variable is associated
4. Define static variables.
Static variables are bound to memory cells before execution begins and remains bound to the same
memory cell throughout execution.

5. List the disadvantages of Static variables. (NOV/DEC 2021)


 Lack of flexibility
 No recursion.
6. When Explicit heap-dynamic variables are allocated?
Explicit heap-dynamic variables are allocated and deallocated by explicit directives, specified by the
programmer, which take effect during execution. They are
 Referenced only through pointers or references
 E.g. dynamic objects in C++ (via new and delete), all objects in Java
7. Define Type checking
Type checking is the activity of ensuring that the operands of an operator are of compatible types
8. Define coercion
A compatible type is one that is either legal for the operator, or is allowed under language rules to be
implicitly converted, by compiler-generated code, to a legal type. This automatic conversion is called a
coercion.

9. Define Scope of a variable.


The scope of a variable is the range of statements in a program over which it’s visible
10. Define Block.
A block is a section of code in which local variables are allocated/deallocated at the start/end of the block.
11. Define an Array
An array is an aggregate of homogeneous data elements in which an individual element is identified by its
position in the aggregate, relative to the first element.
12. Define Union.
A union is a type whose variables are allowed to store different type values at different times during
execution.

13. Define Garbage Collection (GC).


GC is a process by which dynamically allocated storage is reclaimed during the execution of a program.

14. Define Associative Array.


An associative array is an unordered collection of data elements that are indexed by an
equal number of values called keys.

15. Define Record.


A record is a possibly heterogeneous aggregate of data elements in which the individual
elements are identified by names.

PART- B
1. Explain the different types of bindings in detail. (NOV/DEC 2021)
2. Explain about data types in detail.
3. Write a note on an Array.(NOV/DEC 2022)
4. Explain about Arithmetic expressions in detail.
5. Describe control structures in detail.
6. Write a note on guarded statements in detail.
UNIT – III - SUBPROGRAMS AND
IMPLEMENTATIONS PART-A
1. Define Subprogram.
A subprogram definition describes the interface to and the actions of the subprogram abstraction .
2. Define formal parameter. (NOV/DEC 2021)
A formal parameter is a dummy variable listed in the subprogram header and used in the
subprogram
3. Define actual parameter.
An actual parameter represents a value or address used in the subprogram call statement.
4. List the categories of subprograms.
• Procedures
• Functions
5. List the parameter passing methods
 Pass-by-value
 Pass-by-result
 Pass-by-value-result
 Pass-by-reference
 Pass-by-name
6. Define the term overloaded.
An overloaded subprogram is one that has the same name as another subprogram in the same
referencing environment.

7. List the design issues for functions.


Functional Side Effects: Because of the problems of side effects of functions that are called parameters
to functions should always be in-mode (actual to formal parameter).This requirement of in mode parameter
passing prevents a function from causing side effects through its parameters.

8. Define dynamic scope.


With dynamic scope, a global identifier refers to the identifier associated with the most recent environment.
Environment

9. Define nested subprogram.


A nested subprogram is a subprogram that is created within a PL/SQL block. It has two components: Actual
code and Activation record

10.Define static dynamic local variables.(NOV/DEC 2022)


A non-static local variables declared in a function are stack dynamic local variables by default. This means
that the local variables are created by allocating space on the stack and assigning these stack locations to
the variables.

11. Define dynamic chain.


The collection of dynamic links in the stack at a given time is called the dynamic chain, or call chain

PART- B
1. Explain about subprograms in detail.
2. Write in detail about semantic of call and return .
3. Write short note on overloaded methods and generic methods.
4. Explain dynamic scoping with an example. (NOV/DEC 2021)
5. How parameters are passed to the functions. Explain.

UNIT – IV - OBJECT-ORIENTATION, CONCURRENCY, AND EVENT HANDLING

PART-A
1. Define Object orientation.(NOV/DEC 2012)
Object orientation is a programming approach that focuses on objects that represent real-world things.
2. List the design issues for OOP languages. (APR/MAY 2011)
 The exclusivity of objects
 Are subclasses subtypes?
 Type checking and polymorphism
 Single and multiple inheritance
 Object allocation and deallocation
 Dynamic and static binding
 Nested classes
 Initialization of objects
3. List the disadvantages of Multiple Inheritance.(NOV/DEC 2022)
 Language and implementation complexity (in part due to name collisions)
 Potential inefficiency - dynamic binding costs more with multiple inheritance (but not much)

4. When concurrency occurs?


Concurrency can occur at four levels:
 Machine instruction level
 High-level language statement level
 Unit level
 Program level

5. List out the categories of concurrency. (NOV/DEC 2022)
Categories of Concurrency:
 Physical concurrency - Multiple independent processors ( multiple threads of control)
 Logical concurrency - The appearance of physical concurrency is presented by time-sharing one
Processor (software can be designed as if there were multiple threads of
control)
6. What is the role of the scheduler?
Used to map the task execution onto available processors.

7. Define Semaphore.
A semaphore is a data structure consisting of a counter and a queue for storing task descriptors.
Semaphores can be used to implement guards on the code that accesses shared data structures.

8. Define Monitor.
A monitor in an operating system (OS) is a synchronization construct that manages access to shared
resources and enables threads or processes to coordinate actions. Monitors are also known as
synchronization tools.

9. How message passing is achieved?


Message passing is a computer science technique that allows objects to communicate with each other by
sending and receiving messages. The sender knows the receiver object, and the message is passed through a
function call. The object then decides whether or not to respond to the message.
10. Define Thread.
In object-oriented programming, a thread is an independent path of execution within a program. Threads are
lightweight processes that can run concurrently with other threads in the same process. They share the
process's memory and resources, but they have their own stack and program counter. This allows threads to
run independently of each other, which can improve the performance of a program.

11.Define Exception Handling.


An exception is any unusual event, either erroneous or not, detectable by either hardware or
software, that may require special processing

PART-B

1. Explain in detail the “implementation of object oriented constructs”.


2. Write a short note on semaphore and monitor.
3. How message passing is achieved. Explain it with an example.
4. Explain about concurrency. (NOV/DEC 2021)
5. Define exception. How the exception is handled. Explain it with an example.
6. Write a note an event handling.
UNIT – V –FUNCTIONAL AND LOGIC PROGRAMMING LANGUAGES

1.Define Lambda calculus.


A mathematical function is a mapping of members of one set, called the domain set, to another set, called the
range set. A function definition specifies the domain and range sets, either explicitly or implicitly, along with
the mapping. The mapping is described by an expression or, in some cases, by a table.

2. Mention the objective of the design of a functional programming language.


The objective of the design of a functional programming language is to mimic mathematical functions to the greatest
extent possible.

3. Define Scheme Language. (NOV/DEC 2022)


The Scheme language is a language with simple syntax and semantics, Scheme is well suited to educational
applications, such as courses in functional programming, and also to general introductions to programming.

4. Mention the role of Scheme interpreter.


A Scheme interpreter repeatedly reads an expression typed by the user (in the form of a list), interprets the expression,
and displays the resulting value. This form of interpreter is also used by Ruby and Python.

5. Mention the role of LET function.


LET is a function that creates a local scope in which names are temporarily bound to the values of
expressions. It is often used to factor out the common sub expressions from more complicated expressions.
6. Define Functional Composition.
Function composition is a functional form that takes two functions as parameters and returns a function that
first applies the second parameter function to its parameter and then applies the first parameter function to
the return value of the second parameter function.
7. Define declarative language.
Languages used for logic programming are declarative languages, because programs written in them consist
of declarations rather than assignments and control flow statements. One of the essential characteristics of
logic programming languages is their semantics, which is called declarative semantics. The basic concept of
this semantics is that there is a simple way to determine the meaning of each statement, and it does not
depend on how the statement might be.
9. Define Multi –Paradigm Languages.
A programming language that supports both procedural and object-oriented programming concepts. C++ is
one of the multi paradigm language because it has the concepts of programming language but added the
object oriented concepts also.

10. Define Goal statements.


These statements are the basis for the theorem-proving model. The theorem is in the form of a proposition that
we want the system to either prove or disprove. In Prolog, these propositions are called goals, or queries.

Introduction to lambda calculus – fundamentals of functional programming languages–


Programming with Scheme – Programming with ML– Introduction to logic and logic programming –
Programming with Prolog – multi-paradigm languages.
PART-B

1. Explain in detail about Lambda calculus. (NOV/DEC 2022)


2. Explain the fundamentals of functional programming languages.(NOV/DEC 2021)
3. Summarize programming with scheme in detail.
4. For what sort of application logic programming is useful? Briefly explain.
5. Write a short note on “Programming with Prolog”. (NOV/DEC 2022)
6. Analyze Multi-paradigm languages in detail.
7. Write a prolog description of your family tree (based only on facts), going back to your grandparents and
including all descendants. Be sure to include all relationships.
8. Discuss about basic elements of prolog. Give examples.
9. Explain how data abstraction is implemented in ADA.

You might also like