To convert binary number into its equivalent decimal number (Qbasic Code)

To convert binary number into its equivalent decimal number (Qbasic Code)
  • CLS
    INPUT "Enter binary number"; b$
    FOR i = LEN(b$) TO 1 STEP -1
        d$ = MID$(b$, i, 1)
        d = VAL(d$) * 2 ^ a
        dec = dec + d
        a = a + 1
    NEXT i
    PRINT "The equivalent decimal number is "; dec
    END
Next Method
  • CLS
    INPUT "Enter binary number"; a
    WHILE a <> 0
        r = a MOD 10
        s = s + r * 2 ^ p
        p = p + 1
        a = a \ 10
    WEND
    PRINT "The equivalent decimal is "; s
    END

Share :

Twitter
Back To Top

facebook main

counter

Powered by Blogger.