Ok...I wrote this code up, which works fine for converting an integer to base 2. The only problem I'm having is how do I reverse the stack? Will anyone help? Here is the code.
#include <iostream>
#include "StackLibrary.h"
using namespace std;
int main()
{
STACK <int, 10> s;
STACK <int, 10> p;
s.MakeStack();
int n;
cout<< "Enter a positve integer below 1000: ";
cout<<endl;
cin>>n;
for( int i=1; n>=1; ++i)
{
s.PushStack(n%2);
for( int j=1; j<=1; ++j)
{
n=(n/2);
}
}
while(!s.EmptyStack())
{
int q= s.PopStack();
p.PushStack(q);
}
while(!p.EmptyStack())
{
int a= p.PopStack();
cout<<a;
}