Thursday, November 24, 2016

Conversion of decimal numbers into other number system and vice versa


Conversion of decimal numbers into other number system and vice versa
CLS
p = 1
INPUT "please enter any number="; d
WHILE d <> 0
    r = d MOD 8
    o = o + p * r
    p = 10 * p
    d = d \ 8
WEND
PRINT " the required octal number is="; o
END

2.                Write a QBASIC program to convert any decimal number into binary number.
CLS
p = 1
INPUT "please enter any number="; d
WHILE d <> 0
    r = d MOD 2
    b = b+ p * r
    p = 10 * p
    d = d \ 2
WEND
PRINT " the required binary number is="; b
END



3.                Write a QBASIC program to convert any binary number into decimal number.
CLS
p = 1
INPUT "please enter any number="; b
WHILE b <> 0
    r = b MOD 10
    d = d + p * r
    p = 2 * p
    b = b \ 10
WEND
PRINT " the required decimal number is="; d
END


4.               Write a QBASIC program to c⊬onvert any octal number into decimal number.

CLS
p = 1
INPUT "please enter any octal number="; o
WHILE o <> 0
    r = o MOD 10
    d = d + p * r
    p = 8 * p
    o = o \ 10
WEND
PRINT " the required decimal number is="; d
END




3 comments:

Featured Post

Conversion of decimal numbers into other number system and vice versa

ht Conversion of decimal numbers into other number system and vice versa 1. Write a QBASIC program to convert any decimal number in...