Monday 16 April 2012

A simple program to change any number in base ten to another base.

In the study of computer science you must come across number base
problems, this little code here can help you.
CLS
'THIS PROGRAM CHANGES ANY NUMBER IN BASE TEN TO ANY BASE YOU
'WISH TO CHANGE IT TO
DIM B(30)
INPUT "THE NO IN BASE TEN"; D
INPUT "THE NEW BASE YOU WANT TO CHANGE IT TO"; NB
CLS

BT = D
DO
K = K + 1
I = I + 1
E = D MOD NB
D = D \ NB
B(I) = E
LOOP UNTIL D < NB
PRINT
PRINT
PRINT BT; "IN BASE"; NB; "IS"

B(I + 1) = D
FOR I = K + 1 TO 1 STEP -1
COLOR 6
PRINT USING "#"; B(I);
NEXT I
END

No comments:

Post a Comment

Please comment if there's anything you feel can be added or if you have any questions. Thanks.