Page 68 - CTS - CSA TP - Volume 2
P. 68
COMPUTER SOFTWARE APPLICATION - CITS
TASK 2: Using continue in a Loop
public class ContinueExample {
public static void main(String[] args) {
// This program prints even numbers in a loop, skipping odd numbers
// Print even numbers in a loop
for (int i = 1; i <= 10; i++) {
if (i % 2 != 0) {
// Skip odd numbers and continue to the next iteration
continue;
}
System.out.println(“Even number: “ + i);
}
}
}
Output:
53
CITS : IT & ITES - Computer Software Application - Exercise 89