QBasic Programming

WAP TO ENTER ANY DIGIT AND DISPLAY ITS REVERSED FORM

CLS
INPUT "ENTER ANY NUMBER"; N
S = 0
WHILE N < > 0
R = N MOD 10
S = S * 10 + R
N = N \ 10
WEND
PRINT "REVERSED DIGITS="; S
END
USING SUB PROCEDURE
DECLARE SUB REV (N)
CLS
INPUT "ENTER ANY NUMBER"; N
CALL REV (N)
END
SUB REV (N)
S = 0
WHILE N < > 0
R = N MOD 10
S = S * 10 + R
N = N \ 10
WEND
PRINT " REVERSED DIGITS="; S
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION REV (N)
CLS
INPUT "ENTER ANY NUMBER"; N
PRINT " REVERSED DIGITS="; REV (N)
END
FUNCTION REV (N)
S = 0
WHILE N < > 0
R = N MOD 10
S = S * 10 + R
N = N \ 10
WEND
REV = S : END FUNCTION

WAP to enter any 10 numbers and find the sum of even numbers (Prev Lesson)
(Next Lesson) WAP to input any number and check whether the given no. is palindrome or not
Back to QBasic Programming

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!