I have to write a program such that I give it a three digit input and it converts it into word format. example:
input = 907
output = nine hundred seven
I can easily figure out how to give the hundred position output. I can divide the input by 100 and then store the whole part of result into a new variable. and then if the variable has value, let's say 7
make another new variable of character type and give it a value seven
using if conditionals.
But I can't figure out what to do for tens and ones. I mean when there is a number like 907
, do I write something so that it gives me the correct output.
PS I just started programming and don't know the best method to do this.
What is the correct way to handle this?
There are good libraries they can perform this kind of task for you. However you can get the result using :
To use in loops you can use:
I use this: