COMPILERS: PROGRAMMING
LANGUAGES
ASSIGNMENTS - STATEMENTS.
1
Presentation By: Geo S. Mariyan
(Master in Computer Science)
Assignment - Introduction
• Assignment is to "assign a pre declared variable with
some value or by the value of another variable of the
same data type. This is done anywhere in body of the
program.
For E.g. : n=9 or m=5 then, n=5 !
assigns value 5 to n
• Initialization is telling compiler to allocate a
memory to the initialized variable so that compiler can
know that this variable is going to store some value.
2
ASSIGNMENT – Symbolic Representation
• ASSIGNMENT: The Basic Operation for changing the binding of
the value to the data object.
• Assignment also returns the value, which is a data object
containing the copy of a value assigned.
3
Ex : int a; Initializing 'a' as of type int
Assignment means proving a particular value to
any variable.
Ex: int a=2; a in assigned a value to 2.
This is purely assignment and assignment
can be done n no. of times in a program. There is no
such restriction on it.
Assignment throws away the old value of a
variable and replacing it with a new one. It can be done
anywhere in the whole program.
4
l- and r- values
• An lvalue can appear on the left side of an assignment
operator, whereas an rvalue can appear on the right side.
• "lvalue" and "rvalue" are so named because of where each
of them can appear in an assignment operation.
• ex: int a, b;
• a = 4;
• b = a;
• In the third line of that example, "b" is the lvalue, and "a"
is the rvalue, whereas it was the lvalue in line.
• This illustrates an important point: An lvalue can also be
an rvalue.
5
Assignment Operators
• An assignment operator is the operator used
to assign a new value to a variable, property, event or
indexer element.
• Assignment operators can also be used for logical
operations such as bitwise logical operations or
operations on integral operands and Boolean operands.
• Unlike in C++, assignment operators in C# cannot be
overloaded directly, but the user-defined types can
overload the operators like +, -, /, etc. This allows the
assignment operator to be used with those types.
6
Characteristics of Assignment Operators:
• The different assignment operators are based on the type of
operation performed between two operands such as addition
(+=), subtraction, (-=), etc. The meaning of the operator
symbol used depends on the type of the operands.
• Assignment operators are right-associative, which means they
are grouped from right to left.
• Although assignment using assignment operator (a += b)
achieves the same result as that without ( =a +b), the
difference between the two ways is that unlike in the latter
example, "a" is evaluated only once.
7
Practice with Assignment Operators
The assignment operator expects the type of both
the left- and right-hand side to be the same for
successful assignment.
Example:
i += 24
i *= x
8
Variant forms of Assignment
•Augmented Assignment
•Chained Assignment
•Parallel Assignment
9
• Augmented assignment: The case where the assigned
value depends on a previous one is so common that many
imperative languages, most notably C and the majority of
its descendants, provide special operators
called Augmented assignment
ex: *=, so a = 2*a can instead be written as a *= 2
• Chained assignment: A statement like w = x = y = z is
called a chained assignment in which the value of z is
assigned to multiple variables w, x, and y. Chained
assignments are often used to initialize multiple variables, as
in
•example: a = b = c = d = f = 0
10
Parallel Assignment:
Some programming languages, such
as Go, JavaScript (since, Maple, Perl, Python, REBOL, Ruby,
and Windows Power Shell allow several variables to be
assigned in parallel, with syntax like:
ex: a, b := 0, 1
which simultaneously assigns 0 to a and 1 to b. This is most
often known as parallel assignment.
11
Assignment statements
• Once a variable is declared, it can be assigned values
multiple times in a program; for example:
int num; // num declared,
uninitialized
num = 3; // num assigned 3
num = num + 1; // num assigned 3 + 1 (4)
num = 15 / num; // num assigned 15 / 4
12
Implementation of Assignment:
• Compiler can implement the assignment A := B
• The Compiler generates code to compute the r-value and B
into some register r-value of B into some register r
• If the data types of A and B are incompatible, the compiler
generates code to convert the r-value of B to a type
appropriate for A.
• If necessary, the compiler generates the code to determine
the l-value of A.
(if A is in primitive type , no code is needed)
• Finally, the compiler generates code to store the
contents of register r into the l-values of A.
13
Assignment compatibility
• When a variable is declared, the data type in the
declaration indicates the nature of the values the variable is
capable of storing.
• For example, an int variable can store a whole number, a
char variable can store a character, and a double variable
can store a real number.
• The value assigned to the variable must be compatible with
its data type.
14
•Java is a strongly-typed language.
•This means that, for the most part, you can only
assign a value of a particular data type to a
variable of the same type
•Some examples:
int x = -2; // this is fine; -2 is an integer
char c = ‘2’; // this is OK also
x = 2.5; // syntax error: 2.5 is a double value,
not an int
c = 2; // also an error; 2 is an int value, not a
char
15
Assignment Statement Variety:
= FORTRAN, C, C++, Java
= Can be bad if it is overloaded for the
relational operator for equality.
• Example
C: a=b=c
• In the C statement A = B = C, the value of C is
assigned to B, and the value of B is assigned to A.
16
Statements:
Definition :
A statement in programming context is a
single complete programming instruction that is
written as code.
The Elementary action of evaluation,
assignment and control of evaluation orders are
specified by the statements of the programming
language .
Statements can have diverse forms and
languages.
17
Function Call Statement
•Certain function calls, such as the MESSAGE function,
can be a statement on their own. They are known as
function call statements
•
18
The Statement Separator
A single programming statement may span
several code lines; one code line may consist of
multiple statements.
Therefore, the C compiler must be able to
detect when one statement ends and another
statement begins.
[ <statement> { ; <statement> } ]
Example : Integer Num:=10;
19
Assignment Statement
In computer programming, an assignment
statement sets and/or re-sets the value stored in the
storage location(s) denoted by a variable name; in other
words, it copies a value into the variable. In most
imperative programming languages, the assignment
statement (or expression) is a fundamental construct.
The syntax of an assignment statement is almost as easy
as the syntax of the function call statement. The syntax is
as follows:
<variable> := <expression>
20
Assignment Statement
• Assignment statements can be in the following two forms
1) x := op y
2) x := y op z
• First statement op is a unary operation. Essential unary
operations are unary logical negation, shift operators and
conversion operators.
• Second statement op is a binary arithmetic or logical
operator.
21
Assignment Operator
• An assignment operator is the operator used
to assign a new value to a variable, property, event or
indexer element in C# programming language.
• Assignment operators can also be used for logical
operations such as bitwise logical operations or operations
on integral operands and Boolean operands.
• The “colon equals” (:=) is known as the assignment
operator. You use it to assign a value or an expression that
evaluates to a value to a variable.
• :=
22
Jump Statements
• The jump statements are the goto statement, the
continue statement, the break statement, and the
return statement.
• The source statement like if and while-do cause jump in the
control flow through three address code so any statement in
three address code can be given label to make it the target of a
jump.
23
Indexed Assignment
• Indexed assignment of the form A:=B[I] and A[I]:=B.
the first statement sets A to the value in the location I
memory units beyond location B.
• In the later statement A [I]:=B, sets the location I units
beyond A to the value of B.
• In Both instructions A, B, and I are assumed to refer
data objects and will represented by pointers to the
symbol table.
24
Address and Pointer Assignment
• Address and pointer assignment
x := &y
x := *y
*x := y
• First statement, sets the value of x to be
the location of y.
• In x := *y, here y is a pointer or
temporary whose r-value is a location. The r-value of
x is made equal to the contents of that location.
• *x := y sets the r-value of the object
pointed to by a to the r-value of y.
25
Assignment Operations
• Most basic statements for initializing variables
• General syntax:
• variable = expression;
• Example:
• length = 25;
• Expression
• Any combination of constants and variables that
can be evaluated to yield a result
26
•All variables used in an expression must
previously have been given valid values.
•Must be a variable listed immediately to the
left of the equal sign.
•Has lower precedence than any other
arithmetic operator.
27
Assignment Statements: Compound
Operators
•A shorthand method of specifying a
commonly needed form of assignment.
•Introduced in ALGOL; adopted by C
Example:
a = a + b is written as a += b
•Unary assignment operators in C-based
languages combine increment and decrement
operations with assignment.
28
Examples:
• sum = ++count (count incremented,
then assigned to sum)
• sum = count++ (count assigned to sum,
then incremented)
• count++ (count incremented)
• -count++ (count incremented then negated)
29
Assignment as an Expression
• In C, C++, and Java, the assignment statement
produces a result and can be used as operands
• An example:
while ((ch=getchar())!= EndOfFile){…}
ch = getchar() is carried out; the result
(assigned to ch) is used as a conditional value for the
while statement
30
Simple and Compound Statements
• Simple Statement: A Simple statement is one which
does not contain any augmented statement.
• Read, Assignment and goto are the three examples of
simple statements.
• In certain languages, a program may be regarded
as a sequence of simple statements. (e.g., BASIC,
SNOBOL)
• Compound Statement: A Compound Statement is one
that may contain one or more embedded statements.
• The logical IF in FORTRAN
• IF (condition) statement
31
Compound statements: The Compound Statement
enable computation that logically belong together and
be grouped together syntactically.
• This ability of grouping together helps make program
readable.
Example of Compound statement:
1. If condition then statement
2. If condition then statement else statement
3. While condition do statement
32
Explanation:
• The if-then and if-then-else statements allows all actions
that apply for the value of condition to be grouped
together.
• The compound statements permits the sequence of the
statements to be used wherever one may appear.
• The while statements is to establish the loops with
arbitrary loop control conditions.
• In compound statement in other languages the syntax
may be widely different.
•Note*: The test for the condition is performed
before the statements allowing the loops to be
executed zero times if necessary.
33
Types of Statements
1. Conditional Statements.
2. Sequential Statements.
3. Control Statements.
4.Structural Statements.
5. Declaration Statements.
6.Input Statements.
7. Output Statements.
34
Conditional Statements:
• In Conditional statements are features of
a programming language, which perform different
computations or actions depending on whether a
programmer specified boolean condition evaluates to true
or false.
35
36
Conditional statement is a set of rules
performed if a certain condition is met. Below are some
examples of conditional statements in programming.
this last example will print if it is greater than 10, less than 10
or equal to 10.
Sequential Statement:
• In most languages , control automatically flows from one
statement to the next.
• Certain statements such as goto, break, call and return
deliberately alter the flow of control.
• There has been considerable debate as to what statements
are best suited for creating easy to understand flow-of-
control patterns in programs.
• The Sequential statement has been the focus and it permits
the arbitrary flow-of-control patterns, including those that
are difficult to comprehend.
37
38
Example:
Control Structure:
• A control statement is a statement that determines whether
other statements will be executed.
• An if statement decides whether to execute
another statement, or decides which of two statements to
execute.
• A loop decides how many times to execute another statement.
• while loops test whether a condition is true before executing
the controlled statement.
• do-while loops test whether a condition is true after executing
controlled statement.
39
40
•The for loops are (typically) used to execute the controlled
statement a given number of times.
•A switch statement decides which of several statements to
execute.
Structural Statements:
• Certain Statements such as END serve to group Simple
statements into structures.
• Following the structured program theorem:
• "Sequence: Ordered statements or subroutines
executed in sequence.
• "Selection: One or a number of statements is
executed depending on the state of the program. This is
usually expressed with keywords such as if..then..else.
41
42
Iteration: a statement or block is executed until the program
reaches a certain state, or operations have been applied to
every element of a collection. This is usually expressed with
keywords such as while, repeat, for or do..until
Recursion: a statement is executed by repeatedly calling itself
until termination conditions are met.
Declaration Statements:
• These statements generally produce no executable
code.
• Their semantic effect is to uniform the compiler about
the attributes of names encountered in the program .
• The compiler implements’ a declaration statement by
storing the attribute information contained therein in
the symbol table and then consulting this information
whenever declared names are used in program.
43
44
•Declaration of a variable serves two purposes: It associates a
type and an identifier (or name) with the variable. The type
allows the compiler to interpret statements correctly.
•Declarations are most commonly used for functions, variables,
constants, and classes, but can also be used for other entities
such as enumerations and type definitions.
Input & Output Statements:
• These statements serve the role as their names .
• In many languages they are implemented by library subroutines
made available by operating system to control input/output
devices.
• It convert data to human readable form.
• In variety of languages we see formats, which are strings of
information about how data is to be interpreted or Expressed
(Read or Write)
45
46
Example:
47

More Related Content

ODP
Introduction to Shell script
PPTX
Shell scripting
PPT
Linux architecture
PDF
PPTX
Software project planning
PPTX
Chapter 2 Time boxing &amp; agile models
PPTX
Lecture 3 threads
PPTX
COMPILER DESIGN OPTIONS
Introduction to Shell script
Shell scripting
Linux architecture
Software project planning
Chapter 2 Time boxing &amp; agile models
Lecture 3 threads
COMPILER DESIGN OPTIONS

What's hot (20)

PDF
Unit 5- Architectural Design in software engineering
PPTX
Recursive Descent Parsing
PPTX
Compiler construction tools
PPTX
Android Architecture.pptx
PPTX
Input-Buffering
PPTX
Virtual machine
PPT
Operating system services 9
PPT
Compiler Design Unit 1
PPTX
Delphi cost estimation model
PPTX
Principle source of optimazation
PPTX
Planning the development process
PPT
Software Process Improvement
PPT
UML Diagrams
PPTX
Estimating Software Maintenance Costs
PPTX
Linkers in compiler
PPTX
Peephole optimization techniques in compiler design
PPTX
Coding and testing in Software Engineering
PPTX
Principal source of optimization in compiler design
PPTX
Linux process management
PPTX
Bash shell scripting
Unit 5- Architectural Design in software engineering
Recursive Descent Parsing
Compiler construction tools
Android Architecture.pptx
Input-Buffering
Virtual machine
Operating system services 9
Compiler Design Unit 1
Delphi cost estimation model
Principle source of optimazation
Planning the development process
Software Process Improvement
UML Diagrams
Estimating Software Maintenance Costs
Linkers in compiler
Peephole optimization techniques in compiler design
Coding and testing in Software Engineering
Principal source of optimization in compiler design
Linux process management
Bash shell scripting
Ad

Viewers also liked (20)

PPTX
Mobile security in Cyber Security
PPTX
Presentation on visual basic 6 (vb6)
PPT
Introduction to visual basic programming
PDF
Developing functional safety systems with arm architecture solutions stroud
 
PPTX
Business intelligence
PPTX
Visual Basic Controls ppt
PPT
Visual basic ppt for tutorials computer
PPTX
Sledeshare. nurith pastran. procesal laboral
PPT
Modern Compiler Design
PPTX
RedHealthAsia 2015
PPTX
Steps when designing a forecast process
ODP
Wordpress Boilerplate Plugin Powered
PPTX
PDF
ELK: a log management framework
PDF
2010: Mobile Security - Intense overview
PPTX
Introduction to ELK
PDF
Log analysis with the elk stack
PPTX
compiler and their types
PDF
ArcherGrey PLM Product Uploader NEW Dashboard & Mobile
PPTX
Elk with Openstack
Mobile security in Cyber Security
Presentation on visual basic 6 (vb6)
Introduction to visual basic programming
Developing functional safety systems with arm architecture solutions stroud
 
Business intelligence
Visual Basic Controls ppt
Visual basic ppt for tutorials computer
Sledeshare. nurith pastran. procesal laboral
Modern Compiler Design
RedHealthAsia 2015
Steps when designing a forecast process
Wordpress Boilerplate Plugin Powered
ELK: a log management framework
2010: Mobile Security - Intense overview
Introduction to ELK
Log analysis with the elk stack
compiler and their types
ArcherGrey PLM Product Uploader NEW Dashboard & Mobile
Elk with Openstack
Ad

Similar to Compiler: Programming Language= Assignments and statements (20)

PPTX
Programming in java basics
PDF
2 EPT 162 Lecture 2
PPT
Introduction to c
PDF
CSC111-Chap_02.pdf
PDF
Embedded C The IoT Academy
PPT
chapter 5.ppt
PPTX
JAVA programming language made easy.pptx
PPSX
Data types, Variables, Expressions & Arithmetic Operators in java
PDF
Control structure repetition Tito Lacbayen
PDF
1) VariableIn programming, a variable is a container (storage area).pdf
PPTX
C Programming Unit-1
PDF
java or oops class not in kerala polytechnic 4rth semester nots j
PPTX
CSE 1201: Structured Programming Language
PPTX
Java fundamentals
PDF
Mit6 087 iap10_lec02
PPTX
comp 122 Chapter 2.pptx,language semantics
PPT
1. overview of c
PDF
C programming day#1
PPTX
OOP Using Java Ch2 all about oop .pptx
PDF
Lecture1.pdf
Programming in java basics
2 EPT 162 Lecture 2
Introduction to c
CSC111-Chap_02.pdf
Embedded C The IoT Academy
chapter 5.ppt
JAVA programming language made easy.pptx
Data types, Variables, Expressions & Arithmetic Operators in java
Control structure repetition Tito Lacbayen
1) VariableIn programming, a variable is a container (storage area).pdf
C Programming Unit-1
java or oops class not in kerala polytechnic 4rth semester nots j
CSE 1201: Structured Programming Language
Java fundamentals
Mit6 087 iap10_lec02
comp 122 Chapter 2.pptx,language semantics
1. overview of c
C programming day#1
OOP Using Java Ch2 all about oop .pptx
Lecture1.pdf

Recently uploaded (20)

PDF
Module 7 guard mounting of security pers
PPTX
Research Process - Research Methods course
DOCX
CLASS XII bbbbbnjhcvfyfhfyfyhPROJECT.docx
PPT
Lessons from Presentation Zen_ how to craft your story visually
PPTX
Sustainable Forest Management ..SFM.pptx
DOCX
Action plan to easily understanding okey
PPTX
ANICK 6 BIRTHDAY....................................................
PDF
public speaking for kids in India - LearnifyU
PDF
Microsoft-365-Administrator-s-Guide_.pdf
PPTX
NORMAN_RESEARCH_PRESENTATION.in education
PPTX
Literatura en Star Wars (Legends y Canon)
PPTX
Phylogeny and disease transmission of Dipteran Fly (ppt).pptx
PPTX
Phylogeny and disease transmission of Dipteran Fly (ppt).pptx
PDF
MODULE 3 BASIC SECURITY DUTIES AND ROLES.pdf
PPTX
Bob Difficult Questions 08 17 2025.pptx
PDF
PM Narendra Modi's speech from Red Fort on 79th Independence Day.pdf
PDF
Presentation on cloud computing and ppt..
PPTX
Module_4_Updated_Presentation CORRUPTION AND GRAFT IN THE PHILIPPINES.pptx
PPTX
CASEWORK Power Point Presentation - pointers
PPTX
Shizophrnia ppt for clinical psychology students of AS
Module 7 guard mounting of security pers
Research Process - Research Methods course
CLASS XII bbbbbnjhcvfyfhfyfyhPROJECT.docx
Lessons from Presentation Zen_ how to craft your story visually
Sustainable Forest Management ..SFM.pptx
Action plan to easily understanding okey
ANICK 6 BIRTHDAY....................................................
public speaking for kids in India - LearnifyU
Microsoft-365-Administrator-s-Guide_.pdf
NORMAN_RESEARCH_PRESENTATION.in education
Literatura en Star Wars (Legends y Canon)
Phylogeny and disease transmission of Dipteran Fly (ppt).pptx
Phylogeny and disease transmission of Dipteran Fly (ppt).pptx
MODULE 3 BASIC SECURITY DUTIES AND ROLES.pdf
Bob Difficult Questions 08 17 2025.pptx
PM Narendra Modi's speech from Red Fort on 79th Independence Day.pdf
Presentation on cloud computing and ppt..
Module_4_Updated_Presentation CORRUPTION AND GRAFT IN THE PHILIPPINES.pptx
CASEWORK Power Point Presentation - pointers
Shizophrnia ppt for clinical psychology students of AS

Compiler: Programming Language= Assignments and statements

  • 1. COMPILERS: PROGRAMMING LANGUAGES ASSIGNMENTS - STATEMENTS. 1 Presentation By: Geo S. Mariyan (Master in Computer Science)
  • 2. Assignment - Introduction • Assignment is to "assign a pre declared variable with some value or by the value of another variable of the same data type. This is done anywhere in body of the program. For E.g. : n=9 or m=5 then, n=5 ! assigns value 5 to n • Initialization is telling compiler to allocate a memory to the initialized variable so that compiler can know that this variable is going to store some value. 2
  • 3. ASSIGNMENT – Symbolic Representation • ASSIGNMENT: The Basic Operation for changing the binding of the value to the data object. • Assignment also returns the value, which is a data object containing the copy of a value assigned. 3
  • 4. Ex : int a; Initializing 'a' as of type int Assignment means proving a particular value to any variable. Ex: int a=2; a in assigned a value to 2. This is purely assignment and assignment can be done n no. of times in a program. There is no such restriction on it. Assignment throws away the old value of a variable and replacing it with a new one. It can be done anywhere in the whole program. 4
  • 5. l- and r- values • An lvalue can appear on the left side of an assignment operator, whereas an rvalue can appear on the right side. • "lvalue" and "rvalue" are so named because of where each of them can appear in an assignment operation. • ex: int a, b; • a = 4; • b = a; • In the third line of that example, "b" is the lvalue, and "a" is the rvalue, whereas it was the lvalue in line. • This illustrates an important point: An lvalue can also be an rvalue. 5
  • 6. Assignment Operators • An assignment operator is the operator used to assign a new value to a variable, property, event or indexer element. • Assignment operators can also be used for logical operations such as bitwise logical operations or operations on integral operands and Boolean operands. • Unlike in C++, assignment operators in C# cannot be overloaded directly, but the user-defined types can overload the operators like +, -, /, etc. This allows the assignment operator to be used with those types. 6
  • 7. Characteristics of Assignment Operators: • The different assignment operators are based on the type of operation performed between two operands such as addition (+=), subtraction, (-=), etc. The meaning of the operator symbol used depends on the type of the operands. • Assignment operators are right-associative, which means they are grouped from right to left. • Although assignment using assignment operator (a += b) achieves the same result as that without ( =a +b), the difference between the two ways is that unlike in the latter example, "a" is evaluated only once. 7
  • 8. Practice with Assignment Operators The assignment operator expects the type of both the left- and right-hand side to be the same for successful assignment. Example: i += 24 i *= x 8
  • 9. Variant forms of Assignment •Augmented Assignment •Chained Assignment •Parallel Assignment 9
  • 10. • Augmented assignment: The case where the assigned value depends on a previous one is so common that many imperative languages, most notably C and the majority of its descendants, provide special operators called Augmented assignment ex: *=, so a = 2*a can instead be written as a *= 2 • Chained assignment: A statement like w = x = y = z is called a chained assignment in which the value of z is assigned to multiple variables w, x, and y. Chained assignments are often used to initialize multiple variables, as in •example: a = b = c = d = f = 0 10
  • 11. Parallel Assignment: Some programming languages, such as Go, JavaScript (since, Maple, Perl, Python, REBOL, Ruby, and Windows Power Shell allow several variables to be assigned in parallel, with syntax like: ex: a, b := 0, 1 which simultaneously assigns 0 to a and 1 to b. This is most often known as parallel assignment. 11
  • 12. Assignment statements • Once a variable is declared, it can be assigned values multiple times in a program; for example: int num; // num declared, uninitialized num = 3; // num assigned 3 num = num + 1; // num assigned 3 + 1 (4) num = 15 / num; // num assigned 15 / 4 12
  • 13. Implementation of Assignment: • Compiler can implement the assignment A := B • The Compiler generates code to compute the r-value and B into some register r-value of B into some register r • If the data types of A and B are incompatible, the compiler generates code to convert the r-value of B to a type appropriate for A. • If necessary, the compiler generates the code to determine the l-value of A. (if A is in primitive type , no code is needed) • Finally, the compiler generates code to store the contents of register r into the l-values of A. 13
  • 14. Assignment compatibility • When a variable is declared, the data type in the declaration indicates the nature of the values the variable is capable of storing. • For example, an int variable can store a whole number, a char variable can store a character, and a double variable can store a real number. • The value assigned to the variable must be compatible with its data type. 14
  • 15. •Java is a strongly-typed language. •This means that, for the most part, you can only assign a value of a particular data type to a variable of the same type •Some examples: int x = -2; // this is fine; -2 is an integer char c = ‘2’; // this is OK also x = 2.5; // syntax error: 2.5 is a double value, not an int c = 2; // also an error; 2 is an int value, not a char 15
  • 16. Assignment Statement Variety: = FORTRAN, C, C++, Java = Can be bad if it is overloaded for the relational operator for equality. • Example C: a=b=c • In the C statement A = B = C, the value of C is assigned to B, and the value of B is assigned to A. 16
  • 17. Statements: Definition : A statement in programming context is a single complete programming instruction that is written as code. The Elementary action of evaluation, assignment and control of evaluation orders are specified by the statements of the programming language . Statements can have diverse forms and languages. 17
  • 18. Function Call Statement •Certain function calls, such as the MESSAGE function, can be a statement on their own. They are known as function call statements • 18
  • 19. The Statement Separator A single programming statement may span several code lines; one code line may consist of multiple statements. Therefore, the C compiler must be able to detect when one statement ends and another statement begins. [ <statement> { ; <statement> } ] Example : Integer Num:=10; 19
  • 20. Assignment Statement In computer programming, an assignment statement sets and/or re-sets the value stored in the storage location(s) denoted by a variable name; in other words, it copies a value into the variable. In most imperative programming languages, the assignment statement (or expression) is a fundamental construct. The syntax of an assignment statement is almost as easy as the syntax of the function call statement. The syntax is as follows: <variable> := <expression> 20
  • 21. Assignment Statement • Assignment statements can be in the following two forms 1) x := op y 2) x := y op z • First statement op is a unary operation. Essential unary operations are unary logical negation, shift operators and conversion operators. • Second statement op is a binary arithmetic or logical operator. 21
  • 22. Assignment Operator • An assignment operator is the operator used to assign a new value to a variable, property, event or indexer element in C# programming language. • Assignment operators can also be used for logical operations such as bitwise logical operations or operations on integral operands and Boolean operands. • The “colon equals” (:=) is known as the assignment operator. You use it to assign a value or an expression that evaluates to a value to a variable. • := 22
  • 23. Jump Statements • The jump statements are the goto statement, the continue statement, the break statement, and the return statement. • The source statement like if and while-do cause jump in the control flow through three address code so any statement in three address code can be given label to make it the target of a jump. 23
  • 24. Indexed Assignment • Indexed assignment of the form A:=B[I] and A[I]:=B. the first statement sets A to the value in the location I memory units beyond location B. • In the later statement A [I]:=B, sets the location I units beyond A to the value of B. • In Both instructions A, B, and I are assumed to refer data objects and will represented by pointers to the symbol table. 24
  • 25. Address and Pointer Assignment • Address and pointer assignment x := &y x := *y *x := y • First statement, sets the value of x to be the location of y. • In x := *y, here y is a pointer or temporary whose r-value is a location. The r-value of x is made equal to the contents of that location. • *x := y sets the r-value of the object pointed to by a to the r-value of y. 25
  • 26. Assignment Operations • Most basic statements for initializing variables • General syntax: • variable = expression; • Example: • length = 25; • Expression • Any combination of constants and variables that can be evaluated to yield a result 26
  • 27. •All variables used in an expression must previously have been given valid values. •Must be a variable listed immediately to the left of the equal sign. •Has lower precedence than any other arithmetic operator. 27
  • 28. Assignment Statements: Compound Operators •A shorthand method of specifying a commonly needed form of assignment. •Introduced in ALGOL; adopted by C Example: a = a + b is written as a += b •Unary assignment operators in C-based languages combine increment and decrement operations with assignment. 28
  • 29. Examples: • sum = ++count (count incremented, then assigned to sum) • sum = count++ (count assigned to sum, then incremented) • count++ (count incremented) • -count++ (count incremented then negated) 29
  • 30. Assignment as an Expression • In C, C++, and Java, the assignment statement produces a result and can be used as operands • An example: while ((ch=getchar())!= EndOfFile){…} ch = getchar() is carried out; the result (assigned to ch) is used as a conditional value for the while statement 30
  • 31. Simple and Compound Statements • Simple Statement: A Simple statement is one which does not contain any augmented statement. • Read, Assignment and goto are the three examples of simple statements. • In certain languages, a program may be regarded as a sequence of simple statements. (e.g., BASIC, SNOBOL) • Compound Statement: A Compound Statement is one that may contain one or more embedded statements. • The logical IF in FORTRAN • IF (condition) statement 31
  • 32. Compound statements: The Compound Statement enable computation that logically belong together and be grouped together syntactically. • This ability of grouping together helps make program readable. Example of Compound statement: 1. If condition then statement 2. If condition then statement else statement 3. While condition do statement 32
  • 33. Explanation: • The if-then and if-then-else statements allows all actions that apply for the value of condition to be grouped together. • The compound statements permits the sequence of the statements to be used wherever one may appear. • The while statements is to establish the loops with arbitrary loop control conditions. • In compound statement in other languages the syntax may be widely different. •Note*: The test for the condition is performed before the statements allowing the loops to be executed zero times if necessary. 33
  • 34. Types of Statements 1. Conditional Statements. 2. Sequential Statements. 3. Control Statements. 4.Structural Statements. 5. Declaration Statements. 6.Input Statements. 7. Output Statements. 34
  • 35. Conditional Statements: • In Conditional statements are features of a programming language, which perform different computations or actions depending on whether a programmer specified boolean condition evaluates to true or false. 35
  • 36. 36 Conditional statement is a set of rules performed if a certain condition is met. Below are some examples of conditional statements in programming. this last example will print if it is greater than 10, less than 10 or equal to 10.
  • 37. Sequential Statement: • In most languages , control automatically flows from one statement to the next. • Certain statements such as goto, break, call and return deliberately alter the flow of control. • There has been considerable debate as to what statements are best suited for creating easy to understand flow-of- control patterns in programs. • The Sequential statement has been the focus and it permits the arbitrary flow-of-control patterns, including those that are difficult to comprehend. 37
  • 39. Control Structure: • A control statement is a statement that determines whether other statements will be executed. • An if statement decides whether to execute another statement, or decides which of two statements to execute. • A loop decides how many times to execute another statement. • while loops test whether a condition is true before executing the controlled statement. • do-while loops test whether a condition is true after executing controlled statement. 39
  • 40. 40 •The for loops are (typically) used to execute the controlled statement a given number of times. •A switch statement decides which of several statements to execute.
  • 41. Structural Statements: • Certain Statements such as END serve to group Simple statements into structures. • Following the structured program theorem: • "Sequence: Ordered statements or subroutines executed in sequence. • "Selection: One or a number of statements is executed depending on the state of the program. This is usually expressed with keywords such as if..then..else. 41
  • 42. 42 Iteration: a statement or block is executed until the program reaches a certain state, or operations have been applied to every element of a collection. This is usually expressed with keywords such as while, repeat, for or do..until Recursion: a statement is executed by repeatedly calling itself until termination conditions are met.
  • 43. Declaration Statements: • These statements generally produce no executable code. • Their semantic effect is to uniform the compiler about the attributes of names encountered in the program . • The compiler implements’ a declaration statement by storing the attribute information contained therein in the symbol table and then consulting this information whenever declared names are used in program. 43
  • 44. 44 •Declaration of a variable serves two purposes: It associates a type and an identifier (or name) with the variable. The type allows the compiler to interpret statements correctly. •Declarations are most commonly used for functions, variables, constants, and classes, but can also be used for other entities such as enumerations and type definitions.
  • 45. Input & Output Statements: • These statements serve the role as their names . • In many languages they are implemented by library subroutines made available by operating system to control input/output devices. • It convert data to human readable form. • In variety of languages we see formats, which are strings of information about how data is to be interpreted or Expressed (Read or Write) 45
  • 47. 47

Editor's Notes

  • #14: Primitive types are the most basic data types available within the Java language. There are 8: boolean , byte , char , short , int , long , float and double .
  • #22: The unary operators operate on a single operand and following are the examples of Unary operators: The increment (++) and decrement (--) operators. The unaryminus (-) operator.  Binary operators are Boolean expression such as Boolean Operators are simple words (AND, OR, NOT or AND NOT) used as conjunctions to combine or exclude keywords.
  • #30: Increment means adding by 1 if it counts by 1.
  • #32: An augmented is generally used to replace a statement where an operator takes a variable as one of its arguments and then assigns the result back to the same variable. A simple example is x += 1 which is expanded to x = x + 1