Find the errors in the following code segments and explain how to correct them.
```
switch (n) {
case 1:
cout << "The number is 1" << endl;
case 2:
cout << "The number is 2" << endl;
break;
default:
cout << "The number is not 1 or 2" << endl;
}
```
Error: Missing break statement in the first case.
Correction: Add a break statement at the end of the first case. This is not an error if you want the statement of case 2: to execute every time the case 1: statement exe- cutes.
You might also like to view...
The following code gives the error message shown below. Fix the code.
What will be an ideal response?
What can be constructed by choosing two or more data items and combining them?
A) a primary key B) an attribute C) a secondary key D) an entity E) a concatenated key
When an e-mail message is open in Outlook, it is displayed in a ____ window.
A. Reading B. Message C. Communication D. Folder
Which of the following tools or methods can be used to discover services running on computers?
A. HTTP interceptor B. ping sweep C. port scanner D. black box