1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
int main()
{
//declare variables
int getInt, thou, hund, ten, one, temp;
char nums[20][20] = {"", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"};
char tens[10][20] = {"", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"};
//guts of the program
cout << "Enter a number: ";
cin >> getInt;
//Convert thousands
thou = getInt / 1000;
if (thou > 0)
cout << nums[thou] << " thousand ";
getInt = getInt - (thou * 1000);
//Convert hundreds
hun = getInt / 100;
if (hun > 0)
cout << nums[hun] << " hundred ";
//...I THINK YOU CAN TAKE IT FROM HERE
}
|