QBasic Programming

WAP to input number and find sum of cube of even digits

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

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

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!