C++ Write a program that reads in non-negative integers and stores and displays distinct numbers.
C++ Write a program that reads in non-negative integers and stores and displays distinct numbers.
Write a program that reads in non-negative integers and stores and displays distinct numbers (i.e., if a number appears multiple times, it is stored and displayed only once). Your program should allow up to 1000 distinct numbers to be stored and displayed. Use the following algorithm (this is required!): Read each number and store it in an array if it is new. If the number is already in the array, ignore it. The user will indicate that they are done entering numbers by entering a negative number. Here is a sample run:
Enter a non-negative integer (negative to quit): 1_x000D_ Enter a non-negative integer (negative to quit): 2_x000D_ Enter a non-negative integer (negative to quit): 3_x000D_ Enter a non-negative integer (negative to quit): 2_x000D_ Enter a non-negative integer (negative to quit): 1_x000D_ Enter a non-negative integer (negative to quit): 6_x000D_ Enter a non-negative integer (negative to quit): 3_x000D_ Enter a non-negative integer (negative to quit): 4_x000D_ Enter a non-negative integer (negative to quit): 5_x000D_ Enter a non-negative integer (negative to quit): 2_x000D_ Enter a non-negative integer (negative to quit): -4_x000D_ You entered: _x000D_ 1 2 3 6 4 5 _x000D_
To get credit for this assignment you must use appropriate decomposition! You should have a function to read the numbers and a function to print the resulting array. The function that reads the numbers should call an additional function that returns a bool value indicating whether a number is already in the array. At the conclusion of the call to the function that reads the numbers, the array MUST contain only distinct numbers.
Additionally, you must not sort the array. The numbers must appear in the same order in which they were typed.
"You need a similar assignment done from scratch? Our qualified writers will help you with a guaranteed AI-free & plagiarism-free A+ quality paper, Confidentiality, Timely delivery & Livechat/phone Support.
Discount Code: CIPD30
Click ORDER NOW..
