I am trying to write a program to change numbers in binary format. For example, the binary representation of 13 is 1101, and the reversal gives 1011, which corresponds to the number 11 on the right?
Here is my code:
static void Main(string[] args)
{
Console.WriteLine("Enter a Number");
int numb = int.Parse(Console.ReadLine());
int reverse = 0;
while (numb > 0)
{
int rem = numb % 10;
reverse = (reverse * 10) + rem;
numb = numb / 10;
}
Console.WriteLine("Reverse number={0}", reverse);
Console.ReadLine();
}
By this code, I get numbers only for the inverse (13 → 31) ...
The entry must contain a single line with an integer number of N, 1≤N≤1000000000 , and I want my conclusion was on one line with one integer number that I want to get by changing the binary representation of N .
Cleon source
share