Vidyalelo
C# Programming · all questions

Control Flow Statements in C Sharp
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

92

Questions

4/5

Page

Pick an option on a question to see the right answer and solution.

What will be the output of the following C# code?
static void Main(string[] args)
{
    int i = 0;
    while (i++ != 0) ;
    Console.WriteLine(i);
    Console.ReadLine();
}

Select an option to see the answer and solution.

What will be the output of the following C# code?
static void Main(string[] args)
{
    int i = 0;
    while (i <= 50)
    {
        if (i % 10 == 0)
        continue;
        else
        break;
        i += 10;
        Console.WriteLine(i % 10);
   }
}

Select an option to see the answer and solution.

What is the correct syntax for do while loop?

Options are not available for this question.

Select an option to see the answer and solution.

What will be the output of the following C# code?
static void Main(string[] args)
{
    int i = 1;
    while (i <= 1)
    {
        if ('A' < 'a')
        {
            Console.WriteLine("Hello...");
        }
        else
        {
           Console.WriteLine("Hi...");
        }
           i++;
    }
    Console.ReadLine();
}

Select an option to see the answer and solution.

What will be the output of the following C# code?
static void Main(string[] args)
{
    int a = 5, b = 10;
    if (Convert.ToBoolean(Convert.ToInt32(++a)) || Convert.ToBoolean(Convert.ToInt32(++b)))
    {
        Console.WriteLine(a + "\n" + b);
    }
    else
    Console.WriteLine(" C# ");
}

Select an option to see the answer and solution.

What will be the output of the following C# code?
static void Main(string[] args)
{
    int i, s = 0, a = 1, d;
    i = Convert.ToInt32(Console.ReadLine());
    do
    {
        d = i % (2 * 4);
        s = s + d * a;
    }while ((Convert.ToInt32(i = i / (2 * 4))) != 0 
     && (Convert.ToBoolean(Convert.ToInt32((a) = (a * 10)))));
    Console.WriteLine(s);
    Console.ReadLine();
}
enter i = 342.

Select an option to see the answer and solution.

What will be the output of the following C# code?
static void Main(string[] args)
{
    int i = 1, j = 5;
    do
    {
        Console.WriteLine(i = i++ * j);
    }while (i <= 10);
    Console.ReadLine();
}

Select an option to see the answer and solution.

What will be the output of the following C# code?
static void Main(string[] args)
{
    int i = 1, j = 1;
    while (++i <= 10)
    {
        j++;
    }
    Console.WriteLine(i+ "  " +j);
    Console.ReadLine();
}

Select an option to see the answer and solution.

What will be the output of the following C# code?
static void Main(string[] args)
{
    int I, J = 0;
    for (I = 1; I < 10; ) ;
    {
        J = J + I;
        I += 2;
    }
    Console.WriteLine("Sum of first 10 even numbers is:"+J);
    Console.ReadLine();
}

Select an option to see the answer and solution.

What will be the output of the following C# code?
static void Main(string[] args)
{
    int i;
    for (i = 0;  ; )
    {
        Console.WriteLine("hello");
    }
    Console.ReadLine();
}

Select an option to see the answer and solution.

What will be the output of the following C# code?
static void Main(string[] args)
{
    int i = 10 , j = 0;
    label:
    i--;
    if ( i > 0)
    {
        Console.WriteLine(i+ " ");
        goto label;
    }
    Console.ReadLine();
}

Select an option to see the answer and solution.

What will be the output of the following C# code?
static void Main(string[] args)
{
    int i= 0,k;
    label: Console.WriteLine(i);
    if (i == 0)
        goto label;
    Console.ReadLine();
}

Select an option to see the answer and solution.

What will be the output of the following C# code?
static void Main(string[] args)
{
    int I, X;
    for (I = 1; I <= (9 % 2 + I); I++)
    {
        X = (I * 3 + I * 2) / I;
        Console.WriteLine(X);
    }
    Console.ReadLine();
}

Select an option to see the answer and solution.

What will be the output of the following C# code?
static void Main(string[] args)
{
    int i, j;
    for (i = 2; i >= 0; i--)
    {
        for (j = 0; j <= 2; j++)
        {
            if (i == j)
            {
                Console.WriteLine("1");
            }
            else
            {
                Console.WriteLine("0");
            }
       }
       Console.WriteLine("\n");
       Console.ReadLine();
    }
}

Select an option to see the answer and solution.

What will be the output of the following C# code?
static void Main(string[] args)
{
    int i = 0, j = 0;
    while (i < 2)
    {
        l1: i--;
        while (j < 2)
        {
            Console.WriteLine("hi\n");
            goto l1;
        }
    }
    Console.ReadLine();
}

Select an option to see the answer and solution.

What will be the output of the following C# code?
static void Main(string[] args)
{
    int i = 30;
    int j = 25 % 25;
    if (Convert.ToBoolean(Convert.ToInt32(i = j)))
    {
        Console.WriteLine("In if");
    }
    else
    {
        Console.WriteLine("In else");
    }
    Console.WriteLine("In main");
    Console.ReadLine();
}

Select an option to see the answer and solution.

Select the output for the following set of code :
static void Main(string[] args)
{
    int a = 0;
    int i = 0;
    int b;
    for (i = 0; i < 5; i++)
    {
         a++;
         Console.WriteLine("Hello \n");
         continue;
    }
    Console.ReadLine();
}

Select an option to see the answer and solution.

What will be the output of the following C# code?
static void Main(string[] args)
{
    int i, j;
    for (i = 1; i <= 3; i++)
    {
        j = 1;
        while (i % j == 2)
        {
            j++;
        }
        Console.WriteLine(i + " " + j);
    }
    Console.ReadLine();
}

Select an option to see the answer and solution.

What will be the output of the following C# code?
static void Main(string[] args)
{
    int n, r;
    n = Convert.ToInt32(Console.ReadLine());
    while (n > 0)
    {
        r = n % 10;
        n = n / 10;
        Console.WriteLine(+r);
    }
    Console.ReadLine();
}
for n = 5432.

Select an option to see the answer and solution.

What will be the output of the following C# code?
static void Main(string[] args)
{
    int a = 5, b = 10;
    if (Convert.ToBoolean(Convert.ToInt32(0xB)))
    if (Convert.ToBoolean(Convert.ToInt32(022)))
    if (Convert.ToBoolean(Convert.ToInt32('\xeb')))
    Console.WriteLine("java");
    else ;
    else ;
    else ;
}

Select an option to see the answer and solution.