What is wrong with the following switch statement?

int ans;
cout <<"Type y for yes on n for no\n";
cin >> ans;
switch (ans)
{
case 'y':
case 'Y': cout << "You said yes\n"; break;
case 'n':
case 'N': cout << "You said no\n"; break;
default: cout <<"invalid answer\n";
}

a. ans is a int
b. break; is illegal syntax
c. nothing
d. there are no break statements on 2 cases.


a. ans is a int

Computer Science & Information Technology

You might also like to view...

The Internet Explorer filterWave(freq=value, lightStrength=value, phase=value, strength=value)applies the sine-wave distortion to an object. The appearance of the wave is determined by the four ____.

A. qualities B. rules C. parameters D. limits

Computer Science & Information Technology

Which type of files are downloaded to your computer, from the Web, in order to view Web pages faster?

A) Web files B) Windows Registry C) Encrypted File System D) Temporary Internet files

Computer Science & Information Technology

Subfolders are folders that are inside of other folders.

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

Computer Science & Information Technology

What is the value of GRID(3, 3) after the instructions corresponding to the following pseudocode are executed?

``` R = 1 DOWHILE R < 5 C = 2 DOWHILE C < 5 GRID(R, C) = R + C C = C + 1 ENDDO R = R + 2 ENDDO ``` a) 5 b) 6 c) 7 d) none of the above

Computer Science & Information Technology