To convert decimal number into its equivalent hexadecimal number. (Qbasic Code)

To convert decimal number into its equivalent hexadecimal number. (Qbasic Code)
  • CLS
    INPUT "Enter decimal number"; d
    WHILE d <> 0
        r = d MOD 16
        d = d \ 16
        a$ = STR$(r)
        IF r = 10 THEN a$ = "A"
        IF r = 11 THEN a$ = "B"
        IF r = 12 THEN a$ = "C"
        IF r = 13 THEN a$ = "D"
        IF r = 14 THEN a$ = "E"
        IF r = 15 THEN a$ = "F"
        b$ = a$ + b$
    WEND
    PRINT "The equivalent hexadecimal number is "; (b$)
    END
     
Next Method
  • CLS
    INPUT "Enter decimal number"; d
    WHILE d <> 0
        r = d MOD 16
        IF r < 10 THEN
            b$ = STR$(r)
            a$ = b$ + a$
        ELSE
            c$ = CHR$(r + 55)
            a$ = c$ + a$
        END IF
        d = d \ 16
    WEND
    PRINT "The equivalent hexadecimal number is "; a$
    END

Share :

Twitter
Back To Top

facebook main

counter

Powered by Blogger.