The problem for my CMPT103 class is to write a program that takes a binary number as an integer and returns it as a decimal, i would be able to do this easily by taking it as a charecter array and dealing with each individual element but i dont understand how to do this. my teacher gave us 3 functions we have to use and a descrption of what theyre supposed to do:

• bool convertBin(int &binary);

This function will take an integer value that is in binary and change it to a decimal value. In the event that the conversion is not possible (for example, trying to convert 6 from binary to decimal), the function will return false and leave binary untouched. If the conversion is possible, then binary will contain the converted number, and the function will return true.

• int lastDig(int num);

This function returns the last digit of num.

• int removeLast(int num);

This function returns a number without the last digit. For example, removeLast(123) would return 12. The body of this function can be accomplished with one line.

i assume im supposed to use lastDIG to make sure its a 0 or 1 and then evalate it, based on how many times ive used removeLast, then use removeLast to get rid of it and continue but i dont know how to deal with each digit? please help! thanks!

P.S. sorry i screwed up the title it should say binary not boolean