Numbers into words | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Numbers into words

for example 1421 is given the output shown by computer is one thousand four hundred twenty one

24th Sep 2018, 3:16 PM
Anil Yadav
Anil Yadav - avatar
1 Answer
+ 2
If you are asking how would I take an input of 1421 and turn it into one thousand four hundred twenty one, you would have to use division and incrementing values. So, take 1421, see how many digits it contains (4), divide by 1000, then divide by 100 four times, then 10 twice, etc. Then output (number of times divided by 1000) thousand (number of times divided by 100) hundred, etc
23rd Nov 2018, 5:51 AM
Pete Cowling
Pete Cowling - avatar