I've been given an assignment where we must print out an integer digit by digit in english form using a recursive method. E.G. 534 prints out "five three four".
This is what I've got:
int englishInt(int num) {
if(num < 10) {
switch(num) {
case 0: cout << "zero ";
case 1: cout << "one ";
case 2: cout << "two ";
case 3: cout << "three ";
case 4: cout << "four ";
case 5: cout << "five ";
case 6: cout << "six ";
case 7: cout << "seven ";
case 8: cout << "eight ";
case 9: cout << "nine ";
}
} else
return englishInt(num / 10);
}
For some reason it's printing out the lowest digit to the highest digit in English...Shouldn't this keep returning until it reaches the first digit then print it out, and then print out each digit up as the stack unwinds?