Professional Documents
Culture Documents
BY
GARIMA V.PANCHBHAI
Control flow
( ordering in program execution )
• Determines what shoulbe done first,what
second and so forth.
• Language Constructs can be arranged in 7 main
categories
• Sequencing
• Selection
• Iteration
• Procedural abstraction
• Recursion
• Concurrency
• Non determinacy
Expression Evaluation
• An expression generally consist of either a simple object or
function applied to collection of operands or arguments
each of which in turn is an expression .
• In general a language may specify that function call(operator
invocation) employ prefix,infix & postfix.
• Most languages use infix notation for built in operators.
• LISPS uses prefix noation for all functions
(+ 2 (/ 9 x)).
Precedence and Associativity:
Operator Precedence:
• specifies that certain operator, in the absence of parentheses,
group “more tightly” than other operators
Operator Associativity:
• Associativity rules specify that sequence of operators of equal
precedence group to the right or to the left.
• specifies the evaluation order of operators ofthe same
precedence
Left Associativity:
operators are evaluated left-to-right
Right Associativity:
operators are evaluated right-to-left
(Fortran power operator **, C assignment
operator = and unary minus)
No Associativity:
parentheses must be used to specify grouping
(ADA)
Assignments :
• In an imperative language
• Computations consists of an ordered series of changes to the
values of variables in memory.
• Each assignment takes pair of arguments a value and a reference.
• In Functional Language :
Statement block
• groups multiple statements together
Examples
• { } in C, C++, and Java
• begin/end in Algol, Pascal, and Modula
Basic block
• block where the only control flow allowed is
sequencing
Selection :
• In most imperative languages, selection is
implemented using variant of if.. .Then….else…
• Logically-Controlled Loop
• Execute until some boolean condition
• Depends on value altered in the loop
Enumeration controlled Loop:
• Is executed once for every value in a given finite
set.
• The number of iterations are known before the
execution of the loop.
• Eg. In Fortran
do 10 i=1, 10, 2
…..
10: continue
The number after do is a label, indicates the last
statement in the body of the loop.
Continue is like “no-op”.
Recursion :
• Requires no special syntax.
• Permits functions to call itself.
• Mostly used in functional languages.
• Decompose problem into smaller problems by
calling itself
• Some languages don’t permit recursion: Fortran
77
Tracing a Recursive Function