I have written a program to display numbers from 0-9999 into words. The program is working properly but I am experiencing unexpected output when I enter numbers like, 415,612,819 (basically all numbers that include 0-19 at the end). The program I have written is in c++ and I am currently beginner in c++.
a rough fix: I moved the teens to the correct area of the conditions, added a handler for "zero", and corrected the logic for ten, and I think a little additional logic that was not quite right.
@moazali, The way you have it, if tens==1 it just prints out the "teens" part and quits. You need to still print the thousands and hundreds, although you don't want to print the tens or ones afterwards if you've printed a "teen".
You could make the program a lot nicer by using a couple arrays to hold the repetitive words (like "one","two",etc) which can easily be accessed by index.
And then there's the problem of ensuring you don't have an extra space at the beginning ....