The SWAP statement is used to exchange the values of two variables.
Syntax
LN SWAP variable1, varaible2
Where,
LN : Line Number
variable1 : the first variable
variable2 : the second variable
- Any type of variable may be swapped (numeric or string).
- To use SWAP, the two variables must be of the same type.
Use of SWAP statement in the program.
CS 5.12 Display on the screen for SWAP statement
Ok
LIST
5 REM Learning the use of SWAP statement
10 A$ = "STUDENTS" : B$ = "TEACHERS" : C$ = "HELP"
20 PRINT A$, C$, B$
30 SWAP A$, B$
40 PRINT A$, C$, B$
50 END
Ok
RUN
STUDENTS HELP TEACHERS
TEACHERS HELP STUDENTS
Ok
No comments:
Post a Comment