Reverse String in Commodore Basic

Published on 16 September 2023 (Updated: 16 September 2023)

Welcome to the Reverse String in Commodore Basic page! Here, you'll find the source code for this program as well as a description of how the program works.

Current Solution

5 REM Input string
10 GOSUB 1000
20 R$ = ""
30 IF S$ = "" THEN GOTO 70
40 FOR K = LEN(S$) TO 1 STEP -1
50     R$ = R$ + MID$(S$, K, 1)
60 NEXT K
70 PRINT R$
80 END
1000 REM Read input value one character at a time since Commodore BASIC
1001 REM has trouble reading line from stdin properly
1002 REM S$ = string
1003 REM Initialize
1010 S$ = ""
1015 REM Append characters until end of value or input
1020 GET A$
1030 C = ASC(A$)
1040 IF C = 13 OR C = 255 THEN RETURN: REM end of value or input
1050 S$ = S$ + A$
1060 GOTO 1020

Reverse String in Commodore Basic was written by:

If you see anything you'd like to change or update, please consider contributing.

How to Implement the Solution

No 'How to Implement the Solution' section available. Please consider contributing.

How to Run the Solution

No 'How to Run the Solution' section available. Please consider contributing.