0% found this document useful (0 votes)
13 views31 pages

Ict 03 Voyager

The document discusses control flow statements in programming, which dictate the order of instruction execution, including jump statements like 'break' and 'continue'. It explains how these statements can alter the flow of loops and provides examples of their usage in Java. Additionally, it covers arrays, detailing their structure, advantages, and types, including single-dimensional and multidimensional arrays.
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)
13 views31 pages

Ict 03 Voyager

The document discusses control flow statements in programming, which dictate the order of instruction execution, including jump statements like 'break' and 'continue'. It explains how these statements can alter the flow of loops and provides examples of their usage in Java. Additionally, it covers arrays, detailing their structure, advantages, and types, including single-dimensional and multidimensional arrays.
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/ 31

Control Flow

Statements and
Arrays
GROUP 03
What is a control flow
statement
• Control flow refers to the order in
which the instructions of a
program are executed. It
determines how a program moves
from one statement to another,
Control Flow Statement
• Control flow statements are fundamental
components of programming languages
that allow developers to control the order in
which a program's instructions are
executed. They enable developers to:
• Execute a block of code multiple times
Jump Statements

• Jumping statements are


control statements that
transfer execution control
from one point to another
Jump Statements

• Jumping statements are


control statements that
transfer execution control
from one point to another
Types of Jump
Statements
• Break Statement
• Continue Statement
Break Statement
• The flowchart of a break statement starts with
the condition check of the loop. If the condition
is true, the loop body is executed, and then the
condition is checked again. If the condition
becomes false, the loop is exited normally, and
the program continues with the statement after
the loop.

• However, if a break statement is encountered


inside the loop body, the control jumps to the
statement immediately after the loop, bypassing
Flowchart of Break Statement
Break Statement
• The `break` statement in Java is a powerful tool
for controlling the flow of your program. It is
used to exit a loop or switch statement
prematurely. It allows us to customize the
behavior of code based on specific conditions.

• When a break statement is encountered inside a


loop, the loop is immediately terminated and
the program control resumes at the next
statement following the loop.
• For example, consider a situation if we are
searching for a specific value in an array using a
for loop. We can use the break statement to exit
the loop as soon as we find the value, like this:
Use Break Statement
o We can use Java break statement in
all types of loops such as
• For loop,
• while loop and
• do-while loop.

o Syntax:
break;
Use Break Statement
o We can use Java break statement in
all types of loops such as
• For loop,
• while loop and
• do-while loop.

o Syntax:
break;
Break Statement with Loop
break Statement with while loop
Break Statement with do-while
loop
Break Statement with Inner Loop
• It breaks inner loop only if you use
break statement inside the inner
loop.
Continue Statement
• The continue statement is used in loop control
structure when you need to jump to the next iteration
of the loop immediately. It can be used with for loop
or while loop.

• The Java continue statement is used to continue the


loop. It continues the current flow of the program and
skips the remaining code at the specified condition. In
case of an inner loop, it continues the inner loop only.

• We can use Java continue statement in all types of


loops such as for loop, while loop and do-while loop.
Continue Statement Flowchart
Continue Statement Example
Continue Statement in while loop
Continue Statement in do-while
loop
Continue Statement with Inner
Loop
• It continues inner loop only if you
use the continue statement inside
the inner loop.
Array
• An array is typically a grouping of
elements of the same kind that are
stored in a single, contiguous block
of memory.
• Array is an object which contains
elements of a similar data type.
Additionally, The elements of an
array are stored in a contiguous
• Array is index-based, the first
element of the array is stored at the
0th index, 2nd element is stored on
1st index and so on.
Advantages and disadvantages
• Advantages
- Code Optimization: It makes the
code optimized, we can retrieve
or sort the data efficiently.
- Random access: We can get any
data located at an index
position.
• Disadvantages
Types of Array

• Single
Dimensional
Array
Single-Dimensional Array
• A single-dimensional array in Java is
a linear collection of elements of the
same data type. It is declared and
instantiated using the following
syntax:
Single-Dimensional Array
Multidimensional Array
• A multidimensional array in Java is
an array of arrays where each
element can be an array itself. It is
useful for storing data in row and
column format.
• Syntax to Declare Multidimensional
Array in Java
Multidimensional Array example
Thank
you!
10 VOYAGER

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy