This document discusses the for loop in programming. It explains that a for loop allows performing the same set of instructions repeatedly until a condition is met. The general form of a for loop is presented as "for(expression1; expression2; expression3)" where expression1 initializes the counter variable, expression2 defines the condition to continue looping, and expression3 alters the counter variable. Nesting of for loops and multiple assignments within a for loop are also described.
Automating Google Workspace (GWS) & more with Apps Script
PRESENTATION ON FOR LOOP
1.
2. FOR LOOP
PRESENTED BY:
FAROOQ MUSTAFA JOYIA
(169-FET/BSME/F11-B)
DEPARTEMENT OF MECHANICAL ENGINEERING
FACULTY OF ENGINEERING AND TECHNOLOGY
INTERNATIONAL ISLAMIC UNIVERSITY ISLAMABAD
3. AGENDA
WHAT IS LOOPING?
GENERAL FORM OF FOR LOOP
DESCRIPTION OF GENERAL FORM
EXECUTION
NESTING THE LOOP
MULTIPLE ASSIGNMENTS IN FOR
LOOP
NULL STATEMENT
4. WHAT IS LOOPING?
LOOPING, also called iteration, is
used in programming to perform the
same set of instructions over and
over until certain specified conditions
are satisfied.
Here we will discuss about for loop
5. GENERAL FORM
General form of for statement is
for(expression1;expression2;expression3)
{
Statement1;
Statement2;
.
.
.
}
6. EXPRESSION 1
Thisis some kind of
expression which initializes the
control variable. This
statement is only carried out
once before the starting of for
loop.
7. EXPRESSION 2
Thisexpression is evaluated at
the beginning of for loop and
the loop is only carried out
when this expression is true.
8. EXPRESSION 3
This is some kind of
expression for altering the
value of control variable.
e.g. i++
9. EXECUTION OF FOR LOOP
When the loop is started
normally a control variable is
initialized by executing.
Expression_2 is tested if it is
false then control is
transferred outside the loop
otherwise do next step_3.
Body of loop is executed.
Value of control is altered by
expression 3.
Step 2 and 4 are repeated
until condition becomes false.
10. NESTING THE LOOPS
When a for loop is
completely
embedded within
for loop, the
structure is called
nested for loop.
11. Inner for loop must finish
first than outer loop must
start another iteration, if
the specified condition is
still met.
12. MULTIPLE ASSIGNMENTS IN
FOR LOOP
We can use more than one
initialization statement &more
than one increment decrement
statement. However only one
condition is allowed within a for
loop.
14. NULL STATEMENT
The for statement does not end with a
semicolon.
The for statement has within it either a
statement block that ends with the closing
brace or a single statement that ends with
a semicolon.