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++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 16PE
icon
Related questions
Question

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:

  1. Greater than size n of the array
  2. 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!

Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage