' REVERSE.BAS
' This program reverses the order of the characters in a string.

CLS
                                         ' get string from user
INPUT "Enter a string of characters to be reversed:  ", inString$
numOfChars% = LEN(inString$)             ' find length of string

FOR i% = numOfChars% TO 1 STEP -1        ' step backwards through string
    tempChar$ = MID$(inString$, i%, 1)   ' extract one letter at a time
    reverse$ = reverse$ + tempChar$      ' build new string
NEXT i%

PRINT                                    ' display new string
PRINT "The characters in reverse order are "; reverse$

