Title: Eliminating duplicates
Objectives: To introduce the concept of passing arrays to functions as parameters; create modular programs to process arrays.
Description:
Part 1.
Write a C function that deletes all occurrences of an element from an array starting from a given index. The prototype of the function is as follows:
//Preconditions: The first parameter is an integer array; the second parameter is an integer representing the number of elements in the array; the third parameter is the number that is to be deleted from the array; and the fourth parameter is the index from which the search for deletion should start.
//Postconditions: The function deletes all elements
whose value is equal to item starting from the index
loc. The size of the array will decrease if one or more copies of item existed in the array. Therefore function changes the number of elements in the array as well. The function also returns the number of deleted items.
int delete_elemet(int a[], int *n, int item, int loc);
Part 2.
Write a program that reads a sequence of unknown number of integers into an array. There may be a maximum of 20 integers in the input, so you should define the size of the array to be 20. Your program should then remove duplicates of all numbers in the array using the function that you wrote in part 1. After deleting the duplicates, your program should also print how many copies are deleted for each number having duplicates.
Restrictions
You must write the function delete_element() as described in part 1 and you must call it in your main function appropriately to perform the task described in
part 2.
Your main function should call the function delete_element() properly so that it can use the value that the function returns to print the number of copies deleted from the array. This printing must be done in the main function, not in the function delete_element() .
Output Specification:
Sample Run 1:
Enter some integers (maximum of 20):
10 25 38 25 40 10 10 50 38 25 10
Value 10 : 3 copies are deleted.
Value 25 : 2 copies are deleted.
Value 38 : 1 copy is deleted.
The resulting array is:
10 25 38 40 50
Sample Run 2:
Enter some integers (maximum of 20):
21 21 21 21 21 21 21
Value 21: 6 copies are deleted.
The resulting array is:
21
## Deliverables
1) Complete and fully-functional working C program in executable form as well as complete source code of all work done.
## Platform
Windows