Write a C++ program that reads user's choice as single character then do the following: • If the user entered (A), your program should read a long positive number, and display the positive difference between the first and last digits (the positive difference between the most right digit and the most left digit) i.e. If the number is 5635634, the program should display 1 (5-4=1). If the number is 3635637, the program should display 4 (7-3=4). • If the user entered (B), your program should read 9 integer numbers, then find and print the sum of the odd numbers. • If the user entered (C), your program should read two integer numbers, add three to each of them, swap their values, and print them after swapping. • If the user entered any other character as a choice, then your program should display the following pattern.
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.
![+
x Online C++ Compiler - online ed +
X Menu Path2Code
x (1) WhatsApp
x Second Semester 2021: al
path2code.com/p2c/suser/question/read.php?testid=tv816K2r1315sFiP8hfhXepWziksjMuOaTE943AZ.FY-&qid=3KmKN94Igy2S2UV2nv7psw-- A
upa
54321
4321
321
21
S Raise Your hand!
Code A</> Path2Code
A main.cpp
1 #include<iostream>
2 using namespace std;
3 int main() {
return 0;
OB Custom input? O Run
1 Submit
Path2Code.com © 2021 All rights reserved.
03:46P
EN
) ll a](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F651d7196-ed3a-4053-9aa8-8bd002180b6d%2F409ec097-fdfa-4d5c-adfc-343770a604a5%2Fffy0quq_processed.jpeg&w=3840&q=75)
![+
x Online C++ Compiler - online ed +
X Menu Path2Code
x (1) WhatsApp
x Second Semester 2021: al
نافذة ضيف
path2code.com/p2c/suser/question/read.php?testid=tv816K2r1315sFiP8hfhXepWziksjMuOaTE943AZ.FY-&qid=3KmKN94Igy2S2UV2nv7psw-- A
O Challenge task
Write a C++ program that reads user's choice as single character then do the following:
• If the user entered (A), your program should read a long positive number, and display the positive difference between the first and last digits
(the positive difference between the most right digit and the most left digit)
i.e.
If the number is 5635634, the program should display 1 (5-4-1).
If the number is 3635637, the program should display 4 (7-3=4).
• If the user entered (B), your program should read 9 integer numbers, then find and print the sum of the odd numbers.
• If the user entered (C), your program should read two integer numbers, add three to each of them, swap their values, and print them after
swapping.
• If the user entered any other character as a choice, then your program should display the following pattern.
54321
4321
321
21
1
Constraints
03:46
EN
4)all餅a
000](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F651d7196-ed3a-4053-9aa8-8bd002180b6d%2F409ec097-fdfa-4d5c-adfc-343770a604a5%2Fcqgerkb_processed.jpeg&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 5 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)