Syntax Convert Decimal to Binary and otherwise vb.net


-Convert decimal to binary

module prog
sub main()
Dim desimal As Integer
Dim bineri As String
desimal=cint(console.readline())
bineri = “”
While desimal >0
bineri = desimal Mod 2 & bineri
desimal = desimal \ 2
end while
console.writeline(bineri)
end sub
end module

——————————

– Convert binary to decimal

module prog
sub main()
dim bin as string
Dim dec As Double
bin=console.readline()
Dim length As Integer = len(bin)
Dim temp As Integer
Dim x As Integer
For x = 1 To length
temp = cint(Mid(Bin,length,1))
length = length – 1
If temp <> cdbl(“0”) Then
dec += (2 ^ (x – 1))
End If
Next
console.writeline(dec)
end sub
end module

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: