Program to print the given digit in words | C ++ implementation of the above approach ; Function to return the word of the corresponding digit ; Switch block to check for each digit c ; For digit 0 ; For digit 1 ; For digit 2 ; For digit 3 ; For digit 4 ; For digit 5 ; For digit 6 ; For digit 7 ; For digit 8 ; For digit 9 ; Function to iterate through every digit in the given number ; Finding each digit of the number ; Print the digit in words ; Driver code
#include " bits / stdc + + . h " NEW_LINE using namespace std ; void printValue ( char digit ) { switch ( digit ) { case '0' : cout << " Zero ▁ " ; break ; case '1' : cout << " One ▁ " ; break ; case '2' : cout << " Two ▁ " ; break ; case '3' : cout << " Three ▁ " ; break ; case '4' : cout << " Four ▁ " ; break ; case '5' : cout << " Five ▁ " ; break ; case '6' : cout << " Six ▁ " ; break ; case '7' : cout << " Seven ▁ " ; break ; case '8' : cout << " Eight ▁ " ; break ; case '9' : cout << " Nine ▁ " ; break ; } } void printWord ( string N ) { int i , length = N . length ( ) ; for ( i = 0 ; i < length ; i ++ ) { printValue ( N [ i ] ) ; } } int main ( ) { string N = "123" ; printWord ( N ) ; return 0 ; }