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

static void Main(string[] args)
{
    int x;
    for (x = 10; x <= 15; x++)
    while (Convert.ToBoolean(Convert.ToInt32(x)))
    {
        do
        {
            Console.WriteLine(1);
            if (Convert.ToBoolean(x >> 1))
            continue;
        }while (Convert.ToBoolean(0));
        break;
    }
    Console.ReadLine();
}

a) 0 0 0….infinite times
b) 1 1 1….infinite times
c) 1 1 1 1 1 1
d) System outofflow exception error

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

Leave a Comment