Examveda

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

Answer: Option C


Join The Discussion

Related Questions on Control Flow Statements in C Sharp