delete custome index from array c++ code example

Example: delete custome index from array c++

const int SIZE = 9;
	int arr[SIZE];
	cout << "Enter numbers: \n";
	for (int i = 0; i < SIZE; i++)
		cin >> arr[i];
	for (int i = 0; i < SIZE; i++)
		cout << arr[i] << "\t";
	cout << endl;
	
	cout << "Enter Index U want to delete:\n";
	int del;
	cin >> del;
	for (int i = del-1; i < SIZE; i++)
	{
		arr[del] = arr[del + 1];
		del++;
	}
	for (int i = 0; i < SIZE - 1; i++)
		cout << arr[i] << "\t";
	cout << endl;

Tags:

Misc Example