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

Continue statement behavior in C Sharp (C#) - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Continue Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of loop with continue inside if
What is the output of this C# code snippet?
C Sharp (C#)
for (int i = 0; i < 5; i++)
{
    if (i == 2) continue;
    Console.Write(i + " ");
}
A0 1 2 3 4
B0 1 3 4
C2 3 4
D0 1 2 4
Attempts:
2 left
💡 Hint
The continue statement skips the rest of the current loop iteration when i equals 2.
Predict Output
intermediate
2:00remaining
Continue in nested loops
What will be printed by this C# code?
C Sharp (C#)
for (int i = 0; i < 3; i++)
{
    for (int j = 0; j < 3; j++)
    {
        if (j == 1) continue;
        Console.Write($"{i}{j} ");
    }
}
A01 11 21
B00 01 02 10 11 12 20 21 22
C00 02 10 12 20 22
D00 10 20
Attempts:
2 left
💡 Hint
The continue skips printing when j equals 1 inside the inner loop.
Predict Output
advanced
2:00remaining
Continue with while loop and increment
What is the output of this C# code?
C Sharp (C#)
int i = 0;
while (i < 5)
{
    i++;
    if (i == 3) continue;
    Console.Write(i + " ");
}
A1 2 4 5
B0 1 2 4 5
C1 2 3 4 5
D1 2 3 5
Attempts:
2 left
💡 Hint
The increment happens before the continue check.
Predict Output
advanced
2:00remaining
Continue inside foreach loop
What will this C# code print?
C Sharp (C#)
string[] words = {"apple", "banana", "cherry"};
foreach (var word in words)
{
    if (word.StartsWith("b")) continue;
    Console.Write(word + " ");
}
Aapple cherry
Bcherry
Capple banana cherry
Dbanana cherry
Attempts:
2 left
💡 Hint
Continue skips words starting with 'b'.
Predict Output
expert
3:00remaining
Continue with multiple conditions in for loop
What is the output of this C# code snippet?
C Sharp (C#)
for (int i = 0; i < 6; i++)
{
    if (i % 2 == 0) continue;
    if (i == 5) continue;
    Console.Write(i + " ");
}
A1 3 5 6
B1 3 5
C0 2 4
D1 3
Attempts:
2 left
💡 Hint
Continue skips even numbers and also skips 5.