Home / CSE MCQs / C#.Net MCQs :: Discussion

Discussion :: C#.Net MCQs

  1. 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();
      }
  2. A.
    loop is printed infinite times
    B.
    loop
    C.
    loop loop
    D.
    Compile time error

    View Answer

    Workspace

    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