Mastering C# Conditional Statements

Mastering C# Conditional Statements

Professional Development

15 Qs

quiz-placeholder

Similar activities

IBEX A-ISB

IBEX A-ISB

Professional Development

10 Qs

MS402 - Platoon Leadership

MS402 - Platoon Leadership

Professional Development

11 Qs

TalentNext Test Day-13-Core Java Topics

TalentNext Test Day-13-Core Java Topics

Professional Development

10 Qs

Operate Scissor Lift

Operate Scissor Lift

Professional Development

10 Qs

Infallible Vedas (DYS 2)

Infallible Vedas (DYS 2)

Professional Development

18 Qs

MGNF-14

MGNF-14

Professional Development

20 Qs

Labour and Fetal Asphyxia

Labour and Fetal Asphyxia

Professional Development

10 Qs

Petrochina Quiz

Petrochina Quiz

Professional Development

20 Qs

Mastering C# Conditional Statements

Mastering C# Conditional Statements

Assessment

Quiz

Professional Development

Professional Development

Practice Problem

Medium

Created by

Rodrigo Calapan

Used 1+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

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.

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?

Discover more resources for Professional Development