Selection Construct Flashcards

(2 cards)

1
Q

How to write if-else statements?

A

if (condition)
{
statement
}
else if (condition)/ else
{
statement
}
brackets needed if there is 2 lines or more

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How to write switch statements?

A

switch (expression)
{
case 1 : statement1 ;
break;
case 2 : statement2 ;
break;
default : statement ;
break;
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly