Advertisement
zontak

DecimalToBinary

Apr 3rd, 2014
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. using System;
  2. class DecimalToBinary
  3. {
  4. static void Main()
  5. {
  6. long num = long.Parse(Console.ReadLine());
  7. long result;
  8. string binary = string.Empty;
  9.  
  10. while (num > 0)
  11. {
  12. result = num % 2;
  13. num /= 2;
  14. binary = result.ToString() + binary;
  15. }
  16. Console.WriteLine(binary);
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement