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
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Count of N-digit numbers having digit XOR as single digit
- Check if the given string of words can be formed from words present in the dictionary
- Count words that appear exactly two times in an array of words
- Python program to print even length words in a string
- Java program to print Even length words in a String
- Generate a number such that the frequency of each digit is digit times the frequency in given number
- Given a sequence of words, print all anagrams together | Set 1
- Given a sequence of words, print all anagrams together | Set 2
- Given a sequence of words, print all anagrams together using STL
- Print all the non-repeating words from the two given sentences
- Extract and print words separately from a given Camel Case string
- Program to extract words from a given String
- Program to reverse words in a given string in C++
- Python Program to print digit pattern
- Check if frequency of each digit is less than the digit
- Count n digit numbers not having a particular digit
- Perform n steps to convert every digit of a number in the format [count][digit]
- Largest number less than N with digit sum greater than the digit sum of N
- Count of Numbers in Range where first digit is equal to last digit of the number
- Count numbers in a range with digit sum divisible by K having first and last digit different
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.