{Exchange two elements of an array}
Program exchange;
Uses Crt;
const min = 0;
      max = 3;
Var  Words:Array[min..max]of String[10];
     Helper:String[10];
     Index:Byte;

Begin{main}
     ClrScr;
     Words[0]:='Apple';
     Words[1]:='Peach';
     Words[2]:='Sun';
     Words[3]:='Wine';
     {write this results to the screen}
     For Index:=0 To max Do WriteLn(Index,'.',Words[Index]);
     WriteLn;
     {now,we exchange the 0. and the 2. elements}
     Helper:=Words[0];
     Words[0]:=Words[2];
     Words[2]:=Helper;
     {and then write changed results to the screen}
     For Index:=0 To max Do WriteLn(Index,'.',Words[Index]);
     ReadKey;
End.{main}

{Created by FlamingClaw 2009.03.10.}
1
Contributor
0
Replies
1
Views
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.