I need the code in console Applecation

Recommended Answers

All 2 Replies

using System;
using System.Collections.Generic;
using System.Text;

namespace TestBed {
    class TestBed {
        static void Main() {
            Stack<int> myStack = new Stack<int>();
            decimal d = 4234234234234;

            decimal t = d;
            while (t > 0) {
                int r = (int)(t % 2);
                myStack.Push(r);
                t = Math.Floor(t/2);
            }

            StringBuilder sb = new StringBuilder();
            while (myStack.Count > 0) {
                sb.Append(myStack.Pop());
            }

            Console.WriteLine("{0} in binary is {1}", d, sb.ToString());

            Console.ReadLine();

        }
    }
}

I sure hope I get an A on this assignment!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.