nikolayneykov

Untitled

Oct 13th, 2018
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.36 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         int decNum = int.Parse(Console.ReadLine());
  8.         string binNum = string.Empty;
  9.         do
  10.         {
  11.             int bit = decNum % 2;
  12.             binNum = bit + binNum;
  13.             decNum /= 2;
  14.         } while (decNum > 0);
  15.         Console.WriteLine(binNum);
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment