Mastering C# Conditional Statements

Mastering C# Conditional Statements

Professional Development

15 Qs

quiz-placeholder

Similar activities

pyhthon condition statement

pyhthon condition statement

Professional Development

10 Qs

Quiz for Module3

Quiz for Module3

Professional Development

20 Qs

MTS WA380z-6

MTS WA380z-6

Professional Development

10 Qs

PLC and SCADA Quiz

PLC and SCADA Quiz

Professional Development

20 Qs

Warid Prepaid 1

Warid Prepaid 1

Professional Development

10 Qs

Python if statement

Python if statement

Professional Development

10 Qs

Remidi UTS Pemrograman Dasar

Remidi UTS Pemrograman Dasar

Professional Development

10 Qs

Flutter Online Quiz

Flutter Online Quiz

Professional Development

18 Qs

Mastering C# Conditional Statements

Mastering C# Conditional Statements

Assessment

Quiz

Professional Development

Professional Development

Medium

Created by

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

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?