ALGORITHM

  1. Get the element values which needed to be inserted
  2. Get the position Value
  3. check the position value is valid or not. If yes then proceed with the next steps or else ask for the input again.
  4. If True then, shift all the element from the last index to position index by 1 position to the right
  5. otherwise, invalid Position
  6. Exit

Source Code

#include <stdio.h>

int main()
{
	int arr[100] = { 0 };
	int i, x, pos, n = 10;

	for (i = 0; i < 10; i++)
		arr[i] = i + 1;

	for (i = 0; i < n; i++)
		printf("%d ", arr[i]);
	printf("\\n");

	x = 50;

	pos = 5;

	n++;

	for (i = n - 1; i >= pos; i--)
		arr[i] = arr[i - 1];

	arr[pos - 1] = x;

	for (i = 0; i < n; i++)
		printf("%d ", arr[i]);
	printf("\\n");

	return 0;
}