Advertisement
Opteronic

Decimal to Binary Converting

Feb 19th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.47 KB | None | 0 0
  1. using System;
  2.  
  3. class DecimalToBinary
  4. {
  5.     static void Main()
  6.     {
  7.         long number = long.Parse(Console.ReadLine());
  8.         string binary = "";
  9.         
  10.         do
  11.         {
  12.             binary = Convert.ToString(number % 2) + binary;
  13.             number /= 2;
  14.  
  15.         } while (number > 0);
  16.  
  17.         Console.WriteLine(binary);
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement