# Board index » delphi » Pascal program doesn't work

## Pascal program doesn't work

I was wondering if anyone could help me with this Pascal problem:-

It should do this declares an array of 10 integers, procedure which reads in
10 integers. then a prcoedure which moves the value of each element to the
adjacent element's position storing ther value of the last element in the
first element's position. finally a procedure which displays  the array with
values in their new order.

Any help will be grateful thank you.

Program array_10;

TYPE
onetoten  = array[1..10]  of Integer;

var
arrays: onetoten ;

var
i  : integer;

begin
FOR i := 1 to 10 do
BEGIN
WRITELN ('Type in your 10 numbers');

END;
end;

Procedure sort (var arr : onetoten);

var
pass,j, hold:integer;
interchange : boolean;

begin
interchange := true;
pass := 1;

while (pass < 10) and interchange do
begin
interchange:=false;
for j := 1 to 10 - pass + 1 -1 do
if arr[j] > arr[j + 1] then
begin
interchange := true;
hold:=arr[j];
arr[j]:= arr[j + 1];
arr[j + 1] :=hold;
end;
pass := pass + 1;
end;
end;

procedure output(var fmgss : onetoten);
var
i:integer;
begin
writeln;
for i := 1 to 10 do
writeln (fmgss[i]);

end;

begin
sort (arrays);
output(arrays);
END.

## Re:Pascal program doesn't work

Hi,

on Sun, 16 Jan 2000 at 00:22:30 o'clock, Mohammed Rafiq wrote:

##### Quote
> It should do this declares an array of 10 integers, procedure which reads in
> 10 integers. then a prcoedure which moves the value of each element to the
> adjacent element's position storing ther value of the last element in the
> first element's position.

To me, this sounds like rotating an array. What the program actually does
is sorting an array. Did you accidentally write a Bubblesort? Not bad :-)

The following procedure will do what you want:

var
Arr : Array[1..10] of Integer;

procedure Rotate;
var
Index : Integer;
Buffy : Integer;
begin
Buffy := Arr[1];
for Index := 2 to 10 do
Arr[Index - 1] := Arr[Index];
Arr[10] := Buffy;
end;

##### Quote
> Procedure read (var num: onetoten);

Under no circumstances should you call a procedure 'read', because one of
the standard procedures already goes by this name. Similarily, 'output'
is also a received name you shouldn't use.

- Sebastian

--
This signature is under construction - be sure to visit back often!