Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In c++ Write a program that inputs an array of 10 integers from the user, and removes the duplicate array elements. Here is some sample

In c++

Write a program that inputs an array of 10 integers from the user, and removes the duplicate array elements. Here is some sample output:

Please enter 10 integers, hitting return after each one: 5 75 10 75 5 80 10 5 5 50 You entered 5 distinct numbers: 5 75 10 80 50
Please enter 10 integers, hitting return after each one: 1 2 3 4 5 6 7 8 9 10 You entered 10 distinct numbers: 1 2 3 4 5 6 7 8 9 10 

Hints and Rules

You may assume that all the integers are between 0 and 100, and you may input them from the user however you wish.

Please write at least 1 function in addition to the main function, and pass the array into that function as a parameter.

Each function should have a comment next to it, briefly explaining what it does

Don't use any global variables. Each variable should be declared inside a function.

Use an array to store the numbers, not a vector.

When the program is finished, the program must have an array that stores each number only once (without duplicates). So you can't just skip outputting the duplicates - you have to remove them (or replace them)

The easiest way to do this is to store only the non-repeating elements (only store a number in the array the first time you see it).

A more intuitive and more complicated way to do it is to input all 10 numbers from the user into an array, and then change the array so it contains only the distinct numbers entered by the user. To remove the duplicates, you should make it appear as if the elements hadn't been there. So do not just set duplicates to an "empty" value, but fill in the gap. That means moving all the later elements back one (kind of like when you hit backspace in the middle of a line in a text editor).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro PowerShell For Database Developers

Authors: Bryan P Cafferky

1st Edition

1484205413, 9781484205419

More Books

Students also viewed these Databases questions