Thursday, October 17, 2019

127. Qbasic program to test whether the input word is palindrome word or not

127.      Write a program to test whether the input word is palindrome word or not using FUNCTION…………END FUNCTION.

DECLARE FUNCTION REV$ (S$)
CLS
INPUT "ENTER ANY STRING"; S$
C$ = REV$(S$)
IF S$ = C$ THEN
PRINT   “THE GIVEN STRING IS PALINDROME”
ELSE
PRINT  “THE GIVEN STRING IS NOT PALINDROME”
END IF
END

FUNCTION REV$ (S$)
FOR I = LEN(S$) TO 1 STEP -1
B$ = MID$(S$, I, 1)
W$ = W$ + B$
NEXT I
REV$ = W$
END FUNCTION

No comments:

Post a Comment