Advertisement
zh_stoqnov

DecimalToBinaryNumber

Oct 22nd, 2014
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Decimal_to_Binary_Number
  4. {
  5. class DecimalToBinaryNumber
  6. {
  7. public static void Main(string[] args)
  8. {
  9. long dec = long.Parse(Console.ReadLine());
  10. string binElement = "";
  11. while (dec != 0)
  12. {
  13. int remain = (int) dec % 2;
  14. dec /= 2;
  15. binElement = remain + binElement;
  16. }
  17. Console.WriteLine(binElement);
  18. }
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement