2024 08 17 LoopingBranching
2024 08 17 LoopingBranching
DEFINITION
DEFINITION
DEFINITION
DEFINITION
DECISION MAKING
DECISION MAKING
IF STATEMENT
if (condition)
{
Statement(s);
}
IF STATEMENT
IF STATEMENT
IF STATEMENT
IF ELSE STATEMENT
if (condition) {
Statement(s);
} else {
Statement(s);
}
The statements inside “if” would execute if the condition
is true, and the statements inside “else” would execute if the
condition is false
NESTED IF STATEMENT
if (condition_1) {
Statement1(s);
if (condition_2) {
Statement2(s);
}
}
NESTED IF
NESTED IF STATEMENT
NESTED IF
SWITCH CASE
STATEMENT
SWITCH STATEMENT
SWITCH CASE
STATEMENT
o While Loop
o Do-While Loop
o For Loop
LOOPING STATEMENTS
While LOOPING
STATEMENTS
while (Boolean
condition) {
loop statements...
}
WHILE LOOP
While LOOPING
STATEMENTS
WHILE LOOP
DO WHILE LOOPING
STATEMENTS
do {
statements..
}
while (condition);
DO-WHILE LOOP
DO WHILE LOOPING
STATEMENTS
o do while loop starts with the execution of the statement(s).
There is no checking of any condition for the first time.
DO-WHILE LOOP
FOR LOOPING STATEMENTS
FOR -LOOP
DEFINITION
o Initialization condition
o Testing Condition:
DEFINITION
DEFINITION
o Statement execution:
DEFINITION
BREAK STATEMENT
o The break command terminates only the current loop and not any
enclosing loops.
CONTINUE
CONTINUE
QUESTION: 01
Input :
Output:
1
2*2
3*3*3
3*3*3
2*2
1 QUESTION:02