QBasic Programming

WAP to input number and find sum of cube of digits

CLS
INPUT "ENTER ANY NUMBER"; N
S = 0
WHILE N < > 0
R = N MOD 10
S = S + R ^ 3
N = N \ 10
WEND
PRINT "SUM OF CUBE OF DIGITS"; S
END
USING SUB PROCEDURE
DECLARE SUB SUMCB (N)
CLS
INPUT "ENTER ANY NUMBER"; N
CALL SUMCB (N)
END
SUB SUMCB (N)
S = 0
WHILE N < > 0
R = N MOD 10
S = S + R ^ 3
N = N \ 10
WEND
PRINT "SUM OF CUBE OF  DIGITS"; S
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION SUMCB (N)
CLS
INPUT "ENTER ANY NUMBER"; N
SU = SUMCB (N)
PRINT "SUM OF CUBE OF DIGITS"; SU
END
FUNCTION SUMCB (N)
S = 0
WHILE N < > 0
R = N MOD 10
S = S + R ^ 3
N = N \ 10
WEND
SUMCB = S : END FUNCTION

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

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!