Rewrite the following if statement as an equivalent switch statement. The variable num is of type int.

```
if (num == 0 || num == 1)
control = 100;
else if (num == 2)
control = 200;
else if (num == 3)
control = 300;
else
control = 0;
```

```
switch (num) {
case 0:
case 1:
control = 100;
break;
case 2:
control = 200;
break;
case 3:
control = 300;
break;
default:
control = 0;
}
```

Computer Science & Information Technology

You might also like to view...

A placeholder is a numeric string that appears within the control element and provides users with information about the kind of information accepted by the field.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

What type of structure is created when a pretest loop is inside another pretest loop?

A. integrated selection B. nested repetition C. iterative repetition D. optional selection

Computer Science & Information Technology