To find the product of the individual digits of the given number. (Qbasic Code)

To find the product of the individual digits of the given number
  • CLS
    INPUT "Enter a number"; n
    p = 1
    WHILE n <> 0
        r = n MOD 10
        p = p * r
        n = n \ 10
    WEND
    PRINT "The product of the digits is"; p
    END

To find the product of individual digits of given number without using CALL statement.
  • DECLARE sub pro (n)
    CLS
    INPUT "Enter a number"; n
    pro n
    END
    SUB pro (n)
    p = 1
    WHILE n <> 0
        r = n MOD 10
        p = p * r
        n = n \ 10
    WEND
    PRINT "The product of the digits is"; p
    END SUB

Share :

Twitter
Back To Top

facebook main

counter

Powered by Blogger.