TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

C# Program to Convert Number in Characters

C# Program to Convert Number in Characters for beginners and professionals with examples on overloading, method overriding, inheritance, aggregation, base, polymorphism, sealed, abstract, interface, namespaces, exception handling, file io, collections, multithreading, reflection etc.

<< Back to C-SHARP

C# Program to Convert Number in Characters

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's see the C# program to convert number in characters.

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




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf