C Program Removing Elements in an Array Make a program that creates an array by asking the size n of the array and n integer inputs. Example: Input size of array: 5 Array elements: 1 2 3 4 5 After creating the array, you need to prompt the user again to pick m number of elements to remove. If the input is invalid, prompt the user to try again. An input is invalid if it meets either one of these criteria: Greater than size n of the array Negative number Example: Number of elements to remove: -2 Invalid number. Try again: 3 After a valid input, prompt the user for the valid indices to remove. An index is valid if it is within the range of the array size. Output the array elements after a valid index input and consider the new size of the array after. Example: Index (1): 2 Array elements: 1 2 4 5 Index (2): 4 Invalid index! Try again. Index (2): 0 Array elements: 2 4 5 Index (3): 2 Array elements: 2 4 After everything, print FINISHED! Input 1. Size of array 2. Elements of the array Description Note that the elements are only integer values but can either be either be positive/negative/zero. 3. Number of elements to remove 4. Indices to remove Example: Input size of array: 5 Array elements: 1 2 3 4 5 Number of elements to remove: -2 Invalid number. Try again: 3 Index (1): 2 Array elements: 1 2 4 5 Index (2): 4 Invalid index! Try again. Index (2): 0 Array elements: 2 4 5 Index (3): 2 Array elements: 2 4 FINISHED!
C Program
Removing Elements in an Array
Make a program that creates an array by asking the size n of the array and n integer inputs.
Example:
Input size of array: 5
After creating the array, you need to prompt the user again to pick m number of elements to remove. If the input is invalid, prompt the user to try again. An input is invalid if it meets either one of these criteria:
- Greater than size n of the array
- Negative number
Example:
Number of elements to remove: -2
After a valid input, prompt the user for the valid indices to remove. An index is valid if it is within the range of the array size. Output the array elements after a valid index input and consider the new size of the array after.
Example:
Index (1): 2 Array elements: 1 2 4 5
After everything, print FINISHED!
Input
1. Size of array
2. Elements of the array
Description
Note that the elements are only integer values but can either be either be positive/negative/zero.
3. Number of elements to remove
4. Indices to remove
Example:
Input size of array: 5
Array elements: 1 2 3 4 5
Number of elements to remove: -2
Invalid number. Try again: 3
Index (1): 2 Array elements: 1 2 4 5
Index (2): 4 Invalid index! Try again.
Index (2): 0 Array elements: 2 4 5
Index (3): 2 Array elements: 2 4
FINISHED!
Step by step
Solved in 4 steps with 3 images