Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- public class Program
- {
- public static void Dec2Bin(int num)
- {
- Stack<int> binary = new Stack<int>();
- while (num != 0)
- {
- binary.Push(num % 2);
- num /= 2;
- }
- while (binary.Count != 0)
- {
- Console.Write(binary.Pop());
- }
- }
- public static void Main()
- {
- Console.Write("Enter number: ");
- int num = int.Parse(Console.ReadLine());
- Stack<int> binary = new Stack<int>();
- while (num != 0)
- {
- binary.Push(num % 2);
- num /= 2;
- }
- while (binary.Count != 0)
- {
- Console.Write(binary.Pop());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement