This Pascal program uses the bubble sort method to sort numbers stored in an array in ascending order. It prompts the user to enter the number of values to store, reads those values into an array, then sorts the array using two nested for loops to compare and swap adjacent elements if out of order. Finally, it displays the sorted array values on the screen.
2. gotoxy(j,2);
read(vec[i]);
end;
for i:=1 to n-1 do
begin
for j:=i+1 to n do
begin
if vec[i]>vec[j] then
begin
aux:=vec[i];
vec[i]:=vec[j];
vec[j]:=aux;
end;
end;
end;
j:=-2;
for i:=1 to n do
begin
j:=j+6;
gotoxy(j,4);
textcolor(yellow);
write(vec[i]);
end;
readkey;
end.
__________________________________________________________
__________________________________________________________