Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _02_DecimaToBinary
- {
- public class Program
- {
- public static void Main()
- {
- string input;
- while ((input = Console.ReadLine()) != "END")
- {
- int decimalNumber = int.Parse(input);
- string binary = string.Empty;
- while (decimalNumber > 0)
- {
- binary += decimalNumber % 2;
- decimalNumber = decimalNumber / 2;
- }
- for (int i = 0; i < binary.Length; i++)
- {
- Console.Write(binary[binary.Length - i - 1]);
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement