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

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter4: Selection Structures
Section4.3: Nested If Statements
Problem 7E
icon
Related questions
icon
Concept explainers
Question
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
None.
Transcribed Image Text: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 None.
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
None.
Transcribed Image Text: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 None.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Control Structure
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++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr