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 1
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;
What is the value of answer if the value of numValue is 5?
Explanation
Verified
like image
like image

The nested if statement:
The "switch" s...

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