program InsertElementInArray;
type
TArray = array[1..100] of Integer;
var
arr: TArray;
size, i, index, val: Integer;
begin
{ Initialize the array and its size }
size := 5;
arr[1] := 7;
arr[2] := 6;
arr[3] := 9;
arr[4] := 1;
arr[5] := 4;
{ Specify the index and value to insert }
index := 3;
val := 100;
{ Shift elements to the right }
for i := size downto index do
arr[i + 1] := arr[i];
{ Insert the new element }
arr[index] := val;
{ Increase the size of the array }
size := size + 1;
for i := 1 to size do
Write(arr[i], ' ');
end.
(*
run:
7 6 100 9 1 4
*)