0% found this document useful (0 votes)
42 views40 pages

ComProg Q3 For Loop

The document discusses programming constructs, specifically focusing on loops, which are sequences of instructions repeated until a condition is met. It details the FOR loop, including its syntax and when to use it, emphasizing its utility for known iteration counts. Additionally, it provides examples of tasks that can be accomplished using FOR loops, such as generating specific numerical patterns.

Uploaded by

wb9w66zw95
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)
42 views40 pages

ComProg Q3 For Loop

The document discusses programming constructs, specifically focusing on loops, which are sequences of instructions repeated until a condition is met. It details the FOR loop, including its syntax and when to use it, emphasizing its utility for known iteration counts. Additionally, it provides examples of tasks that can be accomplished using FOR loops, such as generating specific numerical patterns.

Uploaded by

wb9w66zw95
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

PROGRAMMING CONSTRUCTS

OR FLOW OF
INSTRUCTIONS
SEQUENCE
DECISION
ITERATION
TECHNOLOGY AND
LIVELIHOOD
EDUCATION

8
LOOP

GERARDO M. ROXAS
COMPUTER SCIENCE TEACHER
LOOP

a loop is a sequence of instructions that is


continually repeated until a certain condition
is reached.
LOOP
STATEMENTS
• FOR LOOP
• WHILE LOOP
• DO/WHILE LOOP
TECHNOLOGY AND
LIVELIHOOD
EDUCATION

8
FOR LOOP

GERARDO M. ROXAS
COMPUTER SCIENCE TEACHER
FOR LOOP

Use FOR LOOP when you know exactly how


many times you want to loop through
a block of code
FOR LOOP SYNTAX
SYNTAX OF FOR LOOP

for (statement 1; statement 2; statement 3) {


// code block to be executed
}
Statement 1 is executed (one time)
before the execution of the code block.
Statement 2 defines the condition for
executing the code block.
Statement 3 is executed (every time)
after the code block has been
executed.
Statement 1 sets a variable before the loop starts
Statement 2 defines the condition for the
loop to run (x must be less than 5).
If the condition is true, the loop will start over
again, if it is false, the loop will end.
Statement 3 increases a value (x++) each time
the code block in the loop has been executed.
What applications you have
encountered with application of
FOR Loop or with repetitive tasks?
How to use FOR Loop statement in
a computer program?
Create a For Loop program that
will print
the pattern 1, 2, 4, 8, 16, 32
and 64
Create a program that will print the
following pattern
Number 20
Number 18
Number 16
… up to
Number 0

You might also like