Deletes Specific Index
Lesson 15 of 18 in Coddy's Functions in C++: Building Your Own Functions course.
Challenge
EasyWrite a function to delete an item from an array
write a function in C++ that takes an array and an index, and deletes the item at that specific index
Example:
- If the array is
{12, 34, 5, 67, 8} - And the index is
2 - The output will be
{12, 34, 67, 8}
If the index is not within the bounds of the array, print the message: "Invalid index!"
Try it yourself
#include <iostream>
#include <vector>
using namespace std;
void deleteElementAtIndex(vector<int> arr, int index) {
}All lessons in Functions in C++: Building Your Own Functions
1Introduction
Introduction2Beginner-level function
Repeat a StringReverse a StringMax ValueFill stringCenter TextFormat TextMath Operation3Intermediate-level functions
Compare two StringsSwap CasesCount Alphabetic LetterReplace in ArrayExtracts Integers Generate CharactersDeletes Specific Index