Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class DecimalToBinaryNumber
- {
- static void Main()
- {
- Console.Write("Enter a decimal number : ");
- long num = long.Parse(Console.ReadLine());
- string finalNumber = " ";
- while (num > 0)
- {
- if (num % 2 == 0)
- {
- finalNumber += '0';
- num = num / 2;
- }
- else
- {
- finalNumber += '1';
- num = num / 2;
- }
- }
- Console.WriteLine(finalNumber);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement