Вы находитесь на странице: 1из 154

Geethanjali College of Engineering and Technology

Cheeryal (V), Keesara (M), Ranga Reddy District 501 301 (T.S)

PRINCIPLES OF PROGRAMMING LANGUAGES


COURSE FILE

DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING
(2015-2016)

Faculty In charge

HOD-CSE
Dr. D.S.R. Murthy

Contents
S.No
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
A
B
25
26

Topic

Cover Page
Syllabus copy
Vision of the Department
Mission of the Department
PEOs and POs
Course objectives and outcomes

Course mapping with POs


Brief notes on the importance of the course and how it fits into the curriculum
Prerequisites if any
Instructional Learning Outcomes
Class Time Table

Individual Time Table


Lecture schedule with methodology being used/adopted
Detailed notes
Additional topics
University Question papers of previous years
Question Bank
Assignment Questions

Page. No.
3
4
6
6
7
9
15
10
10
11
12
16
16
19
114
118
124
126
140
140
140
141
142

Unit wise Quiz Questions and long answer questions

Tutorial problems
Known gaps ,if any and inclusion of the same in lecture schedule
Discussion topics , if any
References, Journals, websites and E-links if any
Quality Measurement Sheets
Course End Survey
Teaching Evaluation
Student List
Group-Wise students list for discussion topic

Course coordinator

Program Coordinator

145

HOD
2

GEETHANJALI COLLEGE OF ENGINEERING AND TECHNOLOGY


DEPARTMENT OF COMPUTER SCIENCE ENGINEERING

(Name of the Subject / Lab Course) : Principles of Programming Languages


(JNTU CODE 50511)

Branch:
Year:
Semester:

Programme : UG

CSE A & B

Version No : 3

III

Updated on :

No.of pages : 155

Classification status (Unrestricted / Restricted )


Distribution List :

Prepared by : 1) Name : P.Haritha

1) Name :

2) Sign

2) Sign :

3) Design : Asst.Prof

3) Design :

4) Date

4) Date :

Verified by : 1) Name

2) Sign

* For Q.C Only.

1) Name :

3) Design :

2) Sign

4) Date

3) Design :

4) Date

Approved by : (HOD ) 1) Name :


2) Sign

3) Date :

2.JNTU Syllabus :
UNIT I :
Preliminary Concepts: Reasons for studying, concepts of programming languages, Programming
domains, Language Evaluation Criteria, influences on Language design, Language categories,
Programming Paradigms Imperative, Object Oriented, functional Programming , Logic Programming.
Programming Language Implementation Compilation and Virtual Machines, programming
environments. Syntax and Semantics: general Problem of describing Syntax and Semantics, formal
methods of describing syntax - BNF, EBNF for common programming languages features, parse trees,
ambiguous grammars, attribute grammars, denotational

semantics and axiomatic semantics for

common programming language features.

UNIT II :
Data types: Introduction, primitive, character, user defined, array, associative, record, union, pointer
and reference types, design and implementation uses related to these types. Names, Variable, concept
of binding, type checking, strong typing, type compatibility, named constants, variable initialization.
Expressions and Statements: Arithmetic relational and Boolean expressions, Short circuit evaluation
mixed mode assignment, Assignment Statements, Control Structures Statement Level, Compound
Statements, Selection, Iteration, Unconditional Statements, guarded commands.

UNIT III:
Subprograms and Blocks: Fundamentals of sub-programs, Scope and lifetime of variable, static and
dynamic scope, Design issues of subprograms and operations, local referencing environments,
parameter passing methods, overloaded sub-programs, generic sub-programs, parameters that are subprogram names, design issues for functions user defined overloaded operators, co routines.

UNIT IV :
Abstract Data types: Abstractions and encapsulation, introductions to data abstraction, design issues,
language examples, C++ parameterized ADT, object oriented programming in small talk, C++, Java, C#,
Ada 95

Concurrency: Subprogram level concurrency, semaphores, monitors, massage passing, Java threads, C#
threads.
Exception handling : Exceptions, exception Propagation, Exception handler in Ada, C++ and Java.
Logic Programming Language : Introduction and overview of logic programming, basic elements of
prolog, application of logic programming.

UNIT V :
Functional Programming Languages: Introduction, fundamentals of FPL, LISP, ML, Haskell, application of
Functional Programming Languages and comparison of functional and imperative Languages.
Scripting Languages : Pragmatics , Key concepts , Case Study : Python values and types , variables ,
storage and control , Binding and scope , procedural abstraction , data abstraction ,separate compilation
, module library

5. Suggested Books :
Text Books :
1. Concepts of Programming Languages Robert .W. Sebesta 8/e, Pearson Education 2008.
2.. Programming Language Design Concepts , D.A.Watt,Wiley dreamtech,rp-2007
Reference Books :
1. Programming Languages , 2nd Edition , A.B.Tucker,R.E.Noonan,TMH
2. Programming languages K.C.Louden,2nd Edition,Thomson 2003
3. LISP Patric Henry Winston and Paul Horn Pearson Education.
4. Programming in PROLOG,W.F.Clocksin,&C.S.Mellish,5th Edition,Springer
5. Programming Python,M.Lutz,3rd Edition,Oreilly,SPD,rp-2007
6. Core Python Programming ,Chun ,II Edition,Pearson Education,2007
7. Guide to Programming with Python,Micheal Dawson,Thomson,2008

3.Vision of the Department


To produce globally competent and socially responsible computer science engineers
contributing to the advancement of engineering and technology which involves creativity and
innovation by providing excellent learning environment with world class facilities.

4.Mission of the Department


1. To be a center of excellence in instruction, innovation in research and scholarship, and
service to the stake holders, the profession, and the public.
2. To prepare graduates to enter a rapidly changing field as a competent computer science
engineer.
3. To prepare graduate capable in all phases of software development, possess a firm
understanding of hardware technologies, have the strong mathematical background
necessary for scientific computing, and be sufficiently well versed in general theory to allow
growth within the discipline as it advances.
4. To prepare graduates to assume leadership roles by possessing good communication skills,
the ability to work effectively as team members, and an appreciation for their social and
ethical responsibility in a global setting.

5 .PROGRAM EDUCATIONAL OBJECTIVES (PEOs) OF C.S.E. DEPARTMENT


1. To provide graduates with a good foundation in mathematics, sciences and engineering
fundamentals required to solve engineering problems that will facilitate them to find
employment in industry and / or to pursue postgraduate studies with an appreciation for
lifelong learning.
2. To provide graduates with analytical and problem solving skills to design algorithms,
other hardware / software systems, and inculcate professional ethics, inter-personal skills
to work in a multi-cultural team.
3. To facilitate graduates to get familiarized with the art software / hardware tools, imbibing
creativity and innovation that would enable them to develop cutting-edge technologies of
multi-disciplinary nature for societal development.

PROGRAM OUTCOMES (CSE)


1. An ability to apply knowledge of mathematics, science and engineering to develop

and analyze computing systems.


2. an ability to analyze a problem and identify and define the computing requirements

appropriate for its solution under given constraints.


3. An ability to perform experiments to analyze and interpret data for different

applications.
4. An ability to design, implement and evaluate computer-based systems, processes,

components or programs to meet desired needs within realistic constraints of time and
space.
5. An ability to use current techniques, skills and modern engineering tools necessary to

practice as a CSE professional.


6. An ability to recognize the importance of professional, ethical, legal, security and

social issues and addressing these issues as a professional.


7. An ability to analyze the local and global impact of systems /processes /applications

/technologies on individuals, organizations, society and environment.


8. An ability to function in multidisciplinary teams.
7

9. An ability to communicate effectively with a range of audiences.


10. Demonstrate knowledge and understanding of the engineering, management and

economic principles and apply them to manage projects as a member and leader in a
team.
11. A recognition of the need for and an ability to engage in life-long learning and

continuing professional development


12. Knowledge of contemporary issues.
13. An ability to apply design and development principles in producing software systems

of varying complexity using various project management tools.


14. An ability to identify, formulate and solve innovative engineering problems.

6.Course Objectives and Outcomes


Geethanjali College of Engineering&Technology
Cheeryal(v),Keesara(M),RR Dt.AP-501301
Name of subject: Principles Of Programming Languages
Dept: CSE Class: CSE III- A&B
Faculty: P.Haritha

Academic year: 2015-2016

Course description
The main topics of this course include a comparative study of programming language features,
an introduction to programming language design and implementation, and an introduction to the
theory of formal languages.

The course objectives are

To provide an introduction to formalisms for specifying syntax and semantics of


programming languages, including an introduction to the theory of formal languages,
To provide an exposure to core concepts and principles in contemporary programming
languages, and
To explore various important programming methodologies, such as functional
programming, logic programming, programming with abstract data types, and objectoriented programming.

Learning Outcomes
Upon successful completion of this course, the student will be able to:

Identify the common concepts used to create programming languages.


Compare and contrast factors and commands that affect the programming state.
Explain the evolution and key features of the major programming languages.
Analyze and evaluate new programming languages and new language features.
Illustrate how execution ordering affects programming.
Identify the basic objects and constructs in Object-Oriented Programming.
Explain the characteristics of pure functional functions in functional programming.
Describe the structures and components utilized in logical programming.
Demonstrate an understanding of good user interface design principles through
appropriate use of such principles and through exercising judgment in the use of such
principles when carrying out tasks or projects

7.Brief notes on the importance of the course and how it fits into the curriculum
The study of programming languages examines the principles and limitations of computing
(or programming) models, the effective design and use of systems or languages based on
these models and methods to compare their relative strengths and weaknesses in particular
contexts. Undergraduate students benefit from studying this course, regardless of their future
career paths and interests. It strengthens a students understanding of computation itself, its
power and its limitations. Moreover, the knowledge and skills acquired enable students to
critically compare and choose the most appropriate abstractions for describing particular programs, and to adopt and develop new models as they emerge.

8.Prerequisites if any
Basic knowledge about C,C++ & Java Programming languages .

10

9..Instructional Learning Outcomes

Geethanjali College of Engineering and Technology


CHEERYAL (V), KEESARA (M), R.R.DIST-501301, ANDHRAPRADESH

Department of Computer Science & Engineering


Name of the Faculty:

P.Haritha

Name of the Subject: PPL

Year and semester: III B.Tech CSE A & B

Academic year: 2015-2016

Learning Outcomes

S.No Unit
1

Contents
Preliminary

Concepts:

Outcomes

Reasons

for

Convinces the
student that this
course is indeed
important

Explain Important
features of PLs

Identify which

studying concepts of programming


languages,

Programming

domains,

Language Evaluation Criteria, influences


on

Language

categories,

design,

Language

Programming Paradigms.

Programming Language Implementation

language is suited

programming environments.

best for what type

Syntax and Semantics: How to describe


Syntax and Semantics, formal methods

of project

. Write PL

of describing syntax - BNF, EBNF , parse

semantics

trees, attribute grammar, denotational

technically.

semantics and axiomatic semantics.

Forms a good
foundation for the
course Compiler
Design

11

II

Data types: Primitive,

user defined, At the end of the chapter

array, associative array , record, union,

Distinguish

pointer and reference types, design and

which PLs

implementation issues related to these

support what

types. Variable, initialization, concept

datatypes and the

of binding, type checking, strong typing,

rationale behind
their inclusion

type compatibility, named constants.

Expressions and Statements: Arithmetic

Design issues to
be considered

relational and Boolean expressions,

while designing

Short circuit evaluation, mixed mode

new data types

assignment, Assignment Statements,

in potential new

Control Structures Statement Level,

PLs

Compound Statements, Selection,

Iteration, Unconditional Statements,


guarded commands.

Explain Which
PL supports what
control
statements
Identify the
limitations of
control
statements in
different PLs
Make judicious
choice of control
statements in a
potential new PL

III

Subprograms and Blocks: Fundamentals At the end of the chapter


of sub-programs, Scope and lifetime of

Outline the

variable, static and dynamic scope,

importance of

Design issues of subprograms and

process abstraction.

operations,

local

environments,

parameter

methods,

overloaded

referencing
passing

sub-programs,

Comfortable with
advanced topics in
contemporary PLs

12

generic sub-programs, parameters that

like overloaded

are sub-program names, design issues

subprograms and

for functions user defined overloaded

generic subprograms

operators, co routines.

Is ready to assimilate
the concept of data
abstraction

VI

Abstract Data types: Abstractions and At the end of the chapter


encapsulation, introductions to data

Appreciate the

abstraction, design issues, language

gradual evolution of

examples, C++ parameterized ADT,

programming

object oriented programming in small

languages to include

talk, C++, Java, C#, Ada 95 Concurrency:

process abstraction

Subprogram

level

concurrency,

semaphores,

monitors,

massage

passing, Java threads, C# threads.


Exception

handling

exception

Propagation,

and data abstraction

Ex:C,C++,Java

Write programs in
C++,Java and Ada

Exceptions,

showing abstract

Exception

data type

handler in Ada, C++ and Java.

implementations in

Logic Programming Language :


Introduction and overview of logic

these languages

Outline the

programming, basic elements of prolog,

concurrency concept

application of logic programming

of Threads in Java

Design an exception
handler in a PL

Identify alternate
form of
programming ie
logic programming

Identify for what

13

type of applications
logic programming
languages are
preferred over
imperative
languages

Functional Programming Languages: At the end of the chapter


Introduction, fundamentals of FPL, LISP,

Outline alternate

ML, Haskell, application of Functional

form of

Programming

and

programming ie

and

functional

comparison

Languages
of

functional

imperative Languages.
Scripting Languages : Pragmatics , Key

programming

type of applications

concepts , Case Study : Python values

functional languages

and types , variables , storage and

are preferred over

control , Binding and scope , procedural

imperative

abstraction , data abstraction ,separate


compilation , module library

Identify for what

languages

Write small
programs in Python

HOD

Signature of the faculty


14

10. Mapping of Course to PEOs and POs


Course
PPL

PEOS
PEO1,PEO2,PEO3

POs
PO2,PO3,PO4,PO5,PO7,PO8,PO11

Mapping of Course outcomes to Program Outcomes


S.No.

Course Outcome

Identify the common concepts used to


create programming languages.

Compare and contrast factors and


commands that affect the programming
state.

PO3,PO7

Explain the evolution and key features of


major programming languages
Analyze and evaluate new programming
languages and new language features
Illustrate how execution ordering affects
programming.

PO1,P11

Explain the characteristics of pure


functional
functions
in
functional
programming.

PO2,PO4

Describe the structures and components


utilized in logical programming
Demonstrate good user interface design
principles through appropriate use of such
principles and through
exercising
judgment in the use of such principles
when carrying out tasks or projects.

PO2,PO4,PO7

4
5

POs
PO2, PO3 ,PO5

PO3,PO5,PO7
PO5,PO8

PO3,PO11,PO7

11.Class Time Table


12.Individual Time Table
13. Lecture schedule with methodology being used/adopted along with
tutorial, assignment and NPTEL class schedule.

15

Geethanjali College of Engineering&Technology


Cheeryal(v),Keesara(M),RR Dt.AP-501301
Name of subject: Principles Of Programming Languages
Dept: CSE Class: CSE III-1 A,B
Faculty: P.Haritha

Academic year: 2015-2016


LESSON PLAN

Topics Covered

Unit

Unit-1 Introduction

No of

Teaching

Periods

aids

BB

BB

Language Evaluation Criteria

BB

Influences on Language design, Language categories

BB

Programming Paradigms Imperative, Object Oriented, functional ,

BB

Language Implementation Compilation and Virtual Machines.

BB

programming environments

BB

Syntax and Semantics: general Problem of describing Syntax and

BB

Formal methods of describing syntax using BNF

BB

Parse trees, Ambiguous grammar

BB

EBNF

BB

Attribute Grammar

BB

Example for Attribute Grammar

BB

Operational Semantics

BB

Axiomatic semantics

BB

Denotational Semantics

BB

Tutorial/Assignment/NPTEL

LCD

BB

BB

Reasons for studying concepts of programming languages,


Programming domains

Logic Programming.

Semantics

Unit-2 Introduction , Primitive data types


User defined, array, associative

16

record, union

BB

pointer and reference types

BB

Design and implementation uses related to these types

BB

Names, Variables, concept of binding

BB

type checking, strong typing

BB

Type compatibility, named constants, variable initialization.

BB

Arithmetic and relational expressions

BB

Boolean expressions, Unconditional Statements

BB

Short circuit evaluation mixed mode assignment

BB

Assignment Statements

BB

Control Structures Statement Level

BB

Control Structures -Compound Statements

BB

Selection, Iteration Statements

BB

Unconditional Statements

BB

Guarded commands.

BB

Tutorial/Assignment/NPTEL

LCD

BB

Scope and lifetime of variable

BB

Static scope

BB

dynamic scope

BB

Local referencing environments, parameter passing methods

BB

Overloaded sub-programs, generic sub-programs

BB

parameters that are sub-program names

BB

Design issues for functions, co routines.

BB

Tutorial/Assignment/NPTEL

LCD

BB

BB

Unit-3 Fundamentals of sub-programs, Design issues of subprograms and


operations

Unit-4 Abstractions and encapsulation, introductions to data abstraction,


design issues, language examples
C++ parameterized ADT

17

Object oriented programming in small talk, C++, Java

BB

Object oriented programming in C#, Ada 95

BB

Concurrency: Subprogram level concurrency

BB

Semaphores

BB

monitors, massage passing

BB

Exceptions, Exception Propagation,

BB

Exception handler in Ada

BB

Exception handler in C++

BB

Exception handler in Java

BB

Introduction and overview of logic programming

BB

Basic elements of prolog

BB

Applications of logic programming.

BB

Tutorial/Assignment/NPTEL

LCD

Java threads, C# threads

Unit-5 Functional Programming Languages Introduction, Comparison of 1

BB

functional and imperative Languages.


LISP

BB

ML, Haskell

BB

Scripting Languages : Pragmatics , Key concepts

BB

Case Study : Python values and types , variables

BB

Case Study : Python storage and control , Binding and scope

BB

procedural abstraction , data abstraction

BB

Separate compilation , module library

BB

Tutorial/Assignment/NPTEL

LCD

Revision/Exam paper solving/Additional topics

Total

73

18

14. Detailed Notes

UNIT I : Preliminary Concepts

I . Introductory topics :

What is a programming language?


What features do programming languages have?
How are these features implemented?

Reasons for Studying Concepts of Programming Languages :

Increased ability to express ideas


Improved background for choosing appropriate languages
Increased ability to learn new languages
Better understanding of significance of implementation
Overall advancement of computing

Programming Domains :

Scientific applications
Large number of floating point computations
Fortran
Business applications
Produce reports, use decimal numbers and characters
19

COBOL
Artificial intelligence
Symbols rather than numbers manipulated
LISP
Systems programming
Need efficiency because of continuous use
C
Web Software
Eclectic collection of languages: markup (e.g., XHTML), scripting (e.g., PHP),
general-purpose (e.g., Java)

II .Language Evaluation Criteria :

Readability: the ease with which programs can be read and understood
Writability: the ease with which a language can be used to create programs
Reliability: conformance to specifications (i.e., performs to its
specifications)
Cost: the ultimate total cost

1.Readability :
Overall simplicity
A manageable set of features and constructs
Few feature multiplicity (means of doing the same operation)
Minimal operator overloading
Orthogonality
20

A relatively small set of primitive constructs can be combined in a


relatively small number of ways
Every possible combination is legal
Control statements
The presence of well-known control structures (e.g., while
statement)
Data types and structures
The presence of adequate facilities for defining data structures
Syntax considerations
Identifier forms: flexible composition
Special words and methods of forming compound statements
Form and meaning: self-descriptive constructs, meaningful keywords
Simplicity and orthogonality
Few constructs, a small number of primitives, a small set of rules for
combining them
Support for abstraction
The ability to define and use complex structures or operations in
ways that allow details to be ignored
Expressivity
A set of relatively convenient ways of specifying operations
Example: the inclusion of for statement in many modern languages
Type checking
Testing for type errors
Exception handling
Intercept run-time errors and take corrective measures
21

Aliasing
Presence of two or more distinct referencing methods for the same
memory location
Readability and writability
A language that does not support natural ways of expressing an
algorithm will necessarily use unnatural approaches, and hence
reduced reliability
2.Writability :
Simplicity and orthogonality
Few constructs, a small number of primitives, a small set of rules for
combining them
Support for abstraction
The ability to define and use complex structures or operations in
ways that allow details to be ignored
Expressivity
A set of relatively convenient ways of specifying operations
Example: the inclusion of for statement in many modern languages
3.Reliability :
Type checking
Testing for type errors
Exception handling
Intercept run-time errors and take corrective measures
Aliasing
Presence of two or more distinct referencing methods for the same
memory location
22

Readability and writability


A language that does not support natural ways of expressing an
algorithm will necessarily use unnatural approaches, and hence
reduced reliability
4. Cost :

Training programmers to use language


Writing programs (closeness to particular applications)
Compiling programs
Executing programs
Language implementation system: availability of free compilers, libraries
Reliability: poor reliability leads to high costs
Maintaining programs

III. Primary influences on language design:


1. Computer architecture :
- We use imperative languages, at least in part, because we use von
Neumann machines
2. Programming methodologies :
- 1950s and early 1960s: Simple applications; worry about machine
efficiency
- Late 1960s: People efficiency became important; readability, better
control structures
23

- Late 1970s: Data abstraction


- Middle 1980s: Object-oriented programming
IV. Language Categories :

Imperative
Central features are variables, assignment statements, and iteration
Examples: C, Pascal
Functional
Main means of making computations is by applying functions to
given parameters
Examples: LISP, Scheme
Logic (declarative)
Rule-based (rules are specified in no particular order)
Example: Prolog

V Implementation Methods :
1. Compilation:
- Translate high-level program to machine code
- Slow translation
- Fast execution
2. Pure interpretation:
- No translation

24

- Slow execution
- Becoming rare
3. Hybrid implementation systems:
- Small translation cost
- Medium execution speed
VI. Programming Environments :

The collection of tools used in software development


The old way used the console and independent tools
UNIX/Linux
vi or emacs for editing
compiler
debugger
Integrated Development Environments provide a graphical interface to
most of the necessary tools

VII. Comparison of following Programming languages :


1.FORTRAN :
- Names could have up to six characters
- Posttest counting loop (DO)
- Formatted i/o
- User-defined subprograms
25

- Three-way selection statement (arithmetic IF)


- No data typing statements
- No separate compilation
- Compiler released in April 1957, after 18 worker/
years of effort
- Programs larger than 400 lines rarely compiled correctly,
- Code was very fast
- Quickly became widely used
- Dramatically changed forever the way computers are used
2.LISP - 1959 :
- LISt Processing language (Designed at MIT by McCarthy)
- AI research needed a language that:
1. Process data in lists (rather than arrays)
2. Symbolic computation (rather than numeric)
- Only two data types: atoms and lists
- Syntax is based on lambda calculus
- Pioneered functional programming
- No need for variables or assignment
- Control via recursion and conditional expressions
26

- Still the dominant language for AI


- COMMON LISP and Scheme are contemporary dialects of LISP
- ML, Miranda, and Haskell are related languages
3. COBOL :
- First macro facility in a high-level language
- Hierarchical data structures (records)
- Nested selection statements
- Long names (up to 30 characters), with hyphens
- Data Division
- Comments:
- First language required by DoD; would have
failed without DoD
- Still the most widely used business
applications language
4. BASIC 1964:
- Designed by Kemeny & Kurtz at Dartmouth
- Easy to learn and use for non-science students
- Fast turnaround for homework
- Free and private access
27

- User time is more important than computer time


- Current popular dialects: QuickBASIC and Visual BASIC
5. SIMULA 67 1967:
- Designed primarily for system simulation (in Norway by Nygaard and Dahl)
- Based on ALGOL 60 and SIMULA I
- Primary Contribution:
- Coroutines - a kind of subprogram
- Implemented in a structure called a class
- Classes are the basis for data abstraction
6. Pascal - 1971 :
- Designed by Wirth, who quit the ALGOL 68 committee
- Designed for teaching structured programming
- Small, simple, nothing really new
7. C 1972:
- Designed for systems programming (at Bell Labs by Dennis Richie)
- Evolved primarily from B, but also ALGOL 68
- Powerful set of operators, but poor type checking
- Initially spread through UNIX
8. Smalltalk - 1972-1980 :
28

- Developed at Xerox PARC, initially by Alan Kay, later by Adele Goldberg


- First full implementation of an object-oriented language (data abstraction,
inheritance, and dynamic type binding)
- Pioneered the graphical user interface everyone now uses
9. C++ - 1985 :
- Developed at Bell Labs by Stroustrup
- Evolved from C and SIMULA 67
- Facilities for object-oriented programming, taken partially from SIMULA 67,
were added to C
- Also has exception handling
- A large and complex language, in part because it supports both procedural and
OO programming
- Rapidly grew in popularity, along with OOP
- ANSI standard approved in November, 1997
10. Java (1995):
- Developed at Sun in the early 1990s
- Based on C++
- Significantly simplified
- Supports only OOP
29

- Has references, but not pointers


- Includes support for applets and a form of concurrency

Syntax and Semantics


Syntax: the form or structure of the expressions, statements, and program
units
Semantics: the meaning of the expressions, statements, and program units
Syntax and semantics provide a languages definition
Users of a language definition
Other language designers
Implementers
Programmers (the users of the language)
Terminology :
A metalanguage is a language used to describe another language
A sentence is a string of characters over some alphabet
A language is a set of sentences
a language is specified by a set of rules
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)

Two approaches to Language Definition :

30

Recognizers
Read a string and decide whether it follows the rules for the language
Example: syntax analysis part of a compiler (Chapter 4)
Generators
A device that generates sentences of a language (BNF)
More useful for specifying the language than for checking a string

II.Formal Methods of Describing Syntax :


Backus-Naur Form and Context-Free Grammars
Most widely known method for describing programming language
syntax
Developed as part of the process for specifying ALGOL
Define a class of languages called context-free languages
Extended BNF
Improves readability and writability of BNF

III.BNF Fundamentals :
Non-terminals: BNF abstractions used to represent classes of syntactic
structures
Terminals: lexemes and tokens
Grammar: a collection of rules
Examples of BNF rules:
31

<ident_list> identifier
| identifier, <ident_list>
<if_stmt> if <logic_expr> then <stmt>

BNF Rules :

A rule has a left-hand side (LHS) and a right-hand side (RHS), and consists
of terminal and nonterminal symbols

In a context-free grammar, there can only be one symbol on the LHS


A grammar is a finite nonempty set of rules
An abstraction (or nonterminal symbol) can have more than one RHS
<stmt> <single_stmt>
| begin <stmt_list> end

Derivations :
BNF is a generative device
Use a grammar to generate sentences that belong to the language
the grammar describes
A derivation is a repeated application of rules, starting with the start
symbol and ending with a sentence (all terminal symbols)

IV. An Example Grammar:


<program> -> <stmts>
32

<stmts> -> <stmt> | <stmt> ; <stmts>


<stmt> -> <var> = <expr>
<var> -> a | b | c | d
<expr> -> <term> + <term> | <term> - <term>
<term> -> <var> | const
An Example Derivation :
<program> => <stmts> => <stmt>
=> <var> = <expr>
=> a = <expr>
=> a = <term> + <term>
=> a = <var> + <term>
=> a = b + <term>
=> a = b + const
V.Context-Free Grammars :
- Developed by Noam Chomsky in the mid-1950s
- Language generators, meant to describe the syntax of natural
- Define a class of languages called context-free languages
Backus Normal Form (1959) & EBNF
- Invented by John Backus to describe Algol 58
33

- BNF is equivalent to context-free grammars .


-In BNF, abstractions are used to represent classes of syntactic structures-they act like syntactic variables (also called nonterminal symbols) e.g.
<while_stmt> -> while <logic_expr> do <stmt>
This is a rule; it describes the structure of a while statement
BNF is a generative device
Use a grammar to generate sentences that belong to the language
the grammar describes
A derivation is a repeated application of rules, starting with the start symbol and
ending with a sentence (all terminal symbols)
BNF:
<expr> -> <expr> + <term>

| <expr> - <term>

| <term>

<term> -> <term> * <factor>

| <term> / <factor>

| <factor>
EBNF:

<expr> -> <term> {(+ | -) <term>}


34

<term> -> <factor> {(* | /) <factor>}

VI. Attribute Grammars (AGs) (Knuth, 1968):


Context free grammars cannot describe all of the syntax of programming
languages
- Additions to cfgs to carry some semantic info along through parse trees
Primary value of Attribute Grammars:
1. Static semantics specification
2. Compiler design(static semantics checking)
Def: An attribute grammar is a cfg G = (S, N, T, P) with the following
additions:
1. For each grammar symbol x there is a set A(x) of attribute values
2. Each rule has a set of functions that define certain attributes of the
nonterminals in the rule
3. Each rule has a (possibly empty) set of predicates to check for attribute
consistency
Attribute values are computed as follows :
1. If all attributes were inherited, the tree could be decorated in top-down order.
2. If all attributes were synthesized, the tree could be decorated in bottom-up
order.
35

3. In many cases, both kinds of attributes are used, and it is some


combination of top-down and bottom-up that must be used.
Example: expressions of the form id + id
- id's can be either int_type or real_type
- types of the two id's must be the same
- type of the expression must match it's expected type
BNF:
<expr> -> <var> + <var>
<var> -> id
Attributes:
actual_type - synthesized for <var> and <expr>
expected_type - inherited for <expr>
Attribute Grammar:
1. Syntax rule: <expr> -> <var>[1] + <var>[2]
Semantic rules:
<var>[1].env <expr>.env
<var>[2].env <expr>.env
<expr>.actual_type <var>[1].actual_type
Predicate:
<var>[1].actual_type = <var>[2].actual_type
36

<expr>.expected_type = <expr>.actual_type
2. Syntax rule: <var> -> id
Semantic rule:
<var>.actual_type <- lookup (id, <var>.env)

VII. Axiomatic Semantics :


Based on formal logic (first order predicate calculus)
- Original purpose: formal program verification
- Approach: Define axioms or inference rules for each statement type in
the language (to allow transformations of expressions to other
expressions)
- The expressions are called assertions
- An assertion before a statement (a precondition) states the
relationships and constraints among variables that are true at that point in
execution
- An assertion following a statement is a

postcondition

- A weakest precondition is the least restrictive precondition that will


guarantee the postcondition
- Pre-post form: {P} statement {Q}
Example axiomatic semantics for
37

1. Assignment statement using axiomatic semantics


2. Sequence of statements
3. Selection statement
4. Looping statement

VIII. Denotational Semantics :


- Based on recursive function theory
- The most abstract semantics description method
- Originally developed by Scott and Strachey (1970)
The process of building a denotational spec for a language:
1. Define a mathematical object for each language entity
2. Define a function that maps instances of the language entities onto
instances of the corresponding mathematical objects
- The meaning of language constructs are defined

by only the values of

the program's variables


- The difference between denotational and operational semantics: In
operational semantics, the state changes are defined by coded
algorithms; in denotational semantics, they are defined by rigorous
mathematical functions
Example denotational semantics for
38

1.Expression
2.Assignment statement
3.loop statement

Evaluation of denotational semantics:


- Can be used to prove the correctness of programs
- Provides a rigorous way to think about programs
- Can be an aid to language design
- Has been used in compiler generation systems

UNIT II Data types

I Variables: A variable is an abstraction of a memory cell


Variables can be characterized as a sextuple of attributes:
Name
Address
Value
Type
Lifetime
Scope

39

1Names : A way to refer to variables, functions, user-defined types, labeled


statements,
Design issues for names:
Maximum length?
What characters are allowed?
Are names case sensitive?
C, C++, and Java names are case sensitive
this is not true of other languages
--Are special words reserved words or keywords?
2. Address - the memory address with which it is associated (l-value)
3.Type - allowed range of values of variables and the set of defined operations
4.Value - the contents of the location with which the variable is associated (rvalue)
5. Scope & lifetime: The lifetime of a variable is the time during which it is bound
to a particular memory cell .Scope of a variable is the region over which the
variable is visible. Can be
1.Static scoping
2.Dynamic scoping

II. Concept of binding :


A binding is an association, such as between an attribute and an entity. Binding
time is the time at which a binding takes place.
Possible binding times:
1. Language design time--e.g., bind operator symbols to operations
40

2. Language implementation time--e.g., bind fl. pt. type to a representation


3. Compile time--e.g., bind a variable to a type in C or Java
4. Load time--e.g., bind a FORTRAN 77 variable to a memory cell (or a C static
variable)
5. Runtime--e.g., bind a nonstatic local variable to a memory cell

A binding is static if it occurs before run time and remains unchanged throughout
program execution.A binding is dynamic if it occurs during execution or can
change during execution of the program.

III. Storage binding & lifetime of a variable:


1.Static--lifetime is same as that of the program
2.Stack-dynamic--lifetime is duration of subprogram
3.Explicit heap-dynamic -- Allocated and deallocated by explicit directives,
specified by the programmer, which take effect during execution
4.Implicit heap-dynamic--Allocation and deallocation caused by assignment
statements

IV.Data types : a unique type for every category of variables in the problem
space
Design Issues for all data types:
41

1. What is the syntax of references to variables?


2. What operations are defined and how are they specified?

1.Primitive Data Types (those not defined in terms of other data types)
Number
-Integer
-Floating point
-Decimal
Boolean
Character
Character string

2.User defined data types:


a) Ordinal Types : An ordinal type is one in which the range of
possible values can be easily associated with the set of positive
integers

b) Enumeration Types - one in which the user enumerates all of the


possible values, which are symbolic constants
c) Subrange Type - an ordered contiguous subsequence of an ordinal
type

42

3. Arrays : An array is an aggregate of homogeneous data elements in


which an individual element is identified by its position in the
aggregate,
Four Categories of Arrays (based on subscript binding and binding to
storage)
1. Static - range of subscripts and storage bindings are static
e.g. FORTRAN 77, some arrays in Ada
2. Fixed stack dynamic - range of subscripts is statically bound,
but storage is bound at elaboration time e.g. Pascal locals and, C
locals that are not static
3. Stack-dynamic - range and storage are dynamic, but fixed from
then on for the variables lifetime e.g. Ada
4. Heap-dynamic - subscript range and storage bindings are
dynamic and not fixed

4.Structures & Records : heterogeneous aggregate of data elements in which


the individual elements are identified by names

5.Unions : is a type whose variables are allowed to store different type values
at different times during execution
6. Sets : A set is a type whose variables can store unordered collections of distinct
values from some ordinal type

43

7. Pointers : A pointer type is a type in which the range of values consists of


memory addresses and a special value, nil (or null)

8. Reference Types: (C++,JAVA) Constant pointers that are implicitly


dereferenced .

Expressions and statements


Expressions are the fundamental means of specifying computations in a
programming language
To understand expression evaluation, need to be familiar with the orders of
operator and operand evaluation
Assignment statements play a dominant role in imperative languages.

I.

Arithmetic Expressions :

Arithmetic expressions consist of operators, operands, parentheses, and


function
Calls.
1.Design issues for arithmetic expressions:
operator precedence rules
operator associativity rules
order of operand evaluation
operand evaluation side effects
operator overloading
44

mixed mode expressions


2. Operators :

A unary operator has one operand

A binary operator has two operands

A ternary operator has three operands

3. Operator Precedence Rules :

The operator precedence rules for expression evaluation define the order

in which adjacent operators of different precedence levels are evaluated


Typical precedence levels are parentheses ;unary operators ; ** (if the
language supports it) ; *, / ; +, -

4. Operator Associativity Rule :


The operator associativity rules for expression evaluation define the order in
which adjacent operators with the same precedence level are evaluated
Typical associativity rules
--Left to right, except **, which is right to left
--Sometimes unary operators associate right to left (e.g., in FORTRAN)
--APL is different; all operators have equal precedence and all operators
associate right to left .It is the programmers responsibility to see that
the expression is written correctly
*Precedence and associativity rules can be overriden with parentheses

5. Conditional Expressions :
Conditional Expressions
45

C-based languages (e.g., C, C++)


Ex : average = (count == 0)? 0 : sum / count
Evaluates as if written like
if (count == 0) average = 0
else average = sum /count

6. Operand Evaluation Order :


Operand evaluation order
1. Variables: fetch the value from memory
2. Constants: sometimes a fetch from memory; sometimes the constant
is in the machine language instruction
3. Parenthesized expressions: evaluate all operands and operators first

7. Potentials for Side Effects :


*Functional side effects: when a function changes one of its parameters or a
global variable
*Eg., for a parameter change:
a = 10;
b = a + fun(a);
-- where fun is defined as fun returns value of its argument divided by 2 & changes
parameter to 20
--If first operand is evaluated first and then second operand then b becomes 15
--If second operand is evaluated first and then the first operand the b becomes 25.

Two possible solutions to Functional side effects


46

a) Write the language definition to disallow functional


side effects by implementing
* No two-way parameters in functions
* No global references in functions
b)Write the language definition to demand that operand evaluation order be fixed &
implementers guarantee this order

8. Overloaded Operators :
*Use of an operator for more than one purpose is called operator overloading
--Some are common (e.g., + for int and float)
--Some are potential trouble (e.g., * in C and C++)
*Loss of compiler error detection (omission of & in
x = &y will not be detected by compiler )
*Some loss of readability
*Can be avoided by introduction of new symbols (e.g., Pascals div for integer
division)
*C++ and Ada allow user-defined overloaded operators
Potential problems:
Users can define nonsense operations
Readability may suffer, even when the operators make sense

9 . Type Conversions :
A narrowing conversion is one that converts an object to a type that cannot
include all of the values of the original type e.g., float to int

47

A widening conversion is one in which an object is converted to a type that can


include at least approximations to all of the values of the original type
e.g., int to float

10 . Coersion :
A coercion is an implicit type conversion in mixed mode expression (expr that has
operands of different types)
Disadv:They decrease the type error detection ability of the compiler
In most languages, all numeric types are coerced in expressions, using widening
conversions
In Ada, there are virtually no coercions in expressions

11. Explicit Type Conversions :


Called casting in C-based language
Ex: C : (int) angle
Ada: Float (sum)

Type Conversions: Errors in Expressions:

Causes
--Inherent limitations of arithmetic e.g., division by zero
--Limitations of computer arithmetic e.g. overflow
And underflow
--ignored by the run-time system or caught as exceptions

48

II.

Relational and Boolean Expressions :

Relational Expressions
--Use relational operators and operands of various types
--Evaluate to some Boolean representation
--Operator symbols used vary somewhat among languages (!=, /=, .NE., <>, #)

Boolean Expressions
--Operands are Boolean and the result is Boolean
--Example operators

FORTRAN 90
and

Ada

&&

and

or

||

or

not

not

xor

III.

C has no Boolean type--it uses int type with 0 for false and nonzero for true

Short Circuit Evaluation :

An expression in which the result is determined without evaluating all of the operands
and/or operators

Example: (13*a) * (b/131)

If a is zero, there is no need to evaluate (b/13-1)


* C, C++, and Java: use short-circuit evaluation for the usual Boolean operators (&&
and ||)

49

Ada: programmer can specify either (short-circuit is specified with and then

and or else)
Ex: while(Index <= ListLen) and then (..) is short circuit

IV.Assignment Statements :

* The general syntax


<target_var> <assign_operator> <expression>
* The assignment operator
= FORTRAN, BASIC, PL/I, C, C++, Java
:= ALGOLs, Pascal, Ada

1. Compound Operators :

*A shorthand method of specifying a commonly needed form of assignment


*Introduced in ALGOL; adopted by C
*Ex:

a=a+b

is written as

a += b

2. Unary Assignment Operators :

Unary assignment operators in C-based languages combine increment and

decrement operations with assignment


sum = ++count (count incremented & assigned to sum)
sum = count++ (count assigned to sum & incremented)
count++ (count incremented)
50

-count++ (count incremented then negated)

3. Assignment as an Expression :

In C, C++, and Java, the assignment statement produces a result and can be used as

an operand

Ex:

while ((ch = getchar())!= EOF),-

ch = getchar() is carried out; the result (assigned to ch) is used as a


conditional value for the while statement

4. Mixed-Mode Assignment :

Assignment statements can also be mixed-mode, for example int a, b;


float c;
c = a / b;

In Pascal, integer variables can be assigned to real variables, but real

variables cannot be

assigned to integers

In Java, only widening assignment coercions are done

In Ada, there is no assignment coercion


V . Control Statements Provide means of

Selecting among alternative control flow paths

Repeated execution of collection of statements

Primary factor restricting No of control stmnts is readability

It is proven that all algorithms represented by flowcharts can be coded with


only two-way selection and pretest logical loops

Levels of Control Flow : are


51

Within expressions
Among program units
Among program statements

I . Selection Statements :
A selection statement provides the means of choosing between two or more
paths of execution
Two general categories:
Two-way selectors
Multiple-way selectors
a) Two-Way Selection Statements :
i) General form:
if control_expression
then clause
else clause
ii) Design Issues:
What is the form and type of the control expression?
How are the then and else clauses specified?
How should the meaning of nested selectors be specified?
iii) Nesting Selectors:
Java example
if (sum == 0)
if (count == 0)
result = 0;
52

else result = 1;
Java's static semantics rule states else matches with the nearest if
To force an alternative semantics, compound statements may be used:

if (sum == 0)
{
if (count == 0)
result = 0;
}
else result = 1;
The above solution is used in C, C++, and C#
Perl requires that all then and else clauses to be compound
b) Multiple-Way Selection Statements :
Allow the selection of one of any number of statements or statement groups
Design Issues:
1. What is the form and type of the control expression?
2. How are the selectable segments specified?
3. Is execution flow through the structure restricted to include just a single
selectable segment?
4.What is done about unrepresented expression values?
i) Early multiple selectors:
FORTRAN arithmetic IF (a three-way selector)
IF (arithmetic expression) N1, N2, N3
Segments require GOTOs
53

ii) Modern multiple selectors:


Cs switch statement
switch (expression)
{
case const_expr_1: stmt_1;

case const_expr_n: stmt_n;


[default: stmt_n+1]
}
Any number of segments can be executed in one execution of the construct
(there is no implicit branch at the end of selectable segments)
iii) The Ada case statement :
case expression is
when choice list => stmt_sequence;

when choice list => stmt_sequence;


when others => stmt_sequence;]
end case;
More reliable than Cs switch (once a stmt_sequence execution is completed,
control is passed to the first statement after the case statement
II. Iterative Statements :
The repeated execution of a statement or compound statement is accomplished
either by iteration or recursion
General design issues for iteration control statements:
54

1. How is iteration controlled?


2. Where is the control mechanism in the loop?
a) Counter-Controlled Loops :
A counting iterative statement has a loop variable, and a means of specifying the
initial and terminal , and stepsize values of loop var
Design Issues:
1. What are the type and scope of the loop variable?
2. What is the value of the loop variable at loop termination?
3. Should it be legal for the loop variable or loop parameters to be changed in
the loop body, and if so, does the change affect loop control?
4. Should the loop parameters be evaluated only once, or once for every
iteration?
Examples :
i) FORTRAN 90 :
DO label var = start, finish [, stepsize]
Stepsize can be any non zero value
Parameters can be expressions & can be +ve /-ve
Loop variable must be integer
Loop parameters are evaluated only once
Loop is controlled by iteration count & not the loop parameters
The parameters can be changed inside the loop

ii) Ada :
for var in [reverse] discrete_range loop

...

55

end loop
A discrete range is a sub-range of an integer or enumeration type
Scope of the loop variable is the range of the loop
Loop variable is implicitly undeclared after loop termination

iii) Cs for statement :


for ([expr_1] ; [expr_2] ; [expr_3]) statement
The expressions can be whole statements, or even statement sequences, with the
statements separated by commas
There is no explicit loop variable
The first expression is evaluated once, but the other two are evaluated with each
iteration

iv) C++ differs from C in two ways:


The control expression can also be Boolean
The initial expression can include variable definitions (scope is from the
definition to the end of the loop body)
v) Java and C# :
Differs from C++ in that the control expression must be Boolean

b) Logically-Controlled Loops :
Repetition control is based on a Boolean
Design issues:
Pre-test or post-test?
56

Should the logically controlled loop be a special case of the counting loop
statement expression rather than a counter
i) General forms:
while (ctrl_expr)

do

loop body

loop body
while (ctrl_expr)

ii) Examples :
Pascal has separate pre-test and post-test logical loop statements (while-do and
repeat-until)
C and C++ also have both, while-do and do- while
Java is like C, except the control expression must be Boolean
Ada has a pretest version, but no post-test
FORTRAN 77 and 90 have neither
Perl has two pre-test logical loops, while and until, but no post-test logical loop

c) User-Located Loop Control Mechanisms :


Sometimes it is convenient for the programmers to decide a location for loop
control (other than top or bottom of the loop)
Simple design for single loops (e.g., break)
Design issues for nested loops
1. Should the conditional be part of the exit?
2. Should control be transferable out of more than one loop?
57

i) Examples :
C , C++, and Java: break statement
Java and C# have a labeled break statement: control transfers to the label
An alternative: continue statement; it skips the remainder of this iteration, but
does not exit the loop

d) Iteration Based on Data Structures :


Number of elements of in a data structure control loop iteration
. UNIX awk programming

III . Unconditional Branching :


Transfers execution control to a specified place in the program
Well-known mechanism: goto statement
Major concern: Readability
Some languages do not support goto statement (e.g., Module-2 and Java)
IV. Guarded Commands :
Suggested by Dijkstra
Purpose: to support a new programming methodology that supported verification
(correctness) during development
Basis for concurrent programming in CSP &Ada
Basic Idea: if the order of evaluation is not important, the program should not
specify one

58

a) Selection Guarded Command :


i) Form :
if <Boolean exp> -> <statement>
[] <Boolean exp> -> <statement>
...
[] <Boolean exp> -> <statement>
fi
Semantics: when construct is reached,
Evaluate all Boolean expressions
If more than one are true, choose one non-deterministically/arbitrarily
If none are true, it is a runtime error

b) Loop Guarded Command :


i)Form :
do <Boolean> -> <statement>
[] <Boolean> -> <statement>
...
[] <Boolean> -> <statement>
od
Semantics: for each iteration
Evaluate all Boolean expressions
If more than one are true, choose one non-deterministically; then start loop
again
If none are true, exit loop

59

UNIT III Subprograms and blocks


I. Subprogram is a reusable collection of statements which increases readability of a
program by exposing its logical structrure while hiding small scale details

II. Fundamentals of Subprograms :


a) General subprog characteristics:
Each subprogram has a single entry point
The calling program is suspended during execution of the called subprogram
Control always returns to the caller when the called subprograms execution
terminates
b) Basic Definitions :
A subprogram definition describes the interface to and the actions of the
subprogram
A subprogram call is an explicit request that the subprogram be executed
A subprogram header is the first part of the definition, including the name,
the kind of subprogram, and the formal parameters
The parameter profile (signature) of a subprogram is the number, order, and
types of its parameters
The protocol is a subprograms parameter profile and, if it is a function, its
return type
c) Parameters :
A formal parameter is a dummy variable listed in the subprogram header and
used in the subprog

60

An actual parameter represents a value or address used in the subprogram


call statement
i) Positional parameters :
The binding of actual parameters to formal parameters is by position: the first
actual parameter is bound to the first formal parameter and so forth
ii) Keyword based parameters:
The name of the formal parameter to which an actual parameter is to be
bound is specified with the actual parameter
Parameters can appear in any order
iii) Formal Parameter Default Values :
In certain languages (e.g., C++, Ada,FORTRAN 95,PHP), formal parameters can
have default values .Eg: In Ada
function pay(incm:Float;Exmpn:Integer:=1;
tax_rt:Float) return Float;
is called using pay(20000.0,tax_rt=>0.15);
In C++, default parameters must appear last because parameters are
positionally associated
float pay(float incm,float tax_rt,int exm = 1)
is called using pay(20000.0,0.15);
d) Procedures and Functions :
There are two categories of subprograms
Procedures are collection of statements that define parameterized
computations
Functions structurally resemble procedures but are semantically modeled on
mathematical functions
61

III. Design Issues for Subprograms :


What parameter passing methods are provided?
Are actual & formal parameters type checked?
Are local variables statically or dynamically allocated?
Can subprogram definitions appear in other subprogram definitions?
Can subprograms be overloaded ie can there be two subprograms with the
same name in the same referencing environment?Ex:diff no of parameters
Can subprogram be generic ie which can be computed for data of diff types?

IV. Local Referencing Environments :


Subprograms can define their own var thus creating a local referencing
environment.
These var are called local vars.
Local variables can be static or stack-dynamic

V. Parameter Passing Methods :Ways in which parameters are transmitted to


and/or from called subprograms
1.Models of Parameter Passing :

62

a) Pass-by-value (In Mode) :


The value of the actual parameter is used to initialize the corresponding formal
parameter
Normally implemented by copying
Storage and copy operations can be costly
b) Pass-by-Result (Out Mode) :
When a parameter is passed by result, no value is transmitted to the
subprogram; the corresponding formal parameter acts as a local variable; its
value is transmitted to callers actual parameter when control is returned to
the caller
Require extra storage location and copy operation
c) Pass-by-Value-Result (inout Mode) :
A combination of pass-by-value and pass-by-result
Formal parameters have local storage
63

d) Pass-by-Reference (Inout Mode) :


Pass an access path ;no copying and no duplicated storage hence efficient
Dvg : Slower accesses to formal parameters
Potentials for un-wanted side effects
A subtle but fatal error can occur with pass-by-reference and pass-by-valueresult: a formal parameter corresponding to a constant can mistakenly be
changed

e) Pass-by-Name (Inout Mode) :


By textual substitution
Formals are bound to an access method at the time of the call, but actual
binding to a value or address takes place at the time of a reference or
assignment

Allows flexibility in late binding

2. Implementing ParameterPassing methods:

In most language parameter communication takes place thru the run-time


stack

Pass-by-reference are the simplest to implement; only an address is placed in


the stack

3.Para Passing Methods of Major Languages:


Fortran :Always used the inout semantics model
Fortran 77 and later: pass by value-result

64

C : Pass-by-value .Pass-by-reference is achieved by using pointers as


parameters
C++ :A special pointer type called reference type for pass-by-reference
Java :All parameters are passed are passed by value.Object parameters are
passed by reference
Ada :Three semantics modes of parameter transmission: in, out, in out; in is
the default mode
C# :Default method: pass-by-value.Pass-by-reference is specified by
preceding both a formal parameter and its actual parameter with ref
PHP: very similar to C#
Perl: all actual parameters are implicitly placed in a predefined array named
@_
4. Type Checking Parameters :
very important for reliability
Pascal, FORTRAN 90, Java, and Ada: it is always required
ANSI C and C++: choice is made by the user
Thr the use of prototypes.
Relatively new languages Perl, JavaScript, and PHP do not require type
checking
5. Multidimensional Arrays as Parameters :
If a multidimensional array is passed to a subprogram , the compiler needs to
know the declared size of that array to build the storage mapping function

C,C++ :Pass a pointer to the array and the sizes of the dimensions as other
parameters
65

Ex: void fun(float *mat_ptr,int rows,int col);


Pascal :size is part of the arrays type declaration
Ada :Constrained arrays - like Pascal
Unconstrained arrays - size is part of the object declaration

Java, C# : Similar to Ada .Arrays are objects; they are all single-

dimensioned, but the elements can be arrays


VI. Design Considerations for Parameter Passing :
--Two important considerations which are in are in conflict are efficiency & One way
or two way data transfer.
--Good programming suggest limited access to variables, which means one-way
whenever possible
--But pass-by-reference is more efficient to pass structures of significant size like
arrays
VII. Parameters that are Subprogram Names :
1.It is sometimes convenient to pass subprogram names as parameters
Ex:A subprog that does numerical integration & estimates area under the
graph of a fn by sampling the fn at a no of diff pts.
Such a prog should be usable for any fn
Design issues are :Are parameters type checked?
What is the correct referencing environment for a subprogram that was sent
as a parameter?
2. Referencing Environment :
Shallow binding: The environment of the call statement that enacts the
passed subprogram
Deep binding: The environment of the definition of the passed subprogram
66

Ad hoc binding: The environment of the call statement that passed the
subprogram
Ex : consider prog in JavaScript
Function sub1() {
Var x;
Function sub2() {
Alert(x);
};
Function sub3()

Var x;
X = 3;
Sub4(sub2);
};
Function sub4(subx) {
Var x;
X= 4;
Subx();
}
X = 1;
Sub3();
};
-- consider execution of sub2 when it is called in sub4
--for shallow binding the ref env for this is that of sub4 so x evaluates to 4.Not
appropriate for
Static scoped lang.Implmntd in some dyn scoped lang
67

--for deep binding ref env is that of sub1 so x evaluates to 1.


--For adhoc binding ref env is that of sub3 & x evaluates to 3.Never been used in any
prog lang
C and C++: functions cannot be passed as parameters but pointers to
functions can be passed; parameters can be type checked
FORTRAN 95 type checks
Later versions of Pascal and
Ada does not allow subprogram parameters; a similar alternative is provided
via Adas generic facility
VIII . Overloaded operators & Subprograms :
--operator overloading is assigning special meaning to an existing
operator.Allowed in Ada & C++
--An overloaded subprogram is one that has the same name as another
subprogram in the same referencing environment
--Every version of an overloaded subprogram has a unique protocol
--In Ada, the return type of an overloaded function can be used to
distinguish calls ie two overloaded functions can have the same parameters
diff return types.
--Ada, Java, C++, and C# allow users to write multiple versions of
subprograms with the same name
IX. Generic Subprograms :
--A generic or polymorphic subprogram takes parameters of different types
on different activations
--Overloaded subprograms provide ad hoc polymorphism

68

--A subprogram that takes a generic parameter which can be used to describe
the type of the parameters of the subprogram provide parametric
polymorphism.
--Ex : template <class Type>
Type max(Type first, Type second)
{ return first > second ? first : second; }
The above template can be instantiated for any type for which operator > is
defined
int max (int first, int second)
{

return first > second? first : second; }

X. Design Issues for Functions :


1.Are side effects allowed? If no then parameters should always be in-mode
to reduce side effect (Ex: Ada)
2.What types of return values are allowed?
---C allows any type except arrays and functions
---C++ is like C but also allows user-defined types (objs)
---Ada allows any type
---Java and C# do not have functions but methods can have any type
XI. Coroutines :
--A coroutine is a subprogram that has multiple entries and controls these
entries by itself
-- A coroutine call is named a resume
--The first resume of a coroutine is to its beginning, but subsequent calls
enter at the point just after the last executed statement in the coroutine
69

--Coroutines repeatedly resume each other, possibly forever


--Coroutines provide quasi-concurrent execution of program units (the
coroutines); their execution is interleaved, but not overlapped

70

UNIT IV ABSTACT DATA TYPES & ENCAPSULATION

I .The Concept of Abstraction :


An abstraction is a representation of an entity that includes only the most significant
attributes
The concept of abstraction is fundamental in programming
Nearly all programming languages support process abstraction with subprograms
Nearly all programming languages designed since 1980 support data abstraction
Introduction to Data Abstraction :
--An abstract data type is a user-defined data type

that satisfies the following two

conditions:

The representation of, and operations on, objects of the type are defined in a single

syntactic unit
--The adv is easier program organization and , modifiability as everything associated with a
data structure is together and also separate compilation
of the same

The representation of objects of the type is hidden from the program units that use

these objects.
--Adv is reliability .By hiding the data representations, user code cannot directly access
objects of the type
Design Issues for abstract data types :
--A syntactic unit to define an ADT
--Built-in operations such as Assignment,Comparison
should be included
71

--Common operations such as Iterators,Accessors,


Constructors,Destructors should be included
-- Parameterized ADTs should be possible
Language Examples:
1.Ada :The encapsulation construct is called packages
--Consists of Specification package which provides the interface of the encapsulation and
--Body package which provides implementation of the entities named in the specification
--Specification package consists of two sections
a) private : Not visible to client programs
b) public : visible to client programs
c) limited private : Have no built in operations.useful
when the usual predefined operations like
assignment & comparison are not meaningful.Eg
assgn & comp not used for stacks.
An Example in Ada : Specification package is follows
package Stack_Pack is
type stack_type is limited private; /* Visible part */
max_size: constant := 100;
function empty(stk: in stack_type) return Boolean;
procedure push(stk: in out stack_type; elem:in Integer);
procedure pop(stk: in out stack_type);
function top(stk: in stack_type) return Integer;
type list_type is array (1..max_size) of Integer;/*prvt*
type stack_type is record
list: list_type; /* list of list_type*/
72

topsub: Integer range 0..max_size) := 0;


end record;
end Stack_Pack
--Body package gives definition of function empty,top
procedure push , pop.
2. C++ :
--The class is the encapsulation device
--All instances of a class share a single copy of the member functions
--Each instance of a class has its own copy of the class data members
--Instances can be static, stack dynamic, or heap dynamic
--Entities in the class can be Private for hidden entities
Public for interface entities Protected clause for inheritance
--Constructors are functions to initialize the data members of instances
*Can include parameters to provide parameterization
of the objects
* Implicitly called when an instance is created
* Can be explicitly called
* Name is the same as the class name
--Destructors are functions to cleanup after an instance
is destroyed; usually just to reclaim heap storage
* Implicitly called when the objects lifetime ends
* Can be explicitly called
* Name is the class name, preceded by a tilde (~)
-- Friend functions or classes provide access to private members to some unrelated units or
functions
73

An Example in C++ :
class stack {
private:
int *stackPtr, maxLen, topPtr;
public:
stack() {

// a constructor
stackPtr = new int [100];
maxLen = 99;
topPtr = -1;

};
~stack () {delete [] stackPtr;}; //destructor
void push (int num) ,-;
void pop () ,-;
int top () ,-;
int empty () ,-;

3. Java : Similar to C++, except:


--All user-defined types are classes
--All objects are allocated from the heap and accessed through reference variables
--Individual entities in classes have access control modifiers private or public
--Java has a second scoping mechanism, package scope, which can be used in place of
friends
--All entities in all classes in a package that do not have access control modifiers are visible
throughout the package
An Example in Java :
class StackClass {
74

private:
private int [] *stackRef;
private int [] maxLen, topIndex;
public StackClass() { // a constructor
stackRef = new int [100];
maxLen = 99;
topPtr = -1;
};
public void push (int num) ,-;
public void pop () ,-;
public int top () ,-;
public boolean empty () ,-;
}
4. C# :
--Based on C++ and Java
--Adds two access modifiers, internal and protected internal
--All class instances are heap dynamic
--Default constructors are available for all classes
--Garbage collection is used for most heap objects, so destructors are rarely used
--Includes structs which are lightweight classes that do not support inheritance
--Common accessor methods are getter and setter
--C# provides properties as a way of implementing getters and setters without requiring
explicit method calls
C# Property Example :
public class Weather {
75

public int DegreeDays { //** DegreeDays is a property


get {return degreeDays;}
set {degreeDays = value;}
}
private int degreeDays;
...

...
Weather w = new Weather();
int degreeDaysToday, oldDegreeDays;
...
w.DegreeDays = degreeDaysToday;
...
oldDegreeDays = w.DegreeDays;
II. Parameterized Abstract Data Types :
Parameterized ADTs allow designing an ADT that can store any type elements
Also known as generic classes
C++ and Ada provide support for parameterized ADTs
Java 5.0 provides a restricted form of parameterized ADTs
C# does not currently support parameterized classes
Parameterized ADTs in C++ :
Classes can be somewhat generic by writing parameterized constructor functions
III. Encapsulation Constructs :
*Large programs have two special needs:
--Some means of organization, other than simply division into subprograms

76

--Some means of partial compilation ie compilation units that are smaller than the whole
program
--A grouping of subprograms that are logically related, into a unit that can be separately
compiled is the Obvious solution.
--Such collections are called encapsulation
1.Encapulation in Ada & Fortran95:
Nested Subprograms : Organizing programs by nesting subprogram definitions inside
larger subprograms that use them
2. Encapsulation in C :
Files containing one or more subprograms can be independently compiled
The interface is placed in a header file
Included thr #include preprocessor specification
3. Encapsulation in C++ :
Similar to C
Addition of friend functions that have access to private members of the friend class
4. Ada Packages :
Ada specification packages can include any number of data and subprogram
declarations
Ada packages can be compiled separately
A packages specification and body parts can be compiled separately
5. C# Assemblies :
A collection of files that appear to be a single dynamic link library or executable
A DLL is a collection of classes and methods that are individually linked to an
executing program
77

Naming Encapsulations :
Large programs define many global names;Hence need a way to divide into logical
groupings
A naming encapsulation is used to create a new scope for names
1. C++ Namespaces :
--Can place each library in its own namespace and qualify names used outside with the
namespace
--C# also includes namespaces
--Java Packages;clients of a package can use fully qualified name or use the import
declaration
--Ada Packages are defined in hierarchies which correspond to file hierarchies;Visibility
from a program unit is gained with the with clause
IV. Fundamentals of OOP :
Abstract data types
Inheritance
Polymorphism & Dynamic binding
Terminology of obj orientation :
--ADTs are called classes
--Class instances are called objects
--A class that inherits is a derived class or a subclass
--The class from which another class inherits is a parent class or superclass
--Subprograms that define operations on objects are called methods
--Calls to methods are called messages
--The entire collection of methods of an object is called its message protocol or
message interface
78

--Messages have two parts a method name and the destination object
--A class can modify an inherited method.The new one overrides the inherited one.The
method in the parent is overridden.
--There are two kinds of variables in a class:
Class variables - one/class
Instance variables - one/object
--There are two kinds of methods in a class:
Class methods accept messages to the class
Instance methods accept messages to objects
Lang Ex:
Out of the many object-oriented programming languages
--Some support procedural and data-oriented programming e.g., Ada and C++
--Some support functional program e.g., CLOS
--Newer languages do not support other paradigms but use their imperative structures
e.g., Java and C#
--Some are pure OOP language e.g., Smalltalk
V. Design Issues for OOP Languages :
1. The Exclusivity of Objects : Everything is an object , Add objects to a complete
typing system
2. Subclasses as Types : A derived class is a subtype if it has an is-a

relationship

with its parent class


3. Type Checking and Polymorphism : Polymorphism may require dynamic type
checking of parameters and the return value
4. Single and Multiple Inheritance :Multiple inheritance Language and
implementation complexity
79

5. Object Allocation and De-Allocation : From where are objects allocated?


Heap/stack .Is deallocation explicit or implicit?
6. Dynamic and Static Binding :Allow the user to specify
7.Nested Classes :If a new class is needed by only one class, there is no reason to
define so it can be seen by other classes.Can the new class be nested inside the
class that uses it?
VI. Support for OOP in Smalltalk : pure OOP lang
a) Abstaction :
--Everything is an object
--All computation is through objects sending messages to objects
--All objected are allocated from the heap
--All deallocation is implicit thr garbage collctn
b) Inheritance :
--A Smalltalk subclass inherits all of the instance variables, instance methods, and
class methods of its superclass
--All subclasses are subtypes(nothing is hidden)
--No multiple inheritance
c) Dynamic Binding :
--All binding of messages to methods is dynamic
--only type error occurs when a message is sent to an object that has no matching
method
d) Evaluation :
--The syntax of the language is simple and regular
--Slow compared with conventionalimperative langs
--Dynamic binding allows type errors to go undetected until run time
80

--Greatest impact: advancement of OOP


Support for OOP in C++ :
a) Abstaction :
--Mixed typing system
b) Inheritance :
--A class need not be the subclass of any class as a derived class can be declared
public / private
class base_class {
private:
int a;
float x;
protected:
int b;
float y;
public:
int c;
float z;
};
class subclass_1 : public base_class , -;
// In this b & y are protected & c and z are public
class subclass_2 : private base_class , -;
// In this b, y, c & z are private & no derived class has // access to any member of
base_class
Reexportation in C++ :

81

--A member that is not accessible in a subclass can be declared to be visible there
using the scope resolution operator (::), e.g.,
class subclass_3 : private base_class {
base_class :: c;

c) Dynamic Binding :
--A method can be defined to be virtual, which means that they can be
dynamically bound to messages
--A pure virtual function has no definition at all
--A class that has at least one pure virtual function is an abstract class
d) Evaluation :
--C++ provides extensive access controls (unlike Smalltalk)
--C++ provides multiple inheritance
--In C++, the programmer can decide at design time which methods will be
statically bound and which dynamically bound
--Smalltalk type checking is dynamic
--Because of interpretation and dynamic binding, Smalltalk is ~10 times slower
than C++
III. Support for OOP in Java :
a) Gen Characteristics:
--All data are objects except the primitive types
--Primitive types can have wrapper classes that store one data value
--All objects are heap dynamic, referenced through reference variables, and most
are allocated with new

82

--A finalize method is implicitly called when the garbage collector is about to
reclaim the storage occupied by the object
b) Inheritance :
--Single inheritance only is supported ,but there is an abstract class category /
interface that provides some of the benefits of multiple inheritance
--An interface can include only method declarations and named constants, e.g.,
public interface

Comparable {public int comparedTo (Object b);

--Methods can be final (cannot be overriden)


c) Evaluation :
--No support for procedural programming
--No parentless classes
--Dynamic binding is used as normal way to bind method calls to method
definitions
--Uses interfaces to provide a simple form of support for multiple inheritance
IV . Support for OOP in C# :
a) General characteristics :
--Support for OOP similar to Java.
--Includes both classes and structs
--Classes are similar to Javas classes
--structs are less powerful stack-dynamic constructs
b) Inheritance :
--Uses the syntax of C++ for defining classes
--A method inherited from parent class can be replaced in the derived class by
marking its definition with new Eg : new.Draw()

83

--The parent class version can still be called explicitly with the prefix base: Eg :
base.Draw()
c) Dynamic binding :
--All C# classes are ultimately derived from a single root class, Object
--To allow dynamic binding of method calls to methods:
The base class method is marked virtual
The corresponding methods in derived classes are marked override
Abstract methods are marked abstract and must be implemented in all
subclasses
d) Evaluation :
--C# is the most recently designed C-based OO language
--The differences between C#s and Javas support for OOP are relatively minor
V. Ada 95 :
a) General Characteristics :
--OOP was one of the most imp extensions to Ada 83
--Encapsulation container is a package that defines a tagged type which can be
record or private type.
--A tagged type includes a sys maintained tag to indicate its type during execution
--No constructors or destructors are implicitly called
b) Inheritance :
--Subclasses can be derived from tagged types
--New entities are added to the inherited entities by placing them in a record
definition
--All subclasses are subtypes

84

--No support for multiple inheritance.A comparable effect can be achieved using
generic classes
c) Dynamic Binding :
--Provides both static & dyn binding of procedure calls to procedure definitions in
tagged types
d) Evaluation :
--Ada offers complete support for OOP
--C++ offers better form of inheritance than Ada
--Ada includes no initialization of objects thr constructors
--Dynamic binding in C-based OOP languages is restricted to pointers and/or
references to objects; Ada has no such restriction and is thus more orthogonal
I. Concurrency can occur at four levels:
Machine instruction level
High-level language statement level
Unit level /Subprogram level
Program level
--Because there are no language issues in instrctn & program level concrncy, they
are not addressed here
II. Concurrency can be :
--Physical concurrency implemented thr multiple independent processors (
multiple threads of control)
--Logical concurrency which presents the effect of physical concurrency
implemented thr time-sharing one processor ( PL can be designed as if there were
multiple threads of control)
III. H/W support for cncrcy thr Multiprsr archs :
85

--Late 1950s : one gen purpose procr and one or more special purpose procrs for
input & output operations.
--Early 1960s : multiple complete processors, used for program level concurrency
--Mid 1960s : multiple partial processors, used for instruction level
concurrency.Eg : some m/cs have two or more floating pt arithmetic units. PL
compilers
determine which instrctns can be executed concrntly & schedule these
instructions accordingly.
--Single Instruction Multiple Data (SIMD) m/cs
multiple procrs execute same instr on diff data sets
--Multiple Instruction Multiple Data (MIMD) m/cs
Multiple procrs execute diff instructions.
IV. Language support for cncrcy :
-- Thr Semaphores, monitors & message passing
--Implemented in PL/I , Ada95 , Java , C#
V. Why Study Concurrency :
--Provides a diff way of conceptualising s/w that can be very useful & simulate the
real world better as many real-world situations involve cncrcy.Ex:various m/cs
working simultaniously in a factory
--Since multiprocessor computers capable of physical concurrency are now widely
available why not make use of them by implementing concurrency.
VI. Basic Terminology :
a) Task or process is a program unit that can be in concurrent execution with
other program units
--Tasks differ from ordinary subprograms in that:
86

*A task may be implicitly started


*When a program unit starts the execution of a task, it is not necessarily wait for
completion of the task
*When a tasks execution is completed, control may not return to the caller
b) Heavyweight tasks execute in their own address space and have their own runtime stacks
c) Lightweight tasks all run in the same address space and use the same run-time
stack
d) Synchronisation is a mechanism that controls the order in which tasks execute.
i) Cooperation Sync: Task A must wait for task B to complete some specific
activity before task A can continue its execution, e.g.,prod-cons problem
ii) Competition Sync: Two or more tasks must use some resource that cannot
be simultaneously used, e.g., a shared counter
f) Task execution control is maintained by a program called the scheduler, which
maps task execution onto available processors
g) Task Execution States can be :
New - created but not yet started
Runnable or ready - ready to run but not currently running (no available
processor)
Running
Blocked - has been running, but now cannot continue (usually waiting for
some event to occur)
Dead - no longer active in any sense
g) Liveness means the prog unit will eventually complete its execution.If all tasks
in a concurrent environment lose their liveness, it is called deadlock
87

VII. Semaphores : Dijkstra 1965


--Smphrs are used to provide both comp,coop sync.
-- A semaphore is a data structure consisting of a counter and a queue for storing
task descriptors which stores all relevant info about the exec state of a task.
-- Semaphores have only two operations, wait and release (originally called P and
V by Dijkstra)
a) Coop Synchronization with Semaphores :
--Example: A shared buffer
--The buffer is implemented as an ADT with the ops deposit & fetch as the only
subprogs to access the buff
--Use two semaphores for cooperation: emptyspots and fullspots
--The semaphore counters are used to store the nos of empty spots and full spots
in the buffer
-- deposit must first check emptyspots to see if there is room in the buffer
If there is room, the counter of emptyspots is decremented and value is
inserted in buffer
If there is no room, the caller is stored in the queue of emptyspots
When deposit is finished, it must increment the counter of fullspots
-- fetch must check fullspots to see if there is a value
* If there is a full spot, the counter of fullspots is decremented and value is
removed
* If there are no values in the buffer, the caller must be placed in the queue
of fullspots
*When fetch is finished, it increments the counter of emptyspots

88

-- The operations of fetch and deposit on the semaphores are accomplished


through two semaphore operations named wait and release
-- Ex : Prog of producer consumer :
semaphore fullspots, emptyspots;
fullstops.count = 0;emptyspots.count = BUFLEN;
task producer;
loop
wait (emptyspots);

{wait for space}

deposit(VALUE);
release(fullspots);

{increase filled}

end loop;
end producer;
task consumer;
loop
wait (fullspots);

{wait till not empty}

fetch(VALUE);
release(emptyspots);

{increase empty}

end loop;
end consumer;
b) Comp Sync with semaphores :
--A third semaphore access is used to control access
--The counter of access will only have values 0 & 1
hence called a binary semaphore--Ex :
semaphore access, fullspots, emptyspots;
access.count = 0;fullstops.count = 0;
89

emptyspots.count = BUFLEN;
task producer;
loop
wait(emptyspots);
wait(access);

{wait for space}


{wait for access)

deposit(VALUE);
release(access);

{relinquish access}

release(fullspots);

{increase filled}

end loop;
end producer;
task consumer;
loop
wait(fullspots);
wait(access);

{wait till not empty}


{wait for access}

fetch(VALUE);
release(access);
release(emptyspots);

{relinquish access}
{increase empty}

end loop;
end consumer;
c) Evaluation of Semaphores :
--Misuse of smphs can cause failures in coop sync, e.g., buffer will overflow if the
wait of fullspots is left out
--Misuse of smphs can cause failures in comp sync, e.g., the prog will deadlock if the
release of access is left out
VIII. Monitors :
90

a) A monitor is an ADT for shared data where shared data and its operations are
encapsulated (rather than being in the client units) to restrict access
--All access is resident in the monitor
*Monitor implmntn guarantee synchronized access by allowing only one access at
a time
*Calls to monitor procedures are implicitly queued if the monitor is busy at the
time of the call
-- Concurrent Pascal, Modula, Mesa, Ada, Java, C#
b) Evaluation of Monitors :
--A better way to provide comp sync than are smphs
--Smphrs can be used to implmnt mntrs & vice versa
--Support for coop sync is very similar as with smphs, so it has the same problems
IX. Message Passing : Ada
a) Central idea: task communication is like seeing a doctor most of the time she waits
for you or you wait for her, but when you are both ready, you get together, or
rendezvous/sync message passing.
-- rendezvous is a mechanism to allow a task to indicate when it is willing to accept
messages
--When a sender tasks message is accepted by a rceiver task, the actual message
trnsmsn is called a rendezvous
--This is the Ada 83 Message-Passing Model

91

--Ada 95 includes Ada 83 features for conc, plus two new features protected objts
& Asynchronous cmnctn
b) Evaluation of the Ada message passing :
--Message passing model of conc is powerful and general.Both mon & semphs can
be implemented with message passing.
-- In the absence of distributed processors, the choice between monitors and
tasks with message passing is only a matter of taste
--For distributed systems, message passing is a better model for concurren
92

I. Exception Handling:

--An exception is any unusual event, either erroneous or not, detectable by either
hardware or software, that may require special processing
--The special processing that may be required after detection of an exception is
called exception handling
--The exception handling code unit is called an exception handler
--In a lang without exception handling when an exception occurs, control goes to
the OS, where a message is displayed and the program is terminated
--In a lang with exception handling programs are allowed to trap some exceptions,
thereby providing the possibility of fixing the problem and continuing

II. Advantages of Built-in Exception Handling :


--Error detection code is tedious to write and it clutters the program
--Exception propagation ie excp raised in one prog unit is handled in some other
prog unit allows a single excp handler to be used for any no of diff prog units
--Lang that supports excp handling encourages programmers to think of all
unusual events & account for how to handle them.

III. Design Issues :


--How & where are excp handlers specified & what is their scope?
--How is an excp occurrence bound to an excp handler? ( local / propagated )
--Where does execution continue, if at all, after an exception handler completes
its execution?

93

--How are user-defined exceptions specified?


--Should there be default excp handlers for progs?
--Can built-in exceptions be explicitly raised?
--How can exceptions be disabled, if at all?

IV. Exception Handling in Ada :


1. An excp handler in Ada can occur in either a subprogram body, a package body,
a task, or a block
2. Syntax of excp handler is
when excp_choice{|excp_choice} => stmt_seq
--excp_choice is :

exception_name | others

--Excp handlers are placed at the end of the block or unit in which they occur
3. Binding Exceptions to Handlers :
--If the block or unit in which an excp is raised does not have a handler for that
excp, the excp is propagated elsewhere to be handled
--Procedures : propagate it to the caller
94

--Blocks :propagate it to the enclosing block


--Package body : propagate it to the declaration part of the package
--library unit : program is terminated
--Task : no propagation; if it has a handler, execute it; in either case, mark it
"completed"
4. Continuation :
--The block or unit that raises an exception but does not handle it is always
terminated
--also any block or unit to which it is propagated but could not handle it is
terminated
5. Predefined Exceptions :
--CONSTRAINT_ERROR-index cnstrnts, range cnstrnts, etc.
--NUMERIC_ERROR - numeric op cannot return a correct value (overflow, division
by zero, etc.)
--PROGRAM_ERROR - call to a subprogram whose body has not been elaborated
--STORAGE_ERROR - system runs out of heap
--TASKING_ERROR - an error associated with tasks
6. User-defined Exceptions form :
exception_name_list : exception;
raise [exception_name] ;
pragma SUPPRESS(exception_list) disables excp

V. Basic terminology :

95

a) Logic programming language are Declarative rather than procedural ie only


specification of results are stated & not detailed procedures for producing them.
Ex : Prolog
b) The particular form of symbolic logic used for logic programming is called
predicate calculus
c) A logical statement that may or may not be true is called a proposition &
consists of objects and relationships of objects to each other
d) Objects in propositions are represented by either consts (a symbol that
represents an obj) or vars (a symbol that can represent different objects at
different times )
e) Simplest proposition is the Atomic propositions, consists of compound terms
which is written like a mathematical function
f) Compound term is composed of two parts
i) Functor: function symbol that names the relationship
ii) Ordered list of parameters (tuple)
Examples: student(jon) , like(seth, OSX)
g) Propositions can be stated in two forms:
Fact: proposition is assumed to be true
Query: truth of proposition is to be determined

96

Logical Operators
Name

Symbol

Example

Meaning

negation

not a

conjunction

ab

a and b

Name

Example

Meaning

a or b

universal

X.P

For all X, P is true

existential

X.P

There exists a value of X


such that P is true

disjunction

ab

equivalence

ab

a is equivalent
to b

implication

ab
ab

a implies b
b implies a

Copyright 2007 Addison-Wesley. All rights reserved.

Quantifiers

1-10

Copyright 2007 Addison-Wesley. All rights reserved.

1-11

VI. Prolog :
-- University of Aix-Marseille Natural language processing
-- University of Edinburgh Automated theorem proving Terminology - Edinburgh
Syntax
a) Term: a constant, variable, or structure
i) Constant: an atom or an integer
Atom: symbolic value of Prolog which can be either a string of letters,
digits, and underscores beginning with a lowercase letter OR a string of
printable ASCII characters delimited by apostrophes
Variable: any string of letters, digits, and underscores beginning with an
uppercase letter .Instantiation is the binding of a var to a value & lasts
only as long as it takes to satisfy one complete goal
Structure: represents atomic proposition ie functor(parameter list)
b) Fact Statements :
i) Correspond to Headless Horn clauses ex: female(shelley).
ii) Rule Statements :

97

Corr to Headed Horn clause where right side is antecedent ie if part (may be
single term or conjunction ie multiple terms separated by logical AND op) & left
side is consequent ie then part (must be single term)
Ex : ancestor(mary,shelley) :- mother(mary,shelley).
sibling(X,Y):- mother(M,X), mother(M,Y),father(F,X),
father(F,Y).
iii) Goal Statements :
A proposition that we want system to prove or disprove
Same format as headless Horn ex: man(fred)
iv) Inferencing Process of Prolog / resolution:
To prove a goal is true, must find a chain of inference rules and/or facts. For goal
Q: B :- A ; C :- B ; ; Q :- P
v) Prolog supports int vars & int arithmetic using is op which takes an arithmetic
expression as right operand and variable as left operand ex :

A is B / 17 + C

vi) List Structures :


--List is a sequence of any number of elements.
--Elements can be atoms, atomic propositions, or lists
--[apple, prune, grape, kumquat] ;[]

(empty list)

VII. Applications of Logic Programming :


Relational database management systems
Expert systems
Natural language processing

98

UNIT V Functional programming languages

I. Introduction :
1.The design of the functional langs is based on mathematical functions that is closer
to the user, but relatively unconcerned with the architecture of the m/cs on which
programs will run
2. A mathematical function is a mapping of members of one set, called the domain
set, to another set, called the range set
--A lambda expression specifies the parameter(s) and the mapping of a function in
the following form
--Lambda expressions describe nameless functions,prmeter(s) are placed after the
expression
e.g., ((x) x * x * x)(2) which evaluates to 8

II. Fundamentals of Functional PLs :


--The objective of the design of a FPL is to mimic mathematical functions to the
greatest extent possible
--In an FPL, var are not necessary, as is the case in mthmtcs
--In an FPL, the evaluation of a function always produces the same result given the
same parameters .

III. LISP Data Types and Structures :


Data object types: originally only atoms and lists
--Atoms are symbols or numeric literals
--List parenthesized collections of sublists and/or atoms
99

e.g., (A B (C D) E) stored internally as single-linked lists

IV. Dialects of LISP :


1. SCHEME :
--The values of the parameters are substituted into the fn body & the function body
is evaluated
--The value of the last exprsn in the body is the value of the fn
-- Ex fns in scheme Arithmetic: +, -, *, /, ABS, SQRT, REMAINDER, MIN, MAX

e.g.,

(+ 5 2) yields 7
--QUOTE - takes one parameter; returns the parameter without evaluation .Reqd
because the Scheme interpreter, EVAL, always evaluates parameters to fn
applications before applying the fn.QUOTE avoids para evltn when not ncssry
--DEFINE binds a symbol to an expression
(DEFINE pi 3.141593)

Ex: (DEFINE two_pi (* 2 pi))

e.g., (DEFINE (square x) (* x x)) ex: (square 5)

2. COMMON LISP :
--A combination of many of the features of the popular dialects of LISP around in the
early 1980s
--A large and complex language--the opposite of Scheme
--Features include: records ,arrays ,complex numbers,
character strings,powerful I/O capabilities,packages with access control,iterative
control statements

100

3. ML :
--A static-scoped functional language with syntax that is closer to Pascal than to LISP
--It is strongly typed (whereas Scheme is essentially typeless) and has no type
coercions
--Uses type declarations, but also does type inferencing to determine the types of
undeclared variables
--Includes exception handling and a module facility for implementing abstract data
types
--Includes lists and list operations
--ML specifics
The val statement binds a name to a value (similar to DEFINE in Scheme)
Function declaration form:fun name (parameters) = body;
e.g., fun cube (x : int) = x * x * x;

4. HASKELL :
--Similar to ML (syntax, static scoped, strongly typed, type inferencing)
--Diff from ML (and most other FL) in that it is purely fnctinl (e.g., no var, no
assgnmnt stmnts, no side effects of any kind)
--Uses lazy evaluation (evaluate no subexpression until the value is needed)
--Has list comprehensions, which allow it to deal with infinite lists using set notation
ex: [n * n | n *1..20++
V. Applications of Functional Languages :
--APL is used for throw-away programs
--LISP is used for AI,Knowledge rprsntn,m/c learning,Natural language
processing,Modeling of speech and vision
101

--Scheme is used to teach introductory programming at a significant number of


universities

VI. Comparing Functional and Imperative Languages :


ILs:Efficient execution,complex semantics&syntax,
Concurrency is programmer designed
FLs:Simple semantics&syntax,Inefficient execution
Programs can automatically be made concurrent

VI. Scripting Languages :


As a movie script tells actors what to do, a scripting language controls the
operation of a normally-interactive program, giving it a sequence of work to
do all in one batch. For instance, one could put a series of editing commands
in a file, and tell an editor to run that "script" as if those commands had been
typed interactively.
This usage was generalized under Unix to describe scripts for the shell to
execute, which meant that the running of a whole series of programs was
controlled, not just one. Thus the coinage "shell script". Came into being.
As programmable features of shells became more and more powerful (Ex :
Bourne ,C ) , they began to resemble traditional interpreted languages such
as Lisp or Basic which had never been previously called scripting language.
Because of this evolution, more recent usage has changed the current
definition , requiring "scripting languages" to have following properties in
general .

Source code is present at run time in production system (though it may


be compiled into Bytecode native object code, or some other format for
102

performance reasons). Application code is not delivered as object code


for the underlying processor (some stable system libraries may be precompiled in this way however).

Use of an interpreter or virtual machine is generally required; though


the OS may arrange for the appropriate interpreter to be invoked
automatically.

Explicit compilation or linking phases are not needed (implicit


compilation to bytecode or other low-level representations may be
performed as an optimization)

Variables, functions, and methods typically do not require type


declarations. There are automated conversions or equivalence between
types, particularly between strings and other types.

Very powerful built-in types - typically a dictionary, a set, a literal type


that can act as either numerics or strings. (It's a sad reflection on the
state of language design that dictionaries and sets can be considered
"very powerful".)

The ability to generate, load, and interpret source code at run time
through an eval function. (Perl, Python, Tcl, javascript, shell scripts,
REXX, APL; missing in VB [But present in VBScript])

Interface to the underlying operating system, in order to run other


programs and communicate with them. (Support for bare system calls is
essential for systems programming languages, but not for scripting
languages, which more often need higher-level abstractions that are
portable across operating systems).

103

Plays well with others. Can be easily integrated with larger systems.
Scripting languages are often used to "glue" more-rigid systems
together. True of REXX; probably not true of APL.
o

Rich I/O capabilities, including pipes, network sockets, file I/O, and
filesystem operations.

Language interpreter

can be embedded within another

application, allowing users to automate application operation, to


provide customized handling of application events, or to define
new application functions using the scripting language.
o

The ability to map external components to the semantics of the


built-in types and/or some component-based protocol

The preferred syntax of the language is used for things like


program invokation, I/O redirection, file/directory manipulation,
and job control/pipelining. More mundane things like arithmetic
may require more difficult syntax, or may be unsupported by the
language altogether (and require use of a separate application).

VII . Python :

Types and values in Python :


A). Basic types : Numbers and strings
The usual suspects
12, 3.14, 0xFF, 0377, (-1+2)*3/4**5, abs(x), 0<x<=5
C-style shifting & masking
1<<16, x&0xff, x|1, ~x, x^y
104

Integer division truncates :-(


1/2 -> 0

# 1./2. -> 0.5, float(1)/2 -> 0.5

Will be fixed in the future


Long (arbitrary precision), complex
2L**100 -> 1267650600228229401496703205376L
In Python 2.2 and beyond, 2**100 does the same thing
1j**2 -> (-1+0j)

"hello"+"world"

"helloworld"

"hello"*3

"hellohellohello" # repetition

"hello"[0]

"h"

# indexing

"hello"[-1]

"o"

# (from end)

"hello"[1:4]

"ell"

# slicing

len("hello")

# size

"hello" < "jello"

# comparison

"e" in "hello"

# concatenation

# search

"escapes: \n etc, \033 etc, \if etc"


'single quotes' """triple quotes""" r"raw strings"

B) . Container Types :
Lists : Flexible arrays, not Lisp-like linked lists
a = [99, "bottles of beer", ["on", "the", "wall"]]
Same operators as for strings
a+b, a*3, a[0], a[-1], a[1:], len(a)
105

Item and slice assignment


a[0] = 98
a[1:2] = ["bottles", "of", "beer"]
-> [98, "bottles", "of", "beer", ["on", "the", "wall"]]
del a[-1]

# -> [98, "bottles", "of", "beer"]

Dictionaries : Hash tables, "associative arrays"


d = {"duck": "eend", "water": "water"}
Lookup:
d["duck"] -> "eend"
d["back"] # raises KeyError exception
Delete, insert, overwrite:
del d["water"] # {"duck": "eend", "back": "rug"}
d["back"] = "rug" # {"duck": "eend", "back": "rug"}
d["duck"] = "duik" # {"duck": "duik", "back": "rug"}
Tuples : key = (lastname, firstname)
point = x, y, z

# parentheses optional

x, y, z = point # unpack
lastname = key[0]
singleton = (1,)

# trailing comma!!!

empty = ()

# parentheses!

tuples vs. lists; tuples immutable

2. Variables : No need to declare


Need to assign (initialize)
106

use of uninitialized variable raises exception


Not typed
if friendly: greeting = "hello world"
else: greeting = 12**2
print greeting
Everything is a "variable":
Even functions, classes, modules

3. Control structures :
if condition:
statements
[elif condition:
statements] ...
else:
statements

while condition:
statements
for var in sequence:
statements
break
continue

4. Functions and procedures :


def name(arg1, arg2, ...):
107

"""documentation""" # optional doc string


statements
return

# from procedure

return expression

# from function

Ex Function :
def gcd(a, b):
"greatest common divisor"
while a != 0:
a, b = b%a, a # parallel assignment
return b
>>> gcd.__doc__
'greatest common divisor'
>>> gcd(12, 20)
4
5. Classes :
class name:
"documentation"
statements
-orclass name(base1, base2, ...):
...
Most, statements are method definitions:
def name(self, arg1, arg2, ...):
...
May also be class variable assignments
108

Example Class :
class Stack:
def __init__(self):

# constructor

self.items = []
def push(self, x):
self.items.append(x)

# the sky is the limit

def pop(self):
x = self.items[-1]

# what happens if its empty?

del self.items[-1]
return x
def empty(self):
return len(self.items) == 0 # Boolean result

To create an instance, simply call the class object:


x = Stack()

# no 'new' operator!

To use methods of the instance, call using dot notation:


x.empty()

# -> 1

x.push(1)
x.empty()

# [1]
# -> 0

x.push("hello")
x.pop()

# [1, "hello"]
# -> "hello"

# [1]

To inspect instance variables, use dot notation:


x.items

# -> [1]

Subclassing :
109

class FancyStack(Stack):
"stack with added ability to inspect inferior stack items"
def peek(self, n):
"peek(0) returns top; peek(-1) returns item below that; etc."
size = len(self.items)
assert 0 <= n < size

# test precondition

return self.items[size-1-n]

6. Module library :
Collection of stuff in foo.py file
functions, classes, variables
Importing modules:
import re; print re.match("[a-z]+", s)
from re import match; print match("[a-z]+", s)
Import with rename:
import re as regex
from re import match as m
Before Python 2.0:
import re; regex = re; del re
Packages : Collection of modules in directory
Must have __init__.py file
May contain subpackages
Import syntax:
from P.Q.M import foo; print foo()
from P.Q import M; print M.foo()
110

import P.Q.M; print P.Q.M.foo()


import P.Q.M as M; print M.foo()

# new

7.Catching exceptions :
def foo(x):
return 1/x
def bar(x):
try:
print foo(x)
except ZeroDivisionError, message:
print "Cant divide by zero:", message
bar(0)
f = open(file)
try:
process_file(f)
finally:
f.close()
print "OK"

# always executed
# executed on success only

Raising exceptions :
raise IndexError
raise IndexError("k out of range")
raise IndexError, "k out of range"
try:
something
except:

catch

everything
111

print
raise

"Oops"
# reraise

8.Standard Library :
Core:
os, sys, string, getopt, StringIO, struct, pickle, ...
Regular expressions:
re module; Perl-5 style patterns and matching rules
Internet:
socket, rfc822, httplib, htmllib, ftplib, smtplib, ...
Miscellaneous:
pdb (debugger), profile+pstats
Tkinter (Tcl/Tk interface), audio, *dbm, ...

112

15 .JNTU Syllabus with additional topics :

Topic to be covered

Additional Topics

UNIT I
Introduction
Reasons for studying, concepts of
programming languages,
Programming domains
Language Evaluation Criteria
Influences on Language design
Language categories, Programming Paradigms
Imperative, Object Oriented, functional
Programming , Logic Programming.
Programming
Language Implementation Compilation and
Virtual Machines, programming
environments.
Evaluation of major
programming languages
Syntax and Semantics: general Problem of
describing Syntax and Semantics
Formal methods of describing syntax BNF
parse trees, ambiguous grammars
EBNF for common programming languages
features
Attribute grammars
Axiomatic semantics for common
programming language features

113

Denotational semantics for common

An Example for this

programming language features


Unit-II

Introduction , Primitive , character


User defined, array, associative, record,
union, pointer and reference types
Design and implementation uses related to
these types
Names, Variable, concept of binding, type
checking, strong typing
Type compatibility, named constants, variable

Comparing C,C++ and Java

initialization.
Arithmetic relational and Boolean
expressions, Unconditional Statements
Short circuit evaluation mixed mode
assignment
Assignment Statements
Control Structures Statement Level,
Compound Statements
Selection
Iteration
Unconditional Statements
Guarded commands.
Test
Unit-III

Fundamentals of sub-programs

114

Scope and lifetime of variable


Static and dynamic scope
Design issues of subprograms and operations
Parameter passing methods

How pointers work

Overloaded sub-programs, generic subprograms, parameters that are sub-program


names
Design issues for functions, co routines.
Test
Unit-IV
Abstractions and encapsulation, introductions
to data abstraction, design issues, language
examples
C++ parameterized ADT
Object oriented programming in small talk,
C++, Java, C#, Ada 95

Concurrency: Subprogram level concurrency


Java threads, C# threads
Semaphores, monitors, massage passing
Test
Exceptions
Exception Propagation
Exception handler in Ada, C++ and Java

History of Ada

Logic Programming Language Introduction


and overview of logic programming
Basic elements of prolog

115

Application of logic programming.


Test
Unit-V
Functional

Programming

Languages

Introduction, Comparison of functional and


imperative Languages.
Fundamentals of LISP

What is predicate calculus

116

16.University Question papers of previous years:


Code No: 09A50501
JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY, HYDERABAD
B. Tech III Year I Semester Examinations, November/December-2013
PRINCIPLES OF PROGRAMMING LANGUAGES
(Computer Science Engineering)
Time: 3 hours Max. Marks: 75
Answer any five questions
All questions carry equal marks
--1.a) Explain the areas of computer applications and their associated languages.
b) Draw and explain the layered interface of virtual computers provided by a typical computer
system. [15]
2.a) Explain the syntax graph and EBNF descriptions of the Ada if statement.
b)Explain the attribute grammer and also write the attribute grammer for simple assignment
statements. [15]
3.a) What is the general problem with static scoping.
b) Distinguish between explain and implicit heap dynamic variables.
c) Differentiate between Ada derived type and an Ada subtype. Give examples. [15]
4.a) How does C support relational and boolean expressions?
b) Explain the problems with unconditional branching.
c) Differentiate the for statement between the C, C++ and Java. [15]
5.a) Explain the generic functions in C++ with examples.
b) Explain the design issues of subprograms and operations. [15]
6.a) Explain the abstract data types in C++.
b) Explain about the concurrency in Ada 95. [15]
7.a) Explain how exceptions are handled in Ada.
b) What is the relationship between resolution and unification in prolog?
c) What are the applications of logic programming? [15]
8.a) Explain about the LISP, ML.
b) Compare the functional programming languages with imperative languages. [15]

B. Tech III Year I Semester Examinations, May/June - 2012


PRINCIPLES OF PROGRAMMING LANGUAGES
(COMPUTER SCIENCE AND ENGINEERING)
Time: 3 hours Max. Marks: 75
Answer any five questions
All questions carry equal marks
--1.a) Give some reasons why computer scientists and professional software developers should study
general concepts of language design and evaluation.
b) How can user-defined operator overloading harm the readability of a program? [7+8]
2.a) Give an example of left recursive rule in CFG. What is the significance of left recursive rule?
b) Give BNF grammar for real numbers and for the same give leftmost derivation of the string 2.89.
[7+8]
117

3.a) What are all of the differences between the enumeration types of C++ and those of java?
b) What is the purpose of the ACTION, GOTO table of an LR parser? Explain with example? [7+8]
4.a) How does C support relational and Boolean expressions?
b) What mixed-mode assignments are allowed in C and Java? Explain.
c) Explain with an example the for statement of the C-based languages. [15]
5.a) Distinguish between pass-by-value and pass-by reference with suitable examples.
b) What are the characteristics of co-routine feature? List the languages which allow co-routines.
[7+8]
6.a) What is the primary problem with using semaphores to provide synchronization?
b) Explain how information hiding in provided in an ADA package. [7+8]
7.a) Write detailed compassion of the Exception Handling capabilities of C++ and those of JAVA?
b) What is the difference between checked and unchecked exception in java?
c) How is user defined exception defined in ADA? [7+8]
8.a) Give comparison of Functional and Imperative Languages.
b) What are the three features of Haskell that makes very different from schema?
c) Compare structure programming and functional programming. [15]
Code No: 09A50501
JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY, HYDERABAD
B. Tech III Year I Semester Examinations, May/June 2013
(Computer Science and Engineering)
Time: 3 hours Max. Marks: 75
Answer any five questions
--All questions carry equal marks
Principles of Programming Languages

1. What is meant by programming paradigm? Explain various programming


paradigms with examples. [15]
2.a) Write BNF description for arithmetic expressions that implements the operator hierarchy of any
imperative language.
b) Discuss with an example operator precedence grammar. [15]
3.a) Briefly explain the specification and implementation aspects of following datatypes.
i) Boolean ii) Character
b) What do you mean by dangling reference? Explain with an example. [15]
4. Discuss in detail the design issues for arithmetic expressions. [15]
5.a) Define scope. Explain the static scope and dynamic scope with examples.
b)Explain pass by result parameter passing technique in detail. [15]
6. Discuss how producer-consumer problem and Dining philosophers problem are solved using
concurrency in ADA. [15]
7.a) Discuss how exception handlers are helpful in C++ exception handling.
b) Explain the use of java finally clause in exception handling. [15]
8.a) Explain some of the important functions of LISP.
b) Describe procedural abstraction in Python. [15]

118

119

120

121

17.Question Bank:
UNIT I
Why is it important to study principles of programming languages?
What are the different categories into which we can divide the various
programming languages.
Differentiate between procedural and object oriented programming languages.

Differentiate between functional and logic programming languages

Explain compilation process in detail.


Explain in detail Virtual machines.
Explain about Programming environments.
Which produces faster program execution, a compiler or pure interpreter?
Why is Readability important to Writability?
What are the factors influencing Readability of a Language? Explain.
Briefly discuss a few of the areas of computer applications and their associated
Languages.
Explain the different aspects of the cost of a programming language
What does it mean for a program to be reliable? Explain.
Explain how the Von Neumann architecture affected the design of
programming language.

Write a general problem for describing syntax.


What is the difference between language generator & recognizer ?
122

Define a left recursive grammar rule. Explain with an example.


Describe the basic concept of denotational semantics.
What are three reasons why syntax analyzers are based on grammars?
What is Ambiguity? How can it be removed, show with an example.
Explain with an example how the weakest precondition for a logical pretest
Loop is derived.
How do you express the associativity of operators in grammar? Explain with an
example.
Define Attribute grammars. Give an Attribute grammar for simple assignment
statements. How is the order of evaluation of attributes determined for the trees
of your Attribute grammar?
What are parse trees?
Explain BNF
Devlope an unambiguous grammar for if-then-else?
Write about EBNF?
Explain in detail Axiomatic semantics.

UNIT II
What are the design issues for names?
What is an alias, l-value of a variable & r-value?
Define binding, binding time, static binding and dynamic binding.
Define static, stack dynamic, explicit heap dynamic and implicit heap
dynamic variables.
What are the advantages and disadvantages of these? .

Define coercion,

type error, type checking?.


What are the design issues for character string types?
123

Explain primitive Data types.


What are the design issues for records ?
What is an associative array ?
Explain about Dangling pointers ?
What are the design issues for arrays?
What are the design issues for unions?
What is a C++ reference type and what is its common use?
Explain Type compatibility.
Explain the characteristics of variables.
How we can declare named constants in different languages?
Distinguish between static binding and dynamic binding?
Explain Java References in detail.
How does operand evaluation order interact with functional side effect?
What is an overloaded operator?

What is coercion?
Explain what are Assignment statements?
What are over loaded operators?
What are the design issues for selection structures?

What are the design issues for iteration statements ?


Explain User-Located Loop Control Mechanisms
Explain Guarded Commands .
Explain Arithmetic expressions?
Explain Boolean expressions?
Write about Short circuit evaluation?
What are functional side-effects?

UNIT III
124

What is a subprogram ?
Explain about parameters w.r.t subprograms ?
What are the Design Issues for Subprograms ?
What are the various Parameter Passing Methods?
How are Parameter Passing methods Implemented in various languages ?
What are the design Considerations for Parameter Passing
Explain what is Referencing Environment w.r.t nested subprograms ?
What are the Design Issues for Functions :
Explain about Coroutines
Explain how subprogram is overloaded. Give example?
Explain how subprogram names are passed as parameters. Illustrate with
examples?
What is 'PARAMETRIC PLOYMORPHISM'?
Differentiate between Static scope and Dynamic scope?
Explain about scope and lifetime of a variable?
Explain in detail generic subprograms?
UNIT IV
What is a semaphore? Write the algorithms for cooperation and competition
synchronization using semaphores
Explain about the Concept of Abstraction.
What are the design Issues for abstract data types ?
What are Encapsulation Constructs?
What are the Design Issues for OOP Languages?
Explain how the following languages support object orientation
a) Smalltalk
125

b) C++
c) Ada
d) c#
Explain Java threads in detail?
Explain semaphores with examples ?
Explain about Monitors
Explain Message Passing in Ada
Explain in detail c# threads.
Explain c++ parameterized abstract data types.
Explain sub program level concurrency
Give an example in C++ of an exception that is propagated out of its scope.
Write a prolog program to calculate factorial of a number?
Write the following statement in first order predicate calculus.
If it is raining or snowing, then there is precipitation.
Explain Exception propagation in detail.
Write about Java exception handling?
What are the applications of Logic programming languages?
What are basic elements of prolog?Explain.
Explain how backtracking works in Prolog
Explain Exception handling in Java
Explain Exception Propagation in Ada.

UNIT V
Explain the basic primitives of LISP. Give suitable examples
126

Explain the operations that can be performed on atoms & lists in LISP
Discuss basic elements of LISP. Give ex
Write a lisp fn which computes nth Fibonacci number
Explain ML inferencing process
Explain about the datatypes and their values in python.
What is the importance of module library in python.
What is the difference between a tuple and a list ?
Explain the main features of Imperative Languages.
Write a detail note on functions in ML.
Give comparison of Functional and Imperative Languages.
What are the applications of Functional Languages?
Explain how Haskell differs from ML.
Explain Data abstraction in Python?

18.Assignment Questions

Geethanjali College of Engineering&Technology


Cheeryal(v),Keesara(M),RR Dt.AP-501301
Name of subject: Principles Of Programming Languages
Dept: CSE Class: CSE III- A&B
Faculty: P.Haritha

Academic year: 2015-2016

ASSIGNMENT QUESTIONS
UNIT-1
127

1.Explain in detail Compilation process?


2.Write about Programming Domains ?
3.Write the differences between Procedure oriented and Object oriented
programming languages?
4.Explain different Programming Environments?
5.What is a Parse tree .Explain with an example ?
6. Write about EBNF ?
7.Develope unambiguous grammar for if-then-else ?
8.Explain about Attribute Grammars ?

UNIT-2
1. What are the design issues for names?
2.Explain about strong typing.
3.What is Dynamic binding?
4.What is an associative array ?
5. What is coercion?
6. Explain what are Assignment statements?
7.What are the design issues for selection structures?
8.Explain Guarded Commands

Unit 3

1. Explain Local Referencing Environments in Detail.


2. Illustrate operator overloading with an appropriate example in C++.
3. How can multidimensional arrays can be passed as arguments in Ada
language? Explain with an example.
4. Write short notes on:
a) Parameter passing methods

b) Type checking the parameters

128

5. Explain default parameter passing methods in different programming


languages?
6. Explain how dynamic binding is implemented in C++.

Unit 4
1.What is semaphore? Explain with bounded buffer example
2.What is a monitor? Explain with example
3.What are the basic concepts of declarative semantics? Explain.
4.What are the different forms of a prolog term? Explain.

5.Write a program in JAVA illustrating exception handling.


6. Explain the interfacing process of Prolog
7. What are the deficiencies in Prolog
8.Explain OOP in Java.

9. Explain C++ Parameterized Abstract Data types.

Unit 5
1. Write a HASKEL function that computes the volume of a cylinder given
radius.
2. Describe semantics of
a) COND &
b) LET

3. Explain the scoping rules used in scheme, common lisp, ML and HASKEL.
4. Mention the 3 ways in which ML is different from Scheme.
5. What are the applications of functional programming languages.
129

6. Explain the features of Scripting Languages.

19. Unit wise Quiz Questions

UNIT-1

1. The following is the widely used programming language developed for Artificial
Intelligence Application
1. LISP 2. FORTRAN 3. COBOL 4.ALGOL 60
2. The following language require Interpreter
1. C++ 2. C 3. COBOL 4. APL
3. C was developed by_____________.
4. The first language to provide even limited supported for data abstraction is
_________.
5. Fortran was the first language for scientific applications. [True/False]
6. C++ is object Oriented language. [True/False]
7 . The first high level programming language to include pointer variables was [ ]
1. Fortran 2. Ada 3. Algol-60 4. PL/1
8. In C and C++ the asterisk (*) denotes the following operation. [ ]
1. Dereferencing 2. negation 3. referencing 4. address
9. In FORTRAN90, Loop parameters are evaluated [ ]
1. Thrice 2. only once 3. twice 4. every time
10. The until keyword is used in for loop of ALGOL 60. [True/False]
11. In ADA, blocks are specified with declare clauses. [True/False]
12. ML is a Meta language for program verification system named LCF.
[True/False]
130

13. GPSS is developed to produce business reports . [True/False]


14. Modula-2 doesnt include go to statement. [True/False]
15. FORTRAN 90 also has the following semantics as Cs continue [ ]
1. Repeat 2. cycle 3. exit 4. go to
16. COBOL means [ ]
1. Common Bus Oriented Language
2. Common Buddy Oriented Language
3. Concrete Business Oriented Language
4. Common Business Oriented Language
17. Backus-Naur Form is a natural notation for describing syntax. [True/False]
18. SIMULA 67 is the first language to provide even limited supported for data
abstraction. [True/False]
20.In FORTRAN 95 equal to operator is written as
1.EQ.2.NQ 3.EE 4.QE [True/False]

21 The following Type compatibility is described in Semantics [ ]


1. Structured 2. static 3. denotional 4. dynamic
22. The following type compatibility is described in semantics [ ]
1. Static 2. dynamic 3. denotational 4. structured
23. The following type is one in which the variables have arrange of values that
consists of memory addresses and a special value nil [ ]
1. Enumerated 2. Pointer 3. Derived 4. Linked list
24. The __________ of a language is category of its Lexemes.
1. token 2. Keyword 3.special word 4.1 & 2
25. __________________ is the language of axiomatic semantics.
26. _____________ semantics was defined in conjunction with the development of
a method to prove the correctness of programs.
131

27. The first high level programming language to include pointer variables was
Fortran. [True/False]
28. The following is a name and an associated value such that value may never be
allowed to change by the program during execution [ ]
1. Variable 2. constant 3. keyword 4. Global variable
29. BNF is _______________________
30. In a parse tree, Leaf node represents ___________.
1.terminals 2. Non-terminals 3.parent nodes 4. Child nodes
31. If all the attributes values in a parse tree have been computed the tree is said to
be________.
1.half attributed tree
2.fully attributed tree
3.parse tree
4.game tree
32. Dynamic typing is used in LISP. [True/False]
33. The associativity of all operators in Pascal is of any order. [True/False]
34. The following is correct about semantics [ ]
1. Meaning of the expression, statement and programs units
2. Conditions for writing expressions, statements and programs units
3. Rules for writing expressions, statements and programs units
4. Protocol to be followed by statements

35._____________ attributes are synthesized attributes of leaf nodes whose


values are determined outside the parse tree.
1.Intrinsic 2. Extrinsic 3.Inherited 4. External
36. ________________ can be used to accept the sentence of a language.
1.generator 2. Recognizer 3. Acceptor 4. none
132

37. Axiomatic semantics are based on


1.predicate calculus 2.functions 3.mappings 4.relations
38.

gives meaning to statements and expressions

1.syntax 2.semantics 3.parse tree 4. unification


39. x=y+3 {x>10} post condition is
1. x>9 2. X>10 3. X=10 4.x=x-1
40. weakest precondition is determined by
1. post condition 2. Pre condition 3.expression 4. By substitution

UNIT-II

1. The following language has pointer concept [ ]


1. Java 2. c++ 3. DHTML 4. HTML
2. The following is an aggregate of homogeneous data elements in which an
individual element is identified by its position of the first element [ ]
1. Set 2. Array 3. structure 4. union
3. The first high level programming to included pointer variables was [ ]
1. Fortran 2. PL/1 3. ALGOL 60 4. ADA
4. The following is the association such as between an attribute and an entity, or
between an operation and a symbol [ ]
1. Over loading 2. binding 3. polymorphism 4. allocation
5. The following variables should not appear in recursive functions [ ]
1. Register 2. static 3. auto 4. extern
6. The following language supports labeled iteration [ ]
1. C++ 2. Pascal 3. Java 4. C

133

7. Having two or more distinct referencing methods or names for the same memory
cell is called _____________.
8. The ________ variables are bound to memory cells before execution begins and
remains bound to the same memory cell through out execution.
9. The ability of a program to intercept run-time errors, take corrective measures
and then continue execution is called________
10. _____________ language can select only one single statement under IF [ ]
1. C++ 2. FORTRAN 3. C 4. PASCAL
11. FORTRAN uses the following statement to select more than one statement
under IF with negative condition [ ]
1. IF 2. FOR 3. while 4. GOTO
12. Dynamic typing used in the following language [ ]
1. APL 2. LISP 3. SNOBO L4 4. Pascal
13. The following is a logical statement that is assumed to be true. [ ]
1. Axiom 2. Post Condition Statement
3. Reference statement 4. Precondition statement.
14. The following of the variable is the time between creation and termination [ ]
1. Context 2. scope 3. range 4. lifetime
15. The _____________types are supported directly in the hardware of the
machine and not defined in terms of other types.
16. In C switch case statement the default expression type can be_________.
17. _____________language support independent compilation.
18. ____________ has a pretest version, but no post test logically controlled
iteration
19. The type of the following operator ?: is [ ]
1. unary 2. not an operator 3. ternary 4. binary
20. The following type stores values as sequences of characters [ ]
134

1. Boolean 2. float 3. int 4. string


21. Dynamic typing is used in the following language [ ]
1. SNOBOL4 2. Pascal 3. LISP 4. APL
22. Aliasing in the context of programming languages refers to
(1) multiple variables having the same memory location
(2) multiple variables having the same value
(3) multiple variables having the same identifier
(4) multiple uses of the same variable
23.The following type has variables allowed to store different type values in a
memory [ ]
1. Record 2. array 3. union 4. associative array

24. The abs operator is [ ]


1. Unary 2. not an operator 3. ternary 4. binary
25. Else if is used in [ ]
1. ALGOL 60 2. PL/1 3. Ada 4. FORTRAN
26. The repeated execution of a statement or compound statement is accomplished
by blocking. [True/False]
27. SNOBOL doesnt require interpreter. [True/False]
28. This of the following is true for abstraction [ ]
1. The process of hiding all low - level details from the user
2. The ability to define and then use complicated structure in way that allows
many of the details to be ignored
3. The ability of a program to intercept run - time errors.
4. The ability to acquire properties of other class .
29. PDA means [ ]
1. Pop down Automata 2. Push down automata
3. Push Dip Automata 4. Push Down Automatic
135

30. Logical expressions are called [ ]


1. Axioms 2. conditions 3. assertions 4. subjects
31. The attributes are determined at [ ]
1. Language design time 2. Compile time 3. run time 4. load time
32. The following declaration is a means of associating variables with types
through default conversions instead of declaration statements [ ]
1. Explicit 2. implicit 3. internal 4. external
33. FORTRAN 90 supports the following user located loop control mechanisms [
]
1. Repeat 2. break 3.exit 4. continue
34. Block concept was introduced in the_____________ language
35. CGI stands for [ ]
1. Computer Gateway Interface 2. Common Gateway Interchange
3. Common Guided Interface 4. Common Gateway Interface
36. IPL stands for [ ]
1. Intelligent Procedure Language 2. Information Procedure Language
3. Information Proceeding Language 4. Information Processing Language

UNIT-III

1.A __ describes the interface to and the actions of the subprogram []


1.subprogram 2. Interface 3.scope 4.blocks
2. A subprogram header is the first part of the definition, including the name, the kind
of subprogram, and the formal parameters
3.The protocol is a subprograms parameter profile and, if it is a function, its return
type

136

4.A formal parameter is a dummy variable listed in the subprogram header and
used in the subprog
5.An actual parameter represents a value or address used in the subprogram call
statement
6. In C++, default parameters must appear last
7.Fortran Always used the

semantics model

1.inout 2.in 3. Out 4. out


8. C Pass-by-reference is achieved by using pointers as parameters
9. C++ A special pointer type called reference type for pass-by-reference
10.Java :All parameters are passed by value.
11.C# :Default method: pass-by-value.
12. A__is a subprogram that has multiple entries and controls these entries by
itself []
1.coroutine 2. Subprogram 3.Concurrency 4. Blocks
13. What is printed by the print statements in the program P1 assuming call by
reference parameter passing?
Program Pl()
{
x=10;
y=3;
func1(y, x, x);
print x;
print y;
}
func1 (x, y, z)
{
y = y + 4;
z = x + y + z;
}
a) 10, 3
b) 31, 3
137

c) 27, 7
d) None of the above
14. The- results returned by functions under value-result and reference
parameter passing conventions [ ]
a) Do not differ
b) Differ in the presence of loops
c) Differ in all cases
d) May differ in the presence of exceptions
15. The caller is _______________during execution of the called subprogram []
(A) suspended (B) terminated (C) blocked (D) none
16. A Subprogram declaration provides the _________________, but not body,of
the subprogram. [ ]
(A) definition (B) code (C) protocol (D) none
17.If local variables are stack-dynamic, advantage is _________________
[]
(A) deallocation
(B) allocation
(C) indirect address
(D) they support
recursion
18. The period of time between an allocation and its subsequent disposal is called
(A) Life time (B) scope (C) binding (D) all
19. In java, object parameters are passed using
[]
(A) call-by-name (B) call-by-value (C) call-by-reference
(D) call-by-result
20) Which modifier used in C# method to specify a formal parameter [ ]
A) New B) Def C) Params D) A&B
21) Variables defined inside the subprogram is called [ ]
A) Global variables B) Local Variables C) Parameter D)None
UNIT-IV
1. Nearly all programming languages support process abstraction with subprograms
2. Ada :The encapsulation construct is called packages
3. In C++ The class is the encapsulation device
4. C# does not currently support parameterized classes
5. A class that inherits is a derived class or a subclass
138

6. The class from which another class inherits is a parent class or superclass
7. Subprograms that define operations on objects are called methods
8. Calls to methods are called messages
9. The entire collection of methods of an object is called its message protocol
10.Ex of a pure OOP language Smalltalk
11.SIMD stands for Single Instruction Multiple Data m/cs
12. MIMD stands for Multiple Instruction Multiple Data m/cs
13.Task or process is a program unit that can be in concurrent execution with
other program units
14.Heavyweight tasks execute in their own address space and have their own
run-time stacks
15. Lightweight tasks all run in the same address space and use the same runtime stack
16. Synchronisation is a mechanism that controls the order in which tasks
execute.
17.Cooperation Sync: Task A must wait for task B to complete some specific
activity before task A can continue its execution
18. Competition Sync: Two or more tasks must use some resource that cannot
be simultaneously used
19.Task execution control is maintained by a program called the scheduler
20.If all tasks in a concurrent environment lose their liveness, it is called
A)deadlock B)semaphore C)concurrency D)none

21. A ------ is a data structure consisting of a counter and a queue for storing
task descriptors which stores all relevant info about the exec state of a task.
A)semaphore B)message passing C)monitor D)A&B
22.Semaphores have only two operations
139

A)wait B)release C)stop D)A&B


23.In Java restrictions are called
[]
A) Boundaries B) Constraint C) Limit D) Bounds
24.An instance of abstract data type is called
[]
A) Variable B) Object C) Value D) Constructor
25. _______________method, which kills the thread

]
(A) stop () (B) yield () (C) suspend () (D) start ()
26. Array Index Outof BoundsException is defined in _____________package []
(A) java.applet (B) java.awt (C) java.util (D) java.lang
27. An instance of abstract data type is called
[]
A) Variable B) Object C) Value D) Constructor
28 The encapsulating constructs in Ada are called [ ]
A) Exceptions B) Interfaces C) Definitions D) Packages
29. Concurrency can occur at _______________level
[ ]
(A) kernel (B) program (C) unit (D) data
30.When a sender tasks message is accepted by a rceiver task, the actual message
transmission is called a rendezvous
31.An

is any unusual event, either erroneous or not, detectable by either

hardware or software, that may require special processing


1. condition 2. Exception 3. Procedures 4. none
32.The special processing that may be required after detection of an exception is
called exception handling
33.The exception handling code unit is called an exception handler
34.

programming languages are Declarative rather than procedural ie only

specification of results are stated & not detailed procedures for producing them.
A) Logic B) functional C) Imperative D) None
35. The particular form of symbolic logic used for logic programming is called
A) predicate calculus B) functions C) algorithms D) A&B
140

36.A logical statement that may or may not be true is called a


A) proposition B) Fact C) Rule D) Resolution
37. Simplest proposition is the Atomic propositions, consists of compound terms
which is written like a mathematical function
38. An Exception raised in which construct
[]
A) Catch B) Throw C) Try D) None
39. Deriving new propositions based on previous called
A) resolution B) lazy eval C) Lambda exp D) A&B
40. is used to describe the relations
A) functor B) unification C) Matching D) terms
41.

are used along with the variables in prolog

A) quantifiers B)qualifiers C)terms D) B&D


42. Finding value to variable in prolog is
A) Unification B) Simplification C) Matching D)exceptional propagation
43. Java

clause provides a mechanism for guaranteeing that

some code will be executed how the execution of a try compound terminates.
A) finally B) throws C) try D) catch
44. The categories of exceptions in Java are
a) checked b) unchecked c)constant d)a&b
45. Empty left side propositions are called as
a) headed horn clauses
b) horn clauses
c) hypotheses
d) goal
46.Re-consideration of path is
a) backtracking
b) BFS
141

c) farward chaining
d) backward chaining
49. Logic programming languages are used in
a) RDBMS
b) expert systems
c) natural language processing
d) all

UNIT-5

1. A static-scoped functional language with syntax that is closer to Pascal than to LISP
A) ML B) HASKELL C) C D) FORTRAN
2. ML is strongly typed (whereas Scheme is essentially typeless) and has no type
coercions
3.

Uses lazy evaluation (evaluate no subexpression until the value is needed)

A)ML B)HASKELL C) LISP D) PROLOG


4.APL is used for throw-away programs
5. In PHP 2 integers are divided what is the out come [ ]
A)float B) Int C) char D) All
6. Pure LISP has only two kinds of data structures atoms and [ ]
A). Arrays B). Lists C). variables D). Stack
7. The design of the functional langs is based on
1.mathematical functions 2. Predicate calculus 3. Relations 4.none
8.The first functional programming language
A). ML B). HASKELL C). LISP D). FORTRAN

142

20. Tutorial Questions


1.Differences between POP-OOP?
2.Imperative languages-functional languages
3.Programming environments
4.Grammars and derivations
5.Functional side-effects
6.Parse trees
7.Type coercion(explicit-implicit)
8.Syntax and semantics of PL
9.Strong typing
10.Type compatibility
11.Mixed mode assignments
12.Short circuit evaluation
13. Call by value-call by reference
14.Overloaded operators
15.Parallel programming Languages
16.Logic programming Languages
17.Exceptions(ada,c++,java)
18.Scripting Languages
19.Data abstraction-procedural abstraction

21.Known gaps ,if any


No.

22.Discussion topics , if any


1.Differences between POP-OOP?
2.Imperative languages-functional languages
3.Call by value-call by reference
4. Grammars and derivations
4.Data abstraction-procedural abstraction
5.Type coercion(explicit-implicit)

143

23. References, Journals, websites and E-links


Websites
1. www.aw.com/cssupport
2. www.perl.com
3. haskell.org
4. java.sun.com
5. www.cs.rise.edu/CS/PLT/packages/drscheme/

e books :
1. Concepts of Programming Languages Robert .W. Sebesta 7/e, Pearson
Education.
2.Programming Languages Louden, Second Edition, Thomson.

Subject Experts :
1. Prof. K.Gopinath , Professor Computer Science & Automation (CSA),
Indian Institute of Science (IISc), Bangalore 560012 INDIA

2. Dr. Satish Ramesh Kolhe , Reader , Department of Computer Science, North


Maharashtra University, Jalgaon

List of relevant journals :


SCP - Science of Computer Programming
JFP - Journal of Functional Programming
IJPP - International Journal of Parallel Programming
JOOP - Journal of Object-oriented Programming
CL - Computer Languages, Systems & Structures
TPLP - Theory and Practice of Logic Programming
JPL - Journal of Programming Languages

144

24. Quality Control Sheets


25. Student List
Students list II CSE A

12R11A0507

B MADHU SUDHAN

12R11A0509

CHEBROLU VEERAPA NAIDU

13R11A0501

A BHARATH KUMAR

13R11A0502

AKUNOOR SAKETH

13R11A0503

ALURI VENKATA PAVANKUMAR

13R11A0504

ANANTHULA NITIN BABU

13R11A0505

ANKALA NIKILESHWAR RAO

13R11A0506

ANUGU SAI KRISHNA REDDY

13R11A0507

BANDARU KRUTHI

10

13R11A0509

BODA ABHISHEK

11

13R11A0510

B VINOD

12

13R11A0511

BIRUDHA RAJU SUCHITRA

13

13R11A0512

BOMMAGANI NARESH

14

13R11A0513

C SRAVAN KUMAR

15

13R11A0514

CHAVALA VISHAL

16

13R11A0515

DINDI MURALI KRISHNA

17

13R11A0516

DUDIMADOGULA JHANSI

18

13R11A0517

DOKKUPALLY SAI VARDHAN REDDY

19

13R11A0518

DONKANI SANTHOSH GOUD

20

13R11A0519

G YAMINI

21

13R11A0520

GANGAVARAPU SARIKA

22

13R11A0521

GANGULA KARTHIKEYA REDDY


145

23

13R11A0522

GUDI NIKHITHA

24

13R11A0523

GUNDABATTULA SHRAVANI

25

13R11A0524

HARSHITHA KRISHNA T

26

13R11A0525

INGUVA SACHIN SAI

27

13R11A0526

INGUVA SIVA SUBRAMANYAM

28

13R11A0527

KARLA MAHESH

29

13R11A0528

KARANAM SAI PHANI TEJA

30

13R11A0529

KAUSHIK KHANDELWAL

31

13R11A0530

KEESARI VINEETH REDDY

32

13R11A0531

KODURI NITYA PURNIMA

33

13R11A0532

KOMMIDI NISHANTH REDDY

34

13R11A0533

KUCHALLAPATI RENUKA

35

13R11A0535

NASEEM FATHIMA

36

13R11A0536

PATNAM KEERTHI PRIYANKA

37

13R11A0537

PINNINTI SHIVANI

38

13R11A0538

PURANAM SATYA SAI RAM

39

13R11A0539

PUVVULA ROHINI

40

13R11A0540

RAHUL T

41

13R11A0541

RAJENDRAN ONISHA

42

13R11A0542

RICHARD BENHUR K

43

13R11A0543

RIYA PRAMOD KHANDARE

44

13R11A0544

S JAYANTH

45

13R11A0545

SINGIREDDY NAVEEN REDDY

46

13R11A0546

SANJEEVU TEJASWANI

146

47

13R11A0547

TADIPARTHI CHRISTINA

48

13R11A0548

TALAKOKKULA VISHAL

49

13R11A0549

TANNIRU MOUNIKA

50

13R11A0550

UPPULURI SAI ABHILASH

51

13R11A0551

V TULAJA SRAVANTHI

52

13R11A0552

VADDALAPU UDAY SAI

53

13R11A0553

P S MANASA

54

13R11A0554

NOMULA KIRAN KUMAR

Students list II CSE B

13R11A0555

ADLA JAYASHREE

13R11A0556

ALETI ROOPAREDDY

13R11A0557

B ADITYA REDDY

13R11A0558

B CHANDRA SHEKAR REDDY

13R11A0559

B KARTHIK RAO

13R11A0560

BURUGU RANJITH KUMAR REDDY

13R11A0561

BATTU SHIRISH KUMAR REDDY

13R11A0562

BADIMELA KAVYASREE MADHURI

13R11A0563

BANDARU PRADEEP

10

13R11A0564

BHASKAR DIVYA

11

13R11A0565

B TEJASREE

12

13R11A0566

BUDDA NAGA PRASANNA

13

13R11A0567

BUKKAPATNAM HRIDAYA LAKSHMI

14

13R11A0568

CHIVUKULA RAHUL BHARADWAJ

15

13R11A0569

CHALLA BHARGAVI REDDY


147

16

13R11A0570

CHILASAGAR JYOTHI

17

13R11A0571

CHILUKOJI JAYANTHI

18

13R11A0572

CHITLOJU MADHUKAR CHARY

19

13R11A0573

DESHAM SRIKANTH GOUD

20

13R11A0574

DUSARI LAXMI PRASANNA

21

13R11A0575

GUBBA SRILAKSHMI

22

13R11A0576

GADDAM SRIKANTH REDDY

23

13R11A0577

GINKA KIRAN

24

13R11A0578

GUDAVALLI RAMA KRISHNA PRASAD

25

13R11A0579

J SUSMITHA

26

13R11A0580

KAMSANI VIJAYENDHAR REDDY

27

13R11A0581

KANDUKURI SURYATEJA

28

13R11A0582

KOLLIPARA NISCHAL

29

13R11A0583

L PRUTHIVI KUMAR

30

13R11A0584

VISHAL VINOD LOKARE

31

13R11A0585

LAKSHMI PRASANNA B

32

13R11A0586

MOKHAMATAM SWETHA

33

13R11A0587

MEDURI BHAVYA SAMEERA

34

13R11A0588

M S BHUVAN

35

13R11A0589

MANGA VIVEK KUMAR

36

13R11A0590

MARABOINA KEERTHANA

37

13R11A0591

MAVARAM BHARGAVA

38

13R11A0592

MODALI NEELA LOHITA KASHYAP

39

13R11A0593

NAGAPURI DIVYA

40

13R11A0594

PAGADIENTI SAI VAMSHI

41

13R11A0595

PENDAM VINAY KUMAR

42

13R11A0596

POTHANA HARIKA

43

13R11A0597

PUNNA SPOORTHY
148

44

13R11A0598

RAMESH B K

45

13R11A0599

S SAIKIRAN

46

13R11A05A0

SANGI SHETTI VISHAL

47

13R11A05A1

SAVARAM SAMBASIVA AKHIL

48

13R11A05A2

SHAIK SAAJIDAH BANU

49

13R11A05A3

SHARATH KUMAR P

50

13R11A05A4

SRINADHUNI LAKSHMI KAVYA

51

13R11A05A5

T MADHURI CHARY

52

13R11A05A6

TADEGIRI BUELAH RANI

53

13R11A05A7

THOTA ADITYA KUMAR

54

13R11A05A8

V LAKSHMI

55

13R11A05A9

VADLAMANI ADITYA

56

13R11A05B0

VEERAMALLI SAITEJA

57

13R11A05B1

VIDYA BHARATHI CHEGU

58

13R11A05B2

VUDEPU TARUN KUMAR

59

13R11A05B3

YALLAMBHOTLA ACHYUTH

60

13R11A05B4

YELLAGOUNI HARI KRISHNA

26. Group wise Student list for Discussion

II CSE A

12R11A0507

B MADHU SUDHAN

12R11A0509

CHEBROLU VEERAPA NAIDU

13R11A0501

A BHARATH KUMAR

13R11A0502

AKUNOOR SAKETH

13R11A0503

ALURI VENKATA PAVANKUMAR

149

13R11A0504

ANANTHULA NITIN BABU

13R11A0505

ANKALA NIKILESHWAR RAO

13R11A0506

ANUGU SAI KRISHNA REDDY

13R11A0507

BANDARU KRUTHI
B SOUJANYA

13R11A0508

13R11A0509

BODA ABHISHEK

13R11A0511

BIRUDHA RAJU SUCHITRA

13R11A0512

BOMMAGANI NARESH

13R11A0513

C SRAVAN KUMAR

13R11A0514

CHAVALA VISHAL

13R11A0515

DINDI MURALI KRISHNA

13R11A0516

DUDIMADOGULA JHANSI

13R11A0517

DOKKUPALLY SAI VARDHAN REDDY

13R11A0518

DONKANI SANTHOSH GOUD

13R11A0519

G YAMINI

13R11A0520

GANGAVARAPU SARIKA

13R11A0521

GANGULA KARTHIKEYA REDDY

13R11A0522

GUDI NIKHITHA

13R11A0523

GUNDABATTULA SHRAVANI

13R11A0524

HARSHITHA KRISHNA T

13R11A0525

INGUVA SACHIN SAI


150

13R11A0526

INGUVA SIVA SUBRAMANYAM

13R11A0527

KARLA MAHESH

13R11A0528

KARANAM SAI PHANI TEJA

13R11A0529

KAUSHIK KHANDELWAL

13R11A0530

KEESARI VINEETH REDDY

13R11A0531

KODURI NITYA PURNIMA

13R11A0532

KOMMIDI NISHANTH REDDY

13R11A0533

KUCHALLAPATI RENUKA

13R11A0535

NASEEM FATHIMA

13R11A0536

PATNAM KEERTHI PRIYANKA

13R11A0537

PINNINTI SHIVANI

13R11A0538

PURANAM SATYA SAI RAM

13R11A0539

PUVVULA ROHINI

13R11A0540

RAHUL T

13R11A0541

RAJENDRAN ONISHA

13R11A0542

RICHARD BENHUR K

13R11A0543

RIYA PRAMOD KHANDARE

13R11A0544

S JAYANTH

13R11A0545

SINGIREDDY NAVEEN REDDY

13R11A0546

SANJEEVU TEJASWANI

13R11A0547

TADIPARTHI CHRISTINA
151

13R11A0548

TALAKOKKULA VISHAL

13R11A0549

TANNIRU MOUNIKA

13R11A0550

UPPULURI SAI ABHILASH

13R11A0551

V TULAJA SRAVANTHI

13R11A0552

VADDALAPU UDAY SAI

13R11A0553

P S MANASA

13R11A0554

NOMULA KIRAN KUMAR

26.Group-Wise students list for discussion topics

II CSE B
1

13R11A0555

ADLA JAYASHREE

13R11A0556

ALETI ROOPAREDDY

13R11A0557

B ADITYA REDDY

13R11A0558

B CHANDRA SHEKAR REDDY

13R11A0559

B KARTHIK RAO

13R11A0560

BURUGU RANJITH KUMAR REDDY

13R11A0561

BATTU SHIRISH KUMAR REDDY

13R11A0562

BADIMELA KAVYASREE MADHURI

13R11A0563

BANDARU PRADEEP

13R11A0564

BHASKAR DIVYA

13R11A0565

B TEJASREE

13R11A0566

BUDDA NAGA PRASANNA

13R11A0567

BUKKAPATNAM HRIDAYA LAKSHMI


152

13R11A0568

CHIVUKULA RAHUL BHARADWAJ

13R11A0569

CHALLA BHARGAVI REDDY

13R11A0570

CHILASAGAR JYOTHI

13R11A0571

CHILUKOJI JAYANTHI

13R11A0572

CHITLOJU MADHUKAR CHARY

13R11A0573

DESHAM SRIKANTH GOUD

13R11A0574

DUSARI LAXMI PRASANNA

13R11A0575

GUBBA SRILAKSHMI

13R11A0576

GADDAM SRIKANTH REDDY

13R11A0577

GINKA KIRAN

13R11A0578

GUDAVALLI RAMA KRISHNA PRASAD

13R11A0579

J SUSMITHA

13R11A0580

KAMSANI VIJAYENDHAR REDDY

13R11A0581

KANDUKURI SURYATEJA

13R11A0582

KOLLIPARA NISCHAL

13R11A0583

L PRUTHIVI KUMAR

13R11A0584

VISHAL VINOD LOKARE

13R11A0585

LAKSHMI PRASANNA B

13R11A0586

MOKHAMATAM SWETHA

13R11A0587

MEDURI BHAVYA SAMEERA

13R11A0588

M S BHUVAN

13R11A0589

MANGA VIVEK KUMAR

13R11A0590

MARABOINA KEERTHANA
153

13R11A0591

MAVARAM BHARGAVA

13R11A0593

NAGAPURI DIVYA

13R11A0594

PAGADIENTI SAI VAMSHI

13R11A0595

PENDAM VINAY KUMAR

13R11A0596

POTHANA HARIKA

13R11A0597

PUNNA SPOORTHY

13R11A0598

RAMESH B K

13R11A0599

S SAIKIRAN

13R11A05A0

SANGI SHETTI VISHAL

13R11A05A1

SAVARAM SAMBASIVA AKHIL

13R11A05A2

SHAIK SAAJIDAH BANU

13R11A05A3

SHARATH KUMAR P

13R11A05A4

SRINADHUNI LAKSHMI KAVYA

13R11A05A5

T MADHURI CHARY

13R11A05A6

TADEGIRI BUELAH RANI

13R11A05A7

THOTA ADITYA KUMAR

13R11A05A8

V LAKSHMI

13R11A05A9

VADLAMANI ADITYA

13R11A05B0

VEERAMALLI SAITEJA

13R11A05B1

VIDYA BHARATHI CHEGU

13R11A05B2

VUDEPU TARUN KUMAR

13R11A05B3

YALLAMBHOTLA ACHYUTH

13R11A05B4

YELLAGOUNI HARI KRISHNA

154

Вам также может понравиться