Write a program that prompts the user to enter 50 integers and stores them in an array. The program then determines and outputs which numbers in the array are sum of two other array elements. If an array element is the sum of two other array elements, then for this array element, the program should output all such pairs separated by a ';'. An example of the program is shown below: list[0] = 15 is the sum of: ---------------------- list[1] = 25 is the sum of: list[5], list[14]; list[13], list[47]; list[46], list[47]; ---------------------- list[2] = 23 is the sum of: list[0], list[33]; ---------------------- list[3] = 65 is the sum of: list[4], list[32]; list[13], list[20]; list[20], list[46]; list[21], list[34]; list[32], list[38]; ---------------------- list[4] = 34 is the sum of: list[0], list[14]; list[6], list[48]; ---------------------- list[5] = 6 is the sum of: ... If no two elements can equal the value of an element, the line can remain empty, as shown above for list[0] and list[5].

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter10: Classes And Data Abstraction
Section: Chapter Questions
Problem 22PE
icon
Related questions
Question

Write a program that prompts the user to enter 50 integers and stores them in an array. The program then determines and outputs which numbers in the array are sum of two other array elements. If an array element is the sum of two other array elements, then for this array element, the program should output all such pairs separated by a ';'.

An example of the program is shown below:

list[0] = 15 is the sum of: ---------------------- list[1] = 25 is the sum of: list[5], list[14]; list[13], list[47]; list[46], list[47]; ---------------------- list[2] = 23 is the sum of: list[0], list[33]; ---------------------- list[3] = 65 is the sum of: list[4], list[32]; list[13], list[20]; list[20], list[46]; list[21], list[34]; list[32], list[38]; ---------------------- list[4] = 34 is the sum of: list[0], list[14]; list[6], list[48]; ---------------------- list[5] = 6 is the sum of: ...

If no two elements can equal the value of an element, the line can remain empty, as shown above for list[0] and list[5].

Expert Solution
Step 1
  • A program is to be written in such a way that it takes prompts the user to enter the 50 integers.
  • The integers entered read by the program statements.
  • The program then calculates and outputs the sum of two other array elements that number in the array.
  • If an array element is the sum of two other array elements, then the program should produce all such pairs separated by a ';' for this array element.
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Arrays
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++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning