QBasic Programming

WAP to display first 20 palindrome numbers

CLS
N = 1 : CNT = 1
TOP:
A = N
S = 0
WHILE A < > 0
R = A MOD 10
S = S * 10 + R
A = A \ 10
WEND
IF N = S THEN
PRINT N,
CNT = CNT + 1
END IF
N = N + 1
IF CNT <= 20 THEN GOTO TOP
END
USING SUB PROCEDURE
DECLARE SUB PALIN ( )
CLS
CALL PALIN
END
SUB PALIN
N = 1
CNT = 1
TOP:
A = N : S = 0
WHILE A < > 0
R = A MOD 10
S = S * 10 + R
A = A \ 10
WEND
IF N = S THEN
PRINT N,
CNT = CNT + 1
END IF
N = N + 1
IF CNT <= 20 THEN GOTO TOP
END SUB

WAP to input any number and check whether the given no. is palindrome or not (Prev Lesson)
(Next Lesson) WAP to display all palindrome numbers from 1 to 200
Back to QBasic Programming

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!