vault backup: 2024-09-18 11:52:12
This commit is contained in:
parent
5dfd3085bb
commit
26c475fff5
@ -74,7 +74,7 @@ The program would print `onetwo` because each case is missing a `break` statemen
|
||||
| 912 | Savannah |
|
||||
> Write a switch statement whose controlling expression is the variable `area_code`. If the value of `area_code` is not in the table, the `switch` statement will print the corresponding city name. Otherwise, the `switch` statement will display the message `"Area code not recognized."` Use the techniques discussed in section 5.3 to make the `switch` as simple as possible.
|
||||
```c
|
||||
int area_code = 0;
|
||||
int area_code;
|
||||
|
||||
switch (area_code) {
|
||||
case 404:
|
||||
@ -83,7 +83,21 @@ switch (area_code) {
|
||||
case 770:
|
||||
printf("Atlanta");
|
||||
break;
|
||||
case
|
||||
|
||||
case 706:
|
||||
case 762:
|
||||
printf("Columbus");
|
||||
break;
|
||||
case 229:
|
||||
printf("Albany");
|
||||
break;
|
||||
case 478:
|
||||
printf("Macon");
|
||||
break;
|
||||
case 912:
|
||||
printf("Savannah");
|
||||
break;
|
||||
default:
|
||||
printf("Area code not recognized.");
|
||||
break;
|
||||
}
|
||||
```
|
Loading…
Reference in New Issue
Block a user