Discussion :: C#.Net MCQs
-
Select the output for the following set of code : static void Main(string[] args){int i = 0, j = 0;l1: while (i < 2){i++;while (j < 3){Console.WriteLine("loop\n");goto l1;}}Console.ReadLine();}
Answer : Option C
Explanation :
Since outer while loop i.e while(i<2) executes only for two times.Hence,loop while executing third time for (j<3) could not be able to satisfy condition i<2 as i = 2.hence,loop breaks and control goes out of loop. Output : loop loop.
Be The First To Comment