Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 using namespace std;

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

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

Step: 3

blur-text-image

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

Database In Depth Relational Theory For Practitioners

Authors: C.J. Date

1st Edition

0596100124, 978-0596100124

More Books

Students also viewed these Databases questions