Tuesday, October 18, 2011

Qbasic (To Convert Decimal no. to Hexadecimal)

Rem Deci into Hexa
Declare Sub Subas(H)
Cls
Input "Enter Decimal"; H
Call Subas(H)
End

SUB Subas(H)
K= H
While K>0
R = K MOD 16
Case Select R
Case 10
B$="A"
Case 11
B$ = "B"
Case 12
B$ = "C"
Case 13
B$ = "D"
Case 14
B$= "E"
Case 15
B$ = "F"
CASE ELSE
B$ = STR$(R)
END SELECCT
Z$ = B$ + Z$
K = K\16
WEND
PRINT "H"; "="; "Z$"
END SUB

No comments:

Post a Comment