expand icon
book C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith cover

C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith

Edition 8ISBN: 978-1285867410
book C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith cover

C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith

Edition 8ISBN: 978-1285867410
Exercise 3
Using a switch Statement
In this exercise, you use what you have learned about the switch statement to study some C++ code, and then answer Questions.
First, examine the following code:
int numValue = 10;int answer = 0;switch(numValue){case 5: answer += 5;case 10: answer += 10;case 15: answer += 15;break;case 20: answer += 20;case 25: answer += 25;default: answer = 0;break;}cout ? "Answer: " ? answer ? endl;
Is the break statement in the default case needed? Explain.
Explanation
Verified
like image
like image

blured image
, there is no need to use the break st...

close menu
C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith
cross icon