
Mastering C# Conditional Statements

Quiz
•
Professional Development
•
Professional Development
•
Medium
Rodrigo Calapan
Used 1+ times
FREE Resource
15 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the purpose of an if statement in C#?
To create loops in C#
The purpose of an if statement in C# is to control the execution of code based on a condition.
To declare variables in C#
To define classes in C#
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How do you write an if-else statement in C#?
if (condition) { // code } else { // code }
if condition { // code } else // code
if (condition) { // code } else if { // code }
if (condition) // code else { // code }
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is a nested if statement? Provide an example.
if (x < 10) { console.log('x is less than 10'); }
Example: if (x > 10) { if (y < 5) { console.log('x is greater than 10 and y is less than 5'); } }
if (y > 5) { if (x == 10) { console.log('y is greater than 5 and x is equal to 10'); } }
if (x == 5) { console.log('x is equal to 5'); }
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Explain the switch statement and when to use it.
The switch statement is a type of conditional that only works with strings.
The switch statement can only handle boolean values.
The switch statement is used to execute different parts of code based on the value of a variable, particularly when there are multiple possible values.
The switch statement is used for looping through arrays.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following code: if (x > 10) { Console.WriteLine("Greater"); }?
Greater
Not Greater
Equal
Less
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How can you use multiple conditions in an if statement?
You can use logical operators like '&&' for 'and' and '||' for 'or' to combine multiple conditions.
You can use mathematical operators like '+' and '-' to combine conditions.
You must use a switch statement instead of if.
You can only use one condition in an if statement.
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the difference between == and = in C#?
The difference is that '=' assigns a value, and '==' checks for equality.
Both '=' and '==' are used for assignment in C#.
'==' is used to declare variables, while '=' is for comparison.
'=' checks for equality, and '==' assigns a value.
Create a free account and access millions of resources
Similar Resources on Wayground
20 questions
MENGATASI GANGGUAN SEDERHANA

Quiz
•
Professional Development
15 questions
Verilog Fundamentals

Quiz
•
Professional Development
14 questions
ABREDES - Devasc Python

Quiz
•
Professional Development
10 questions
Identifying Assumptions and Conclusions

Quiz
•
Professional Development
15 questions
python dictionary and set

Quiz
•
Professional Development
10 questions
ETHICAL DILEMMA Advanced 1

Quiz
•
Professional Development
20 questions
ASR General Knowledge Online Test

Quiz
•
Professional Development
15 questions
EMERGENCY CODES

Quiz
•
Professional Development
Popular Resources on Wayground
18 questions
Writing Launch Day 1

Lesson
•
3rd Grade
11 questions
Hallway & Bathroom Expectations

Quiz
•
6th - 8th Grade
11 questions
Standard Response Protocol

Quiz
•
6th - 8th Grade
40 questions
Algebra Review Topics

Quiz
•
9th - 12th Grade
4 questions
Exit Ticket 7/29

Quiz
•
8th Grade
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
19 questions
Handbook Overview

Lesson
•
9th - 12th Grade
20 questions
Subject-Verb Agreement

Quiz
•
9th Grade