Reverse a phrase

Highlight the following code and save it as a text file called REVERSE.BAS
Put it in the same folder as GW-BASIC.EXE. Load it and run it.

10 REM Reverse the letters of a phrase
20 CLEAR :KEY OFF :CLS
30 INPUT "What is your phrase";PHRASE$
40 PRINT :PRINT "The phrase reversed: ";
50 FOR LETTER = 1 TO LEN(PHRASE$)
60   PRINT LEFT$(RIGHT$(PHRASE$,LETTER),1);
70 NEXT LETTER
80 END

Previous | Home | Next