Question 04 of 05

Array Deletion

Write a program to delete an element from a specific position in an array.

C++
#include <iostream>
using namespace std;

int main() {
    int arr[] = {10, 20, 30, 40, 50};
    int n = 5, pos = 2;
    for (int i = pos; i < n-1; i++) arr[i] = arr[i+1];
    n--;
    for (int i = 0; i < n; i++) cout << arr[i] << " ";
    return 0;
}
Question 4 of 5