Select an option to see the answer and solution.
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
2/5
Page
Pick an option on a question to see the right answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
Select an option to see the answer and solution.
static void Main(string[] args)
{
int x = 0;
do
{
x++;
if (x == 5)
{
x++;
continue;
break;
}
Console.WriteLine(x + " ");
}
}while (x < 10);Select an option to see the answer and solution.
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();
}Select an option to see the answer and solution.
static void Main(string[] args)
{
int x;
for (x = 1; x <= 3; x++)
{
int j = 1;
do
{
j++;
}while (x % j == 2);
Console.WriteLine(x + " " + j);
}
Console.ReadLine();
}Select an option to see the answer and solution.
static void Main(string[] args)
{
Console.WriteLine("Enter a letter:");
char c = (char)Console.Read();
if (Char.IsDigit(c) == true)
Console.WriteLine("A number");
else if (char.IsLower(c) == true)
Console.WriteLine("A lowercase letter");
else if (char.IsUpper(c) == true)
Console.WriteLine("An uppercase letter");
Console.ReadLine();
}
a. Enter a letter :
a
An uppercase letter
b. Enter a letter :
A
An uppercase letter
c. Enter a letter :
2
A number
d. Enter a letter :
2
A lowercase letter.Select an option to see the answer and solution.
static void Main(string[] args)
{
char ch = 'p';
switch (ch)
{
case 'p':
Console.WriteLine("coco" + "\t" + Convert.ToInt32(ch));
break;
default:
Console.WriteLine("default");
break;
}
Console.WriteLine("main");
}Select an option to see the answer and solution.
static void Main(string[] args)
{
int i;
int b = 8, a = 32;
for (i = 0; i <= 10; i++)
{
if ((a / b * 2)== 2)
{
Console.WriteLine( i + " ");
continue;
}
else if (i != 4)
Console.Write(i + " ");
else
break;
}
Console.ReadLine();
}Select an option to see the answer and solution.
static void Main(string[] args)
{
int i;
int j = 1;
int []ar = {21, 22, 13, 4};
switch (ar[j])
{
case 1:
i++;
break;
case 2:
i += 2;
j = 3;
continue;
case 3:
i %= 2;
j = 4;
continue;
default:
--i;
}
Console.WriteLine(i);
Console.ReadLine();
}Select an option to see the answer and solution.
static void Main(string[] args)
{
int i;
for (i =-3; i <= 3; i++)
{
switch (i)
{
case 0:
Console.WriteLine("zero");
break;
}
if (i > 0)
Console.WriteLine("A");
else if (i < 0)
Console.WriteLine("B");
}
Console.ReadLine();
}Select an option to see the answer and solution.
static void Main(string[] args)
{
int i = 0;
int j = 0;
for (i = 0; i < 4; i++)
{
for (j = 0; j < 3; j++)
{
if (i > 1)
continue;
Console.WriteLine("Hi \n");
}
}
Console.ReadLine();
}Select an option to see the answer and solution.
static void Main(string[] args)
{
int temp = 1;
switch (temp << 2 + temp)
{
default:
Console.WriteLine("Example1");
break;
case 4:
Console.WriteLine("Example2");
break;
case 5:
Console.WriteLine("Example3");
break;
case 8:
Console.WriteLine("Example4");
break;
}
Console.ReadLine();
}Select an option to see the answer and solution.
static void Main(string[] args)
{
int i = 9 , j = 7;
switch (i - j + 3)
{
case 9: 7:
j += 6;
break;
case 5:
i -= 4;
break;
}
Console.WriteLine(i + "\n" + j);
Console.ReadLine();
}Select an option to see the answer and solution.