QBasic Programming

WAP to input number and find product of odd digits

REM
CLS
INPUT "ENTER ANY NUMBER"; N
P = 1
WHILE N < > 0
R = N MOD 10
IF R MOD 2 = 1 THEN P = P * R
N = N \ 10
WEND
PRINT "PRODUCT OF ODD DIGITS"; P
END

USING SUB PROCEDURE

DECLARE SUB PROD (N)
CLS
INPUT "ENTER ANY NUMBER"; N
CALL PROD (N)
END

SUB PROD (N)
P = 1
WHILE N < > 0
R = N MOD 10
IF R MOD 2 = 1 THEN P = P * R
N = N \ 10
WEND
PRINT "PRODUCT OF ODD DIGITS"; P
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION PROD (N)
CLS
INPUT "ENTER ANY NUMBER"; N
PR = PROD (N)
PRINT "PRODUCT OF ODD DIGITS"; PR
END

FUNCTION PROD (N)
P = 1
WHILE N < > 0
R = N MOD 10
IF R MOD 2 = 1 THEN P = P * R
N = N \ 10
WEND
PROD = P
END FUNCTION

WAP to input number and find product of digits (Prev Lesson)
(Next Lesson) WAP to input number and find product of even digits
Back to QBasic Programming
Notice: compact(): Undefined variable: limits in /home/bhimgautam34/public_html/wp-includes/class-wp-comment-query.php on line 853

Notice: compact(): Undefined variable: groupby in /home/bhimgautam34/public_html/wp-includes/class-wp-comment-query.php on line 853

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!