QBASIC PROGRAM TO CONVERT DECIMAL NUMBER INTO BINARY EQUIVALENT

QBASIC PROGRAM TO CONVERT DECIMAL NUMBER INTO BINARY EQUIVALENT



CLS
 INPUT "ENTER DECIMAL NUMBER"; D
 WHILE D < > 0
 R = D MOD 2
 S$ = STR$(R) + S$
 D = D \ 2
 WEND
 PRINT "BINARY EQUIVALENT VALUE="; S$
 END

USING SUB


DECLARE SUB DECB(D)
 CLS
 INPUT "ENTER DECIMAL NUMBER"; D
 CALL DECB(D)
 END

 SUB DECB(D)
 WHILE D < > 0
 R = D MOD 2
 S$ = STR$(R) + S$
 D = D \ 2
 WEND
 PRINT "BINARY EQUIVALENT VALUE="; S$
 END SUB

USING FUNCTION


DECLARE FUNCTION DECB(D)
 CLS
 INPUT "ENTER DECIMAL NUMBER"; D
 PRINT "BINARY EQUIVALENT VALUE="; DECB$(D)
 END

 FUNCTION DECB$(D)
 WHILE D < > 0
 R = D MOD 2
 S$ = STR$(R) + S$
 D = D \ 2
 WEND
 DECB$=S$
 END FUNCTION

Post a Comment

0 Comments