Question
in c++ //This program has a list of integers and your job is to fill in the function to insert a number at the given
in c++
//This program has a list of integers and your job is to fill in the function to insert a number at the given position //You do not need to check for a valid position, meaning the value of pos in the insert function will be within the capacity //and size of the array.
#include
void insertItem(int list[], int& count, int val, int pos);
int main() { const int NUM_VALS = 10; int list[NUM_VALS] = { 7, 12, 34, 15, 9, 10, 3, 0, 0, 0}; int i = 0, count = 7; cout << "List before remove: " << endl; for (i = 0; i < count; i++) { cout << list[i] << " "; } cout << endl; insertItem(list, count, 3, 0); insertItem(list, count, 4, 1); cout << "List after 2 inserts: " << endl; for (i = 0; i < count; i++) { cout << list[i] << " "; } return 0; }
void insertItem(int list[], int& count, int val, int pos) { /* Your solution goes here */ /*Use a for loop to shift items to remove the item in index delIndex*/
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started