C Program
#include <stdio.h> int main() { int n; scanf("%d", &n); int r[10], i = 0; while (n) r[i++] = n % 10, n /= 10; for (int j = i-1; j >= 0; j++) { switch(r[j]) { case 0: printf("Zero "); break; case 1: printf("One "); break; case 2: printf("Two "); break; case 3: printf("Three "); break; case 4: printf("Four "); break; case 5: printf("Five "); break; case 6: printf("Six "); break; case 7: printf("Seven "); break; case 8: printf("Eight "); break; case 9: printf("Nine "); break; } } }
C Output
Input:
501Output:
Five Zero One
C++ Program
#include <iostream>
using namespace std;
string w[] = {"Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine"};
int main() {
string n; cin >> n;
for (char c : n) cout << w[c - '0'] << " ";
}
C++ Output
Input:
2048Output:
Two Zero Four Eight
JAVA Program
import java.util.*; public class Main { public static void main(String[] a) { String[] w = {"Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine"}; String n = new Scanner(System.in).next(); for (char c : n.toCharArray()) System.out.print(w[c - '0'] + " "); } }
JAVA Output
Input:
79Output:
Seven Nine
Python Program
w = ["Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Nine"] print(*[w[int(d)] for d in input()])
Python Output
Input:
835Output:
Eight Three Five
In-Depth Explanation
Example
If the number is 501, then digit by digit it is converted to:
5 → Five
0 → Zero
1 → One
Thus the result is: Five Zero One
Each digit is converted individually and printed out with a space between them. This is not converting into full sentence words such as "Five hundred one" — it converts digit-by-digit which is very frequently needed for educational, banking, or form-based systems.
Real-Life Analogy
You’ve likely heard automated voice systems or exam readouts:
"Your roll number is. Five Zero One"
That's exactly the use case here. The system reads the number digit by digit so it can’t be misinterpreted. You’ll also see this in ATMs, OTP generators, phone verification, and shipping barcodes.
Why It Matters
Digit-to-word conversion is essential in:
Voice assistants
Accessibility tools for the visually impaired
Educational apps
Speech generation from numerical data
Audio OTP systems
This also fortifies string parsing, indexing, character-to-integer mapping, and control logic basics.
Learning Insights
You will learn how to:
Transform digits from characters to indexes (c - '0')
Map indexes to word arrays
Employ string and loop control to create custom output
Escape advanced logic using arrays and indexing cleverly
This is a tidy way to reinforce fundamentals while tackling an actual real-world micro-problem.
Interview & Project Relevance
This is the kind of problem typically posed in entry-level interviews to try:
String and number manipulation
Control structures (switch/case, loops)
Indexing proficiency
Precision of output formatting
Applications in real life involve:
IVR systems
Result announcers
Number-to-speech converters
Utility bill displays
Converting digits to word-form digit by digit is a very applied programming problem employed in education, sound equipment, and number-reading software. This problem is a building block to more advanced problems such as check writing applications or text-to-speech software. The solutions of C, C++, Java, and Python presented above are the most concise and tidy and are within the reach of beginners and intermediate learners.
Social Plugin