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
- 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 1
- Print all funny words in a string
- Given a sequence of words, print all anagrams together using STL
- Given a sequence of words, print all anagrams together | Set 2
- Print all possible words from phone digits
- Print all possible combinations of words from Dictionary using Trie
- Print words of a string in reverse order
- Print all valid words that are possible using Characters of Array
- Print individual digits as words without using if or switch
- Print number of words, vowels and frequency of each character
- Java ArrayList to print all possible words from phone digits
- Print all words matching a pattern in CamelCase Notation Dictonary
- Print multiples of Unit Digit of Given Number
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.