21. What is the output of the following segment of code if 7 is
input by...
60.1K
Verified Solution
Link Copied!
Question
Programming
21. What is the output of the following segment of code if 7 isinput by the user when asked to enter a number?____________ intnum; int total = 0; cout << \"Enter a number from 1 to 10: \";cin >> num; switch (num) { case 1: case 2: total = 5; case 3:total = 10; case 7: total = total + 3; case 8: total = total + 6;default: total = total + 4; } cout << total <
Answer & Explanation
Solved by verified expert
3.9 Ratings (413 Votes)
The output of the given segment of code when 7 is entered as the input by the user is 13 Switch statement A switch statement allows us to select an option out of several options present based on the choice Syntax switchchoiceexpression case value1 block1 break case value2 block2break Any number of
See Answer
Get Answers to Unlimited Questions
Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!
Membership Benefits:
Unlimited Question Access with detailed Answers
Zin AI - 3 Million Words
10 Dall-E 3 Images
20 Plot Generations
Conversation with Dialogue Memory
No Ads, Ever!
Access to Our Best AI Platform: Zin AI - Your personal assistant for all your inquiries!