Public Module Program
Public Sub Main(args() As String)
Console.WriteLine("This program will ask for an integer input and convert it into its binary and octal equivalent")
Dim input As Integer, bitwisebin As String = ""
Dim bitwiseoct As String = ""
Console.Write("Enter a number: ")
input = Console.ReadLine
Console.WriteLine()
Do While (input > 0)
Dim remainder As Integer = input Mod 2
bitwisebin = remainder.ToString & bitwisebin
input = input \ 2
Loop
Console.WriteLine("The binary equivalent of decimal number is {0} ", bitwisebin)
End Sub
End Module
May mga error ka lang sa pag declare ng Module and Sub saka sa args()
Public Module Program
Public Sub Main(args() As String)
Console.WriteLine("This program will ask for an integer input and convert it into its binary and octal equivalent")
Dim input As Integer, bitwisebin As String = ""
Dim bitwiseoct As String = ""
Console.Write("Enter a number: ")
input = Console.ReadLine
Console.WriteLine()
Do While (input > 0)
Dim remainder As Integer = input Mod 2
bitwisebin = remainder.ToString & bitwisebin
input = input \ 2
Loop
Console.WriteLine("The binary equivalent of decimal number is {0} ", bitwisebin)
End Sub
End Module
May mga error ka lang sa pag declare ng Module and Sub saka sa args()
Di po ako marunong masyado sa c#. Pakiayos na lang po kung may error.
Dim ctr As Integer = 1
Do While (input > 0)
Dim remainder As Integer = input Mod 2
If (ctr=1) {
Dim octal As Integer = remainder * 1}
else if (ctr=2){
Dim octal As Integer = remainder * 4}
else if (ctr=3){
Dim octal As Integer = remainder * 2}
else if (ctr=4){
Dim octal As Integer = remainder * 1}
bitwisebin = remainder.ToString & bitwisebin
bitwiseoct = bitwiseoct + octal
input = input \ 2
ctr = ctr + 1
Loop