0% found this document useful (0 votes)
20 views10 pages

PPL-Unit 2 Part 1

Uploaded by

thirumal536
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views10 pages

PPL-Unit 2 Part 1

Uploaded by

thirumal536
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Principle of Programming

Languages
Unit-II
Presented By
Mr. P. Thiramal Reddy
Assistant Professor
CSE Dept.
Introduction
•Imperative programming languages are abstractions
of the underlying von Neumann computer architecture.
•The architecture’s two primary components are its
memory, which stores both instructions and data and
its processor, which provides operations for modifying
the contents of the memory.
•The abstractions in a language for the memory cells of
the machine
are variables.
•A variable can be characterized by a collection of
properties, or attributes,the most important of which is
type, a fundamental concept in programming
languages.
•Functional programming languages allow expressions
to be named. These named expressions appear like
Names
Names are also associated with subprograms, formal
parameters, and other program constructs. The term
identifier is often used interchangeably with name.

Design Issues
The following are the primary design issues for names:
• Are names case sensitive?
• Are the special words of the language reserved words
or keywords?

Name Forms
A name is a string of characters used to identify some
entity in a program.
Fortran 95+ allows up to 31 characters in its names.
Names in Java, C#, and Ada have no length limit
Names
•Names in most programming languages have the
same form:
a letter followed by a string consisting of letters,
digits, and
underscore characters ( _ ).
•All variable names in PHP must begin with a dollar
sign. In
Perl, the special character at the beginning of a
variable’s name,
$, @, or %. In Ruby, special characters at the
beginning of
a variable’s name, @ or @@.
•In many languages, notably the C-based languages,
uppercase and lowercase letters in names
are distinct; that is, names in these languages are
Names
lowercase letters. For example, the Java method for
converting a string to an integer value is parseInt,
and spellings such as ParseInt and parseint are not
recognized.

Special Words:
Special words in programming languages are used
to make programs more readable by naming actions
to be performed.
In most languages, special words are classified as
reserved words, which means they cannot be
redefined by programmers,
but in some they are only keywords, which means
they can be redefined.
A keyword is a word of a programming language
Names

•In Fortran, the word Integer, when found at the


beginning of a statement and followed by a name, is
considered a keyword that indicates the statement is
a declarative statement. However, if the word
Integer is followed by the assignment operator, it is
considered a variable name.
•These two uses are illustrated in the following:
Integer Apple
Integer = 4
•A reserved word is a special word of a
programming language that cannot be used as a
name.
•For example, in Fortran, one could have the
following statements:
Variables
• A program variable is an abstraction of a computer
memory cell or collection of cells.
• A variable can be characterized as a six attributes:
name, address,
value, type, lifetime, and scope.

Name:
• Variable names are the most common names in
programs.
Address:
• The address of a variable is the machine memory
address with which it is associated.
• The address of a variable is sometimes called its l-
value, because the address is what is required when the
name of a variable appears in the left side of an
assignment.
Variables
Type:
•The type of a variable determines the range of
values the variable can store.
•For example, the int type in Java specifies a value
range of -2147483648 to 2147483647

Value:
•The value of a variable is the contents of the
memory cell or cells associated with the variable.
•An abstract memory cell has the size required by
the variable
with which it is associated. For example, although
floating-point values may occupy four physical
bytes.
Variables
Scope and life time :
•The scope of a variable refers to the areas or the
sections of the program in which the variable can be
accessed, and the lifetime of a variable indicates
how long the variable stays alive in the memory.
•In java according to scope and life time
variable .There are three types of variables , They
are
Instance Variables:
•A variable which is declared inside a class, but is
declared outside any methods and blocks is known
as instance variable.
Scope: Throughout the class except in the static
methods.
Lifetime: Until the object of the class stays in the
Variables
Class Variables:
•A variable which is declared inside a class, outside
all the blocks and is declared as static is known
as class variable.
Scope: Throughout the class.
Lifetime: Until the end of the program.
Local Variables:
All variables which are
not instance or class variables are known
as local variables.
Scope: Within the block it is declared.
Lifetime: Until control leaves the block in which it
is declared.

You might also like