12. What is the output of the following code snippet?
int x = 3;
int y = 5;
if (x < y)
{
Console.WriteLine("x is less than y");
}
else
{
Console.WriteLine("x is greater than or equal to y");
}
- “x is less than y”
- “x is greater than or equal to y”
- “y is less than x”
- “y is greater than or equal to x”
13. What is the output of the following code snippet?
int i = 0;
while (i < 5)
{
Console.WriteLine(i);
i++;
}
- 0 1 2 3 4
- 5 4 3 2 1
- 0 0 0 0 0
- 1 2 3 4 5
15. What is the purpose of the "else if" statement in a conditional statement?
- To execute a block of code if a condition is false.
- To test another condition if the previous condition tested is false.
- To execute a block of code regardless of whether a condition is true or false.
- To terminate a conditional statement.
16. Which of the following loops is best suited for iterating over an array in C#?
- do..while loop
- while loop
- for loop
- foreach loop
17. What is the output of the following code?
int i = 0;
while (i < 5)
{
Console.WriteLine(i);
i++;
}
- 0 1 2 3 4
- 1 2 3 4 5
- 5 4 3 2 1
- The code will result in an infinite loop.
18. Which of the following operators has the highest precedence?
- Logical NOT (!)
- Multiplication (*)
- Assignment (=)
- Increment (++)
19. Which of the following conditional statements allows for multiple conditions to be tested?
- if
- if..else
- if..else if
- switch