My code works for numbers that dont have a remainder of 10 or above, but whenever I get one with a remainder 10 or above it prints out the number, not the letter. Please help
#include <iostream>
#include <fstream>
using namespace std;
const int maxstack = 51;
class stack_type
{
public:
void clear_stack();
bool empty_stack();
bool full_stack();
void push (int numb);
void pop (int& numb);
int stack[maxstack];
int top;
};
void main()
{
stack_type remainder_stack;
int n, number, remainder;
char response;
remainder_stack.clear_stack();
do
{
cout << "Enter positive integer to convert to base 16: \n\n";
cin >> number;
n = number;
cout << number << "\n";
while (number != 0)
{
remainder = number % 16;
remainder_stack.push(remainder);
number /= 16;
if (remainder==10)
{
remainder='A';
}
else if (remainder==11)
{
remainder='B';
}
else if (remainder==12)
{
remainder='C';
}
else if (remainder==13)
{
remainder='D';
}
else if (remainder==14)
{
remainder='E';
}
else if (remainder==15)
{
remainder='F';
}
}
cout << "Base 16 representation of " << n << " is ";
while (!remainder_stack.empty_stack())
{
remainder_stack.pop(remainder);
cout << remainder;
}
cout << endl;
cout << "\nMore (Y or N)? :";
cin >> response;
}
while (response=='Y' || response=='y');
}
void stack_type::clear_stack()
{
top=0;
}
bool stack_type::empty_stack()
{
if (top==0)
return true;
else
return false;
}
bool stack_type::full_stack()
{
if (top==maxstack-1)
return true;
else
return false;
}
void stack_type::push (int numb)
{
top = top + 1;
stack[top] = numb;
}
void stack_type::pop (int& numb)
{
numb = stack[top];
top = top - 1;
}