Number To Word Conversion

Princy Prakash
2 min readMay 25, 2023

--

ALGORITHM:

  1. Prompt the user to enter a number and store it in a variable n.
  2. Initialize a variable newnum to 0.
  3. Repeat the following steps until n becomes 0:
  • Calculate the remainder of n divided by 10 and store it in a variable remainder.
  • Multiply newnum by 10 and add the value of remainder to it, updating the value of newnum.
  • Divide n by 10 using integer division to remove the last digit.

4. Repeat the following steps until newnum becomes 0:

  • Calculate the remainder of newnum divided by 10 and store it in a variable num.
  • Check the value of num and perform the corresponding action:
  • If num is equal to 1, print "one".
  • Elif num is equal to 2, print "two".
  • Elif num is equal to 3, print "three".
  • Elif num is equal to 4, print "four".
  • Elif num is equal to 5, print "five".
  • Elif num is equal to 6, print "six".
  • Elif num is equal to 7, print "seven".
  • Elif num is equal to 8, print "eight".
  • Elif num is equal to 9, print "nine".
  • Else print”Zero”
  • Divide newnum by 10 using integer division to remove the last digit.

CONCLUSION:

This algorithm takes the input number n and reverses it by extracting the last digit and appending it to newnum. Then, it iterates over each digit of newnum and prints the corresponding word for each digit using a series of conditional statements.

FLOWCHART:

--

--

Princy Prakash
Princy Prakash

Written by Princy Prakash

Hi I Am Princy. I recently discovered my passion for programming and excited to get deeper into the world of technologies also in problem-solving

No responses yet