Qbasic program to find whether a number is palindrome or not
CLS
INPUT "ENTER ANY NUMBER"; 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
USING SUB
DECLARE SUB PALINDROME(N)
CLS
INPUT "ENTER ANY NUMBER"; N
CALL PALINDROME(N)
END
SUB PALINDROME(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
0 Comments