0
0
C Sharp (C#)programming~10 mins

Continue statement behavior in C Sharp (C#) - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to skip printing the number 3 using continue.

C Sharp (C#)
for (int i = 1; i <= 5; i++) {
    if (i == [1]) {
        continue;
    }
    Console.WriteLine(i);
}
Drag options to blanks, or click blank then click option'
A3
B5
C1
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number other than 3 will skip the wrong iteration.
Forgetting to use continue inside the if block.
2fill in blank
medium

Complete the code to skip even numbers using continue.

C Sharp (C#)
for (int i = 1; i <= 6; i++) {
    if (i % 2 == [1]) {
        continue;
    }
    Console.WriteLine(i);
}
Drag options to blanks, or click blank then click option'
A0
B1
C2
D3
Attempts:
3 left
💡 Hint
Common Mistakes
Using 1 instead of 0 will skip odd numbers instead.
Forgetting that modulus operator returns remainder.
3fill in blank
hard

Fix the error in the loop to correctly skip negative numbers using continue.

C Sharp (C#)
int[] numbers = { 2, -1, 3, -4, 5 };
foreach (int num in numbers) {
    if (num [1] 0) {
        continue;
    }
    Console.WriteLine(num);
}
Drag options to blanks, or click blank then click option'
A>
B<
C>=
D==
Attempts:
3 left
💡 Hint
Common Mistakes
Using > instead of < will skip positive numbers.
Using == 0 will skip zeros, not negatives.
4fill in blank
hard

Fill both blanks to skip numbers divisible by 3 and print the rest.

C Sharp (C#)
for (int i = 1; i <= 9; i++) {
    if (i [1] 3 == [2]) {
        continue;
    }
    Console.WriteLine(i);
}
Drag options to blanks, or click blank then click option'
A%
B0
C==
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using != instead of == will skip numbers not divisible by 3.
Using wrong operator instead of modulus.
5fill in blank
hard

Fill all three blanks to skip numbers less than 4 or greater than 7.

C Sharp (C#)
for (int i = 1; i <= 10; i++) {
    if (i [1] 4 [2] i [3] 7) {
        continue;
    }
    Console.WriteLine(i);
}
Drag options to blanks, or click blank then click option'
A<
B>
C||
D&&
Attempts:
3 left
💡 Hint
Common Mistakes
Using && instead of || will skip numbers outside the range incorrectly.
Mixing up < and > operators.