### c++ stacks converting decimal to hexadecimal

Okay so all I need help with is the part where the remainder is 10-15 it outputs the number not the letter. I'm new with stacks and my teacher wants us to use this stack example that he gave us and write the conversion ourselves for decimal to octal and decimal to hex. I have already gotten the octal to work doing it the same way without the if statements. Please help all the other websites I've uses suck and tell me to do things that make no sense and would be too complicated for my level. Thank you
 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118`` ``````#include #include 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); if (remainder==10) { remainder='A'; remainder=number; } else if (remainder==11) { remainder='B'; remainder=number; } else if (remainder==12) { remainder='C'; remainder=number; } else if (remainder==13) { remainder='D'; remainder=number; } else if (remainder==14) { remainder='E'; remainder=number; } else if (remainder==15) { remainder='F'; remainder=number; } number /= 16; } 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; }``````
Topic archived. No new replies allowed.