For the following switch statement; a. What is output by the following code segment if month has the value 6 ?   b. Assuming the code should output a single value per case, does the switch segment output the proper value(s)?   If NO, what statement(s) would you add to the above switch statement so the output would always be correct?  You do not have to rewrite the code segment, you may indicate the correction(s) in the existing code.     int month = 6;   switch (month)   {     case 1 : cout << "January";     case 2 : cout << "February";     case 3 : cout << "March" ;     case 4 : cout << "April" ;     case 5 : cout << "May" ;     case 6 : cout << "June" ;     case 7 : cout << "July" ;     case 8 : cout << "August" ;     case 9 : cout << "September" ;     case 10 : cout << "October" ;     case 11 : cout << "November" ;     case 12 : cout << "December" ;     default : cout << "Error"; }

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter14: Exception Handling
Section: Chapter Questions
Problem 11SA
icon
Related questions
Question

For the following switch statement;

a. What is output by the following code segment if month has the value 6 ?

 

b. Assuming the code should output a single value per case, does the switch segment output the proper value(s)?

 

If NO, what statement(s) would you add to the above switch statement so the output would always be correct?  You do not have to rewrite the code segment, you may indicate the correction(s) in the existing code.

 

  int month = 6;

  switch (month)

  {

    case 1 : cout << "January";

    case 2 : cout << "February";

    case 3 : cout << "March" ;

    case 4 : cout << "April" ;

    case 5 : cout << "May" ;

    case 6 : cout << "June" ;

    case 7 : cout << "July" ;

    case 8 : cout << "August" ;

    case 9 : cout << "September" ;

    case 10 : cout << "October" ;

    case 11 : cout << "November" ;

    case 12 : cout << "December" ;

    default : cout << "Error";

}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Datatypes
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr