Wednesday, October 16, 2019

67. Qbasic program to input any number and check whether the given no. is palindrome or not.


67.      Write a sub program to input any number and check whether the given no. is palindrome or not.

DECLARE SUB PALIN (N)
CLS
INPUT "ENTER ANY NUMBER"; N
CALL PALIN (N)
END
SUB PALIN (N)
A = N
S = 0
WHILE N < > 0
R = N MOD 10
S = S * 10 + R
N = N \ 10
WEND
IF A = S THEN
PRINT A; "IS PALINDROME"
ELSE
PRINT A; "IS NOT PALINDROME"
END IF
END SUB

No comments:

Post a Comment