Control Statements in C Sharp

Control Statements in C Sharp

memorize.aimemorize.ai (lvl 286)
Section 1

Preview this deck

Give an example of 'if' without 'else'?

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

5 years ago

Date created

Mar 1, 2020

Cards (22)

Section 1

(22 cards)

Give an example of 'if' without 'else'?

Front

if (condition) { //then code here }

Back

What are control Statements?

Front

A control statement causes the program control to be transferred to a specific flow based upon whether a certain condition is true or not

Back

What is a 'default' in 'switch' control statement?

Front

If no case label contains a matching value, control is transferred to the default section, if there is one

Back

What is a 'if' control statement?

Front

An if statement identifies which statement to run based on the value of a Boolean expression

Back

Can a 'switch' statement include any number of switch sections?

Front

Yes

Back

Give an example of 'string' switch expression?

Front

switch (dayofweek) { case 'monday': ...}

Back

Give an example of 'numeric' switch expression?

Front

switch (monthofyear) { case 1:

Back

What happens if the value of the switch expression does not match?

Front

The control is transferred outside the switch statement

Back

Can two case labels contain the same constant value?

Front

No

Back

Where can I find more information about control Statements in C Sharp?

Front

https://msdn.microsoft.com/en-us/library/5011f09h.aspx

Back

What is a switch expression?

Front

switch (age)

Back

What is a 'switch' control statement?

Front

The switch statement is a control statement that selects a switch section to execute from a list of candidates.

Back

Give an example of 'While loop' statement?

Front

namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int number = 0; while(number < 5) { Console.WriteLine(number); number = number + 1; } Console.ReadLine(); } } }

Back

Give an example of 'switch' control statement?

Front

int caseSwitch = 1; switch (caseSwitch) { case 1: Console.WriteLine("Case 1"); break; case 2: Console.WriteLine("Case 2"); break; default: Console.WriteLine("Default case"); break; }

Back

Can 'switch' statement have one or more labels?

Front

Yes

Back

Give an example of 'if-else' control statement?

Front

if (condition) { //code here } else {//code here}

Back

Is 'else' mandatory in 'if-else' control statement?

Front

No it is not

Back

Which keywords are used in control statements?

Front

The keywords used in selection statements are if, else, switch, case, default

Back

Where can I find more information about switch Statements in C Sharp?

Front

https://msdn.microsoft.com/en-us/library/06tc147t.aspx

Back

Why should I use 'switch' and not 'if-else'?

Front

A switch statement includes one or more switch sections. Each switch section contains one or more case labels followed by one or more statements.

Back

What if i want nested 'if-else' control statements? Are they allowed?

Front

Yes. Example if (condition1) { if (condition2) { } }

Back

Give an example of 'For loop' statement?

Front

namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int number = 5; for (int i = 0; i < number; i++) Console.WriteLine(i); Console.ReadLine(); } } }

Back