DECLARE FUNCTION REV$(N$)
CLS
INPUT "Enter any String"; N$
PRINT "Reversed string is"; REV$(N$)
END
FUNCTION REV$(N$)
FOR J = LEN (N$) TO 1 STEP -1
C$ = MID$(N$,J,1)
W$ = W$+C$
NEXT J
REV$ = W$
END FUNCION
Tuesday, September 2, 2008
Palindrom
DECLARE FUNCTION Word$(w$, rev$)
CLS
INPUT "Enter a word"; w$
IF W$ = Word$(W$, rev$) THEN
PRINT W$; "Is palindrome"
ELSE
PRINT W$; "Is not a palindrome"
END IF
END
FUNCTION word$(w$, rev$)
FOR I = LEN (w$) TO 1 STEP -1
REV$ = REV$+MID$(w$, I, 1)
NEXT I
Word$ = Rev$
END FUNCTION
CLS
INPUT "Enter a word"; w$
IF W$ = Word$(W$, rev$) THEN
PRINT W$; "Is palindrome"
ELSE
PRINT W$; "Is not a palindrome"
END IF
END
FUNCTION word$(w$, rev$)
FOR I = LEN (w$) TO 1 STEP -1
REV$ = REV$+MID$(w$, I, 1)
NEXT I
Word$ = Rev$
END FUNCTION
Subscribe to:
Posts (Atom)
