What will be the output of the following C# code?

static void Main(string[] args)
 {
     int i;
     Console.WriteLine("enter value of i:");
     i = Convert.ToInt32(Console.ReadLine());
     if (i < 7)
     {
         i++;
         continue;
     }
     Console.WriteLine("final value of i:" +i);
     Console.ReadLine();
 }

a) 12
b) 11
c) Compile time error
d) 13

1 thought on “What will be the output of the following C# code?”

  1. c
    Explanation: ‘Continue’ loop cannot be used within ‘if’ loop. replace while with if(i <7).
    Output: Compile time error.

Leave a Comment