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

For loop execution model in C Sharp (C#) - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
For Loop Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of a simple for loop with increment
What is the output of the following C# code?
C Sharp (C#)
for (int i = 0; i < 3; i++)
{
    Console.Write(i);
}
A012
B123
C321
D0 1 2
Attempts:
2 left
💡 Hint
Remember the loop starts at 0 and runs while i is less than 3.
Predict Output
intermediate
2:00remaining
For loop with break statement output
What will be printed by this C# code?
C Sharp (C#)
for (int i = 0; i < 5; i++)
{
    if (i == 3) break;
    Console.Write(i);
}
A012
B01234
C0123
D345
Attempts:
2 left
💡 Hint
The loop stops when i equals 3.
Predict Output
advanced
2:00remaining
For loop with multiple variables and complex condition
What is the output of this C# code snippet?
C Sharp (C#)
for (int i = 0, j = 5; i < j; i++, j--)
{
    Console.Write(i + j);
}
A1010
B57
C59
D555
Attempts:
2 left
💡 Hint
Add i and j each loop iteration and print the sum.
Predict Output
advanced
2:00remaining
For loop with continue statement effect
What will be the output of this C# code?
C Sharp (C#)
for (int i = 0; i < 5; i++)
{
    if (i % 2 == 0) continue;
    Console.Write(i);
}
A1357
B135
C13
D24
Attempts:
2 left
💡 Hint
The continue skips even numbers.
🧠 Conceptual
expert
2:00remaining
Number of iterations in nested for loops
How many times will the innermost statement execute in this nested loop?
C Sharp (C#)
for (int i = 1; i <= 3; i++)
{
    for (int j = i; j <= 3; j++)
    {
        Console.WriteLine(i * j);
    }
}
A12
B6
C3
D9
Attempts:
2 left
💡 Hint
Count how many times the inner loop runs for each i.