Professional Documents
Culture Documents
Unit 1-Chapter 4 - Control Structures
Unit 1-Chapter 4 - Control Structures
Unit 1 / Chapter 4
3. Jump Statement
break, continue and return
VIJAY KUMAR AS, ASST. PROF. SIMS, BANGLORE
1. SIMPLE IF STATEMENT
Syntax:
if(expression)
statement;
Syntax:
if(expression)
statement1;
else
statement2;
VIJAY KUMAR AS, ASST. PROF. SIMS, BANGLORE
3. IF NESTED STATEMENT
Syntax:
if(expression1) {
if(expression2)
statement1;
else
Switch(expression)
{
case value1: // expression 1
break;
case value2: // expression 2
break;
………………………
default : //do default function
do
{
// Loop Body
Update_expression;
} while (test_expression); // Condition check
}
VIJAY KUMAR AS, ASST. PROF. SIMS, BANGLORE
VIJAY KUMAR AS, ASST. PROF. SIMS, BANGLORE
VIJAY KUMAR AS, ASST. PROF. SIMS, BANGLORE
9. THE ENHANCED FOR LOOP
Here, you do not have the option to skip any element because it does not
work on an index basis.
In the case of for loop, the continue keyword force control to jump immediately to the
update statement.
Whereas in the case of a while loop or do-while loop, control immediately jumps to the
Boolean expression.
Syntax: continue;
To label a loop, place the label before the loop with a colon at the end. Therefore, a loop
with the label is called a labeled loop.