C# Code for converting Digits to words from number 1 to 100099 (Dotnet)

Google+ Pinterest LinkedIn Tumblr +

using System;

namespace DigitsToWords

{

///

/// Summary description for Class1.

///

class Class1

{

///

/// The main entry point for the application.

///

/// 

[STAThread]

static void Main(string[] args)

{

//

// TODO: Add code to start application here

//

//             This Program is For numbers less Than  equal to 100099

            Console.WriteLine(“*****  This Program is For numbers less Than equal to 100099  *****”);

Console.WriteLine(“*****  Enter Any No Between 1 and 100099  *****”);

            int r,i;

int l=int.Parse(Console.ReadLine());

string []a={” One “,” Two “,” Three “,” Four “,” Five “,” Six “,” Seven “,” Eight “,” Nine “,” Ten “};

string []b={” Eleven “,” Twelve “,” Thirteen “,” Fourteen “,” Fifteen “,” Sixteen “,” Seventeen “,” Eighteen “,” Nineteen “};

string []c={“Ten”,” Twenty “,” Thirty “,” Fourty “,” Fifty “,” Sixty “,” Seventy “,” Eighty “,” Ninety “,” Hundred ” };

if(l>9999)

{

                r=l/1000;

if(r>10&&r<20)

{

r=r;

Console.Write(b[r-1]+ “Thousand “);

}

else if(r==10 || r==20||r==30||r==40||r==50||r==60||r==70||r==80||r==90||r==100)

{

r=r/10;

Console.Write( c[r-1]+ ” Thousand “);

}

else 

{

i=r/10;

r=r;

Console.Write(c[i-1] + a[r-1] +” Thousand ” );

}

l=l00;

}

if(l>1000)

{

r=l/1000;

Console.Write(a[r-1] +” Thousand “);

                l=l00;

}

if(l>100)

{

r=l/100;

Console.Write(a[r-1] + ” Hundred “);

l=l0;

}

if(l>10&&l<20)

{

r=l;

Console.Write(b[r-1]);

       }

if(l>19&&l<=100)

{

r=l/10;

i=l;

Console.Write(c[r-1] + a[i-1]);

   }

if(l>0&&l<=10)

{

Console.Write(a[l-1]);

}

            Console.ReadLine();

}

}

}

Example:

*****  This Program is For numbers less Than equal to 100099  *****

*****  Enter Any No Less between 1 and 100099  *****

12345

 Twelve Thousand  Three  Hundred  Fourty  Five 

 

Share.

About Author

Leave A Reply