The following table is a set of statements and keywords that can be used in the script.
Type | Description |
| The |
| Statements for loop processes. |
| The |
| A |
| Executing different processes based on different conditions. |
| Terminates execution of the current iteration in a loop and then execute the next iteration in a loop. |
| Terminates the execution of a loop entirely. |
| Ends function execution and specifies a value to be returned to the function caller. |
|
|
Example for if
…else
:
if (A == 1) {
//run this instruction if A is equal to 1.
...
//run this instruction if A does not equal 1 or 2.
}
Example for
...
while
:
A = 0;
while (A < 10) {
A = A + 1;
...
In this example, 0 is set as the initial value for variable A
. While A
is less than 10,
...
continue to add 1 to A
until A
...
is equal to 10. Once A
is equal to 10,
...
the while
loop will end.
...
}
A = 0;
...
while (
...
A < 10)
...
{
// Write the program that will be repeated.
// while the WHILE keyword’s condition is True.
// This example will be repeated 10 times.
A = A + 1;
}
The subordinate statements will never be executed if the conditions for the WHILE statement are not true. If you use a DO-WHILE statement, the loop statement will be executed at least once. After the first execution, the system will check the condition within the WHILE statement.
Do {
// Write the loop statement when the condition is True.
// The loop statement will be executed once at least.
...
Example for do
...while
:
In this example, 0 is set as the initial value for variable A
. The do
statement will first get executed and will continue to add 1 to A
until A
is equal to 10. Once A
is equal to 10, the do
...while
loop will end.
A = 0;
do {
A = A + 1;
} while (A < 10);
(3) FOR Statement
In this statement, all expressions for the initialization, the decision-making, and the post-loop process are described in a single statement line.
...