Question: ( please only use if - if else - For - while - do while only ) ( c + + language ) Write a

(please only use if - if else - For-while - do while only )
(c++ language)
Write a program that prompts the user to fill an array with positive integers.
If the user enters a negative value, the program should repeatedly request
a positive one. After the array is filled, the program should find and print
all pairs of elements in the array whose sum equals a specified number
provided by the user.
NOTE:
The array is of type integer and size 10.
The program must ensure that the user only enters positive integers
into the array.
[Sample Run 1]
Fill array with 10 numbers:
5
-1
Invalid input! Please enter positive number:
-4
Invalid input! Please enter positive number:
1
9
4
2
8
3
7
6
0
Enter a number to find pairs whose sum is equal to it:
5
5}\mathrm{ and 0
1 and 4
2}\mathrm{ and 3
[Sample Run 2]
Fill array with 10 numbers:
Invalid input! Please enter positive number:
3
7
6
0
Enter a number to find pairs whose sum is equal to it:
10
1 and 9
4 and 6
2 and 8
3 and 7
( please only use if - if else - For - while - do

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!