Counts digits in different bases

Counts digits in different bases.

Counts digits in different bases // For instance 232223 has 4 2’s in base 10, 15 has 4 1’s in base 2 #include using namespace std; //This should return the number of 1’s in the binary representation //of the input number (in decimal) int CountBinOnes(int dec_number) { //base case //recursive case //This should return the number of ‘digits’ in the ‘base’ representation //of the input number (in decimal) //This only has to work for bases between 2-10 and digits 0-9 int CountBaseDigits(int dec_number, int base, int digit) { //base case //recursive case //This should display the number in the ‘base’ representation void PrintBaseDigits(int dec_number, int base) { //a shortcut function to do error checking and ensure we have an integer void GetInput(int &input) { //get inputs cin >> input; while( !cin ) { cin.clear(); cin.ignore(2000, ‘n’); cout

Counts digits in different bases

Posted in Uncategorized