Home / Programs / C# Program to Convert Number in Characters
🚀 Programming Example

C# Program to Convert Number in Characters

👁 623 Views
💻 Practical Program
📘 Step Learning

In C# language, we can easily convert number in characters by the help of loop and switch case. In this program, we are taking input from the user and iterating this number until it is 0. While iteration, we are dividing it by 10 and the remainder is passed in switch case to get the word for the number.

Let us see the C# program to convert number in characters.

💻 Program Code

using System;  
  public class ConversionExample  
   {  
     public static void Main(string[] args)  
      {  
       int n,sum=0,r;     
       Console.Write("Enter the Number= ");    
       n= int.Parse(Console.ReadLine());     
       while(n>0)      
       {      
        r=n%10;      
        sum=sum*10+r;      
        n=n/10;      
       }      
       n=sum;      
       while(n>0)      
       {      
        r=n%10;      
        switch(r)      
        {      
         case 1:      
         Console.Write("one ");  
         break;      
         case 2:      
         Console.Write("two ");      
         break;      
         case 3:      
         Console.Write("three ");    
         break;      
         case 4:      
         Console.Write("four ");    
         break;      
         case 5:      
         Console.Write("five ");    
         break;      
         case 6:      
         Console.Write("six ");     
         break;      
         case 7:    
         Console.Write("seven ");    
         break;    
         case 8:      
         Console.Write("eight ");      
         break;      
         case 9:      
         Console.Write("nine ");    
         break;      
         case 0:      
         Console.Write("zero ");    
         break;      
         default:      
         Console.Write("tttt ");      
         break;      
        }//end of switch      
        n=n/10;      
       }//end of while loop       
   }  
  }  
                        

🖥 Program Output

Enter the Number= 357546
three five seven five four six
                            

📘 Explanation

None
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.