C# Decision Making Quiz Form
Test your knowledge of C# decision making concepts. Answer all questions to the best of your ability. All questions are required.
Full Name
*
First Name
Last Name
Which C# statement is used to make a decision based on a condition?
*
if
for
while
switch
What is the output of the following code? int x = 10; if (x > 5) Console.WriteLine("A"); else Console.WriteLine("B");
*
A
B
No output
Error
Which keyword is used to handle multiple possible values of a variable in C#?
*
switch
case
break
goto
In C#, what is the result of the following code? int y = 3; string result = y > 5 ? "High" : "Low"; Console.WriteLine(result);
*
High
Low
3
Error
Which of the following is the correct syntax for an if-else statement in C#?
*
if (condition) { } else { }
if condition then { } else { }
if { } else { }
if (condition): { } else: { }
Rate your confidence in your C# decision making knowledge.
*
1
2
3
4
5
Match each C# decision making keyword to its purpose.
*
Rows
Purpose
if
Conditional branching
Multiple value selection
Exit current block
Conditional assignment
switch
Conditional branching
Multiple value selection
Exit current block
Conditional assignment
break
Conditional branching
Multiple value selection
Exit current block
Conditional assignment
?: (ternary)
Conditional branching
Multiple value selection
Exit current block
Conditional assignment
Fill in the blank: The _____ statement allows you to execute code only when a specific condition is true in C#.
*
Write a short C# code snippet that uses a switch statement to print "Yes" if a variable equals 1, and "No" otherwise.
*
Submit Quiz
Should be Empty: