Given a number N, the task is to convert every digit of the number into words.
Input: N = 1234
Output: One Two Three Four
Every digit of the given number has been converted into its corresponding word.
Input: N = 567
Output: Five Six Seven
Approach: The idea is to traverse through every digit of the number and use switch-case. Since there are only ten possible values for digits, ten cases can be defined inside a switch block. For each digit, its corresponding case block will be executed and that digit will get printed in words.
Below is the implementation of the above approach:
One Two Three
Related Article: Print individual digits as words without using if or switch
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Java program to print Even length words in a String
- Python program to print even length words in a string
- Python Program to print digit pattern
- Given a sequence of words, print all anagrams together | Set 2
- Print all funny words in a string
- Given a sequence of words, print all anagrams together | Set 1
- Print all the non-repeating words from the two given sentences
- Print all possible words from phone digits
- Given a sequence of words, print all anagrams together using STL
- Print words of a string in reverse order
- Print all possible combinations of words from Dictionary using Trie
- Print individual digits as words without using if or switch
- Print all valid words that are possible using Characters of Array
- Print number of words, vowels and frequency of each character
- Java ArrayList to print all possible words from phone digits
- Extract and print words separately from a given Camel Case string
- Print all words matching a pattern in CamelCase Notation Dictonary
- Program to convert a given number to words
- Program to reverse words in a given string in C++
- Program to extract words from a given String
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.