Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Loops
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.Write("Enter DEC: ");
- int num = int.Parse(Console.ReadLine());
- int num1 = num;
- string bin = "";
- while (num != 0)
- {
- int rem = num % 2;
- bin += rem;
- num /= 2;
- }
- // reverse
- Console.Write($"{num1}(10) = ");
- for (int i = bin.Length - 1; i >= 0 ; i--)
- {
- Console.Write(bin[i]);
- }
- Console.WriteLine("(2)");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement