Please give me inputs about this program. Like is this a good program, does it follow all conventions. Can this program be done in less number of steps etc.
I am a novice in programming and is doing this so that i can become good in programming.
Lots of people are given that exercise. I would suggest you divide your array into several arrays, putting "eleven" "twelve" . . . "nineteen" in one, and "ten" "twenty" . . . "ninety" in another. Using "" or even "\b" for the 0th element in each may make counting easier.
Rob Prime wrote:You'll also want to use another array for the factors of 10. Forty is not four + ty, and eighty is not eight + ty
When my daughter taught English in Indonesia she pointed out how many people said "threety" for "thirty". She thought it endearing, but still had to take a mark off for it.
Thanks for all the inputs. But my first doubt is why are we separating into different arrays. What added advantage would it give. I see that the complexity of an array for getting things at an index is O(1) so how will it make it more efficient.
Jacob Sonia wrote:
Thanks for all the inputs. But my first doubt is why are we separating into different arrays. What added advantage would it give. I see that the complexity of an array for getting things at an index is O(1) so how will it make it more efficient.
Efficiency is not the crux of this current problem (though this is not to say it never is the main issue), simplicity, correctness, and understandability are the issues here, and using separate arrays to keep like with like will make your program much simpler to implement, to upgrade, and to have others understand.