Can anyone help me...

Discussion in 'Programming' started by pskumarsrec88, Sep 27, 2011.

  1. #1
    Write a function in C# Net that will print out any number from 1 to 10,000 in words. For instance "1" will be "one", "19" will be "nineteen" , "110" will be "One hundred and ten".
    please send the code to my mail or
     
    pskumarsrec88, Sep 27, 2011 IP
  2. Cybernetuk

    Cybernetuk Member

    Messages:
    114
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    28
    #2
    Program to Convert Numbers into Words

    #include<stdio.h>

    void pw(long,char[]);
    char *one[]={" "," one"," two"," three"," four"," five"," six"," seven","
    eight"," Nine"," ten"," eleven"," twelve"," thirteen"," fourteen","
    fifteen"," sixteen"," seventeen"," eighteen"," nineteen"};
    char *ten[]={" "," "," twenty"," thirty"," forty"," fifty"," sixty","
    seventy"," eighty"," ninety"};


    void main()
    {
    long n;
    clrscr();
    printf("
    Enter any 9 digit no: ");
    scanf("%9ld",&n);
    if(n<=0)
    printf("Enter numbers greater than 0");
    else
    {
    pw((n/10000000),"crore");
    pw(((n/100000)%100),"lakh");
    pw(((n/1000)%100),"thousand");
    pw(((n/100)%10),"hundred");
    pw((n%100)," ");
    }
    getch();
    }


    void pw(long n,char ch[])
    {
    (n>19)?printf("%s %s ",ten[n/10],one[n%10]): printf("%s ",one[n]);
    if(n)printf("%s ",ch);
    }
     
    Cybernetuk, Sep 27, 2011 IP