Program
Please who can write the program to convert ten billion to words using c# with the algorithm respectively
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Pankaj Kumar ChoudharyRank #80 · 24.4K reputationPosted Apr 1, 2015, 5:31 PM EDT
Code is:
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;
namespace ConsoleApplication1
{
class Program
{
void Convert(long num, string str)
{
string[] st ={" "," one"," two"," three"," four"," five"," six"," seven"," eight"," nine", " ten",
" eleven"," twelve"," thirteen"," fourteen"," fifteen"," sixteen"," seventeen"," eighteen"," ninteen"};
string[] st2 ={" "," "," twenty"," thirty"," fourty"," fifty"," sixty",
" seventy"," eighty"," ninty"};
if (num > 19)
Console.Write(" {0} {1} ", st2[num / 10], st[num % 10]);
else
Console.Write("{0} ", st[num]);
if (num != 0)
Console.Write("{0} ", str);
}
static void Main(string[] args)
{
long n;
Program pg = new Program();
Console.WriteLine("Enter Your Number ");
n = long.Parse(Console.ReadLine());
if (n < 0)
Console.WriteLine("Number Should be greater then 0");
else
{
pg.Convert((n / 10000000), "crore");
pg.Convert(((n / 100000) % 100), "lakh");
pg.Convert(((n / 1000) % 100), "thousand");
pg.Convert(((n / 100) % 10), "hundred");
pg.Convert((n % 100), " ");
}
Console.ReadKey();
}
}
}
gbolahan lawal9 reputationPosted Apr 1, 2015, 9:16 PM EDT
Gagan SikriRank #1,124 · 1.6K reputationPosted Apr 20, 2015, 9:03 AM EDT
http://robertgreiner.com/2011/08/numbertext-converting-numbers-into-words-in-csharp/
Harsh ShahRank #1,322 · 1.3K reputationPosted Dec 1, 2020, 2:05 AM EST