C# Program to Convert Number in Characters

C# Programming Language Loop control in C# Language (Article) Loop control in C# Language (Program)

544

Program:

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       
   }  
  }  

Output:

Enter the Number= 357546
three five seven five four six

Explanation:

None

This Particular section is dedicated to Programs only. If you want learn more about C# Programming Language. Then you can visit below links to get more depth on this subject.