#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

#### Categories

Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

# Problem with a program

2»

• Posts: 757Member
: [code]: PROGRAM bla;
{...}
T:=R;
R:=M;
M:=T;
writeln ('');
writeln ('Here are the numbers after one switch: ');
{...}
END.[/code]:

Also note that the original value of T will be lost as T becomes R and then when M:=T; comes, it is actually M:=R; If you want to rotate, you will need a fourth variable to use as a temporary storage for T.

Phat Nat
· ·
• Posts: 438Member
: : [code]: : PROGRAM bla;
: {...}
: T:=R;
: R:=M;
: M:=T;
: writeln ('');
: writeln ('Here are the numbers after one switch: ');
: {...}
: END.[/code]: :
:
: Also note that the original value of T will be lost as T becomes R
: and then when M:=T; comes, it is actually M:=R; If you want to
: rotate, you will need a fourth variable to use as a temporary
: storage for T.
:
: Phat Nat

T is the fourth variable as you can see from this fragment of his code.
[code]
VAR
L:integer; {Left}
R:integer; {Right}
M:integer; {Middle}
T:integer; {Temporary}
[/code]
And he's not rotating. He's switching one end and then, if the first switch did not do the job, he switches the other end.

· ·
2»