Home »
MCQs »
C# MCQs
What will be the output of the following C# code? | Question 10
44. What will be the output of the following C# code?
using System;
class Program {
static void Main(string[] args) {
int i = 100;
do {
Console.Write(i + " ");
++i;
} while (i <= 50);
}
}
- Error
- 100 101 102 ... Infinite
- 101
- 100
Answer: D) 100
Explanation:
The do-while loop is an exit control loop where the condition is checked after executing the loop body. In the above code, the condition is false still loop body will be executed first. Thus, the output will be 100.