πŸ“Š JAVA
Q. What is the output of the following code?
Code:
for (int i = 1; i <= 10; i++) {
if (i % 2 == 0) {
continue;
}
System.out.println(i);
}
  • (A) 1 3 5 7 9
  • (B) 2 4 6 8 10
  • (C) 1 2 3 4 5 6 7 8 9 10
  • (D) There is a syntax error in the code.
πŸ’¬ Discuss
βœ… Correct Answer: (A) 1 3 5 7 9

Explanation: The for loop iterates from 1 to 10, skipping any even numbers using the continue statement. The odd numbers are printed to the console.

Explanation by: Deepak Sahoo
The for loop iterates from 1 to 10, skipping any even numbers using the continue statement. The odd numbers are printed to the console.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
196
Total Visits
πŸ“½οΈ
3 y ago
Published
πŸŽ–οΈ
Deepak Sahoo
Publisher
πŸ“ˆ
86%
Success Rate