using System;
using System.Linq;
namespace CSN2W
{
class Program
{
static void Main(string[] args)
{
string result;
int i, num;
int[] arrNum =
{
-1, 0, 5, 10, 15, 19, 20, 21, 25, 33, 49, 50, 72,
99, 100, 101, 117, 199, 200, 214, 517, 589, 999,5700,
1000, 1010, 1018, 1200, 9890, 10119, 13535, 57019,
99999, 100000, 100001,1900001,19000010,1111111111,59899999
};
for (i = 0; i < arrNum.Count(); i++)
{
num = arrNum[i];
result = NumberToWord(num);
Console.WriteLine(num + "\t" + result);
}
Console.ReadKey();
}
static string NumberToWord(int num)
{
if (num == 0)
return "Zero";
if (num < 0)
return "Not supported";
var words = "";
string[] strones = { "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen" };
string[] strtens = { "Twenty", "Thirty", "Fourty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety" };
int crore = 0, lakhs = 0, thousands = 0, hundreds = 0, tens = 0, single = 0;
crore = num / 10000000; num = num - crore * 10000000;
lakhs = num / 100000; num = num - lakhs * 100000;
thousands = num / 1000; num = num - thousands * 1000;
hundreds = num / 100; num = num - hundreds * 100;
if (num > 19)
{
tens = num / 10; num = num - tens * 10;
}
single = num;
if (crore > 0)
{
if (crore > 19)
words += NumberToWord(crore) + "Crore ";
else
words += strones[crore - 1] + " Crore ";
}
if (lakhs > 0)
{
if (lakhs > 19)
words += NumberToWord(lakhs) + "Lakh ";
else
words += strones[lakhs - 1] + " Lakh ";
}
if (thousands > 0)
{
if (thousands > 19)
words += NumberToWord(thousands) + "Thousand ";
else
words += strones[thousands - 1] + " Thousand ";
}
if (hundreds > 0)
words += strones[hundreds - 1] + " Hundred ";
if (tens > 0)
words += strtens[tens - 2] + " ";
if (single > 0)
words += strones[single - 1] + " ";
return words;
}
}
}