QBasic Programming

WAP to input number and count total no. of digits

CLS
INPUT "ENTER ANY NUMBER"; N
C = 0
WHILE N < > 0
C = C + 1
N = N \ 10
WEND
PRINT "TOTAL NUMBER OF DIGITS"; C
END
USING SUB PROCEDURE
DECLARE SUB COUNT (N)
CLS
INPUT "ENTER ANY NUMBER"; N
CALL COUNT (N)
END
SUB COUNT (N)
C = 0
WHILE N < > 0
C = C + 1
N = N \ 10
WEND
PRINT "TOTAL NUMBER OF DIGITS"; C
END SUB
USING FUNCTION PROCEDURE

DECLARE FUNCTION COUNT (N)
CLS
INPUT "ENTER ANY NUMBER"; N
PRINT "TOTAL NUMBER OF DIGITS"; COUNT (N)
END

FUNCTION SUM (N)
C = 0
WHILE N < > 0
C = C + 1
N = N \ 10
WEND
COUNT = C
END FUNCTION

WAP to input number and find sum of cube of even digits (Prev Lesson)
(Next Lesson) WAP to input number and count total no. of odd digits
Back to QBasic Programming

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!