Testing Palindrome Using Function...End Function

DECLARE FUNCTION rev$(s$)
CLS
INPUT "Enter string to be tested"; t$
t$=LCASE$(t$)
IF t$=rev$(t$) THEN
  PRINT t$;" is Palindrome!"
ELSE
  PRINT t$;" is not Palindrome!"
ENDIF
END

FUNCTION rev$(s$)
FOR I = LEN(s$) to 1 STEP -1
  r$=r$+MID$(s$, I, 1)
NEXT I
rev$=r$
END FUNCTION

1 comment: