PRODUCT OF DIGITS, PRODUCT OF EVEN DIGITS AND PRODUCT OF ODD DIGITS


140. WAP to input number and find product of digits.
REM
CLS
INPUT "ENTER ANY NUMBER"; N
P = 1
WHILE N < > 0
R = N MOD 10
P = P * R
N = N \ 10
WEND
PRINT "PRODUCT OF 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
P = P * R
N = N \ 10
WEND
PRINT "PRODUCT OF DIGITS"; P
END SUB

USING FUNCTION PROCEDURE

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

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

141. 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

142. WAP to input number and find product of even digits.
REM
CLS
INPUT "ENTER ANY NUMBER"; N
P = 1
WHILE N < > 0
R = N MOD 10
IF R MOD 2 = 0 THEN P = P * R
N = N \ 10
WEND
PRINT "PRODUCT OF EVEN 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 = 0 THEN P = P * R
N = N \ 10
WEND
PRINT "PRODUCT OF EVEN DIGITS"; P
END SUB

USING FUNCTION PROCEDURE

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

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

Comments

Samjhauta said…
thank you for this program


Blog27999 said…
If you're trying to lose kilograms then you certainly need to start following this brand new personalized keto meal plan.

To create this service, licensed nutritionists, fitness couches, and top chefs have joined together to develop keto meal plans that are effective, convenient, money-efficient, and enjoyable.

Since their launch in January 2019, hundreds of people have already remodeled their figure and well-being with the benefits a smart keto meal plan can offer.

Speaking of benefits: clicking this link, you'll discover 8 scientifically-confirmed ones given by the keto meal plan.

Popular posts from this blog

PROGRAM TO FIND SQUARE, CUBE, SQUARE ROOT AND CUBE ROOT OF GIVEN NUMBER

PROGRAM TO DISPLAY SUM, PRODUCT, DIFFERENCE AND PRODUCT OF TWO / THREE NUMBERS

PALINDROME AND ARMSTRONG PROGRAMS