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...

A ________ in OpenOffice Writer includes formatting, such as font, font size, font emphasis, and paragraph indents

A) style B) record C) hanging indent D) first line indent

Computer Science & Information Technology

Upon arriving at an incident scene, the incident response team should do which of the following?

A. Take photographs of the crime scene before it can be disturbed. B. Quickly unplug the Ethernet plug. C. Follow the procedures specified in the incident response plan. D. Turn off the affected machine to stop the attack.

Computer Science & Information Technology