Exforsys
+ Reply to Thread
Results 1 to 4 of 4

A tough program help me please

This is a discussion on A tough program help me please within the C and C++ forums, part of the Programming Talk category; How to solve a program if an user inputs an number example say 1 ;the output must be in words ...

  1. #1
    subash is offline Junior Member Array
    Join Date
    Mar 2011
    Answers
    1

    Smile A tough program help me please

    How to solve a program if an user inputs an number example say 1 ;the output must be in words example: ONE for all value that user gives 'n'


  2. #2
    Aliza Aile is offline Junior Member Array
    Join Date
    Mar 2011
    Answers
    2
    the definition of threads explains a process within a process is and it states also a running program is called thread.


  3. #3
    Aliza Aile is offline Junior Member Array
    Join Date
    Mar 2011
    Answers
    2
    now come to your post it is so simple if an user inputs an number example say 1 ;the output must be in words example: ONE
    you can check the same using switch statement check if user enters 1 put a string for example
    switch(n)
    case 1
    print "one"
    case 2
    print "two"
    so on...


  4. #4
    swapwarick's Avatar
    swapwarick is offline Member Array
    Join Date
    Mar 2011
    Location
    Pune,India
    Answers
    37
    #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();
    }

    this is code is in C.....


    for CPP

    #include<iostream.h>
    #include<conio.h>
    void main()
    {
    int a[5],i,n;
    clrscr();
    cout<<"Enter the Value";
    cin>>n;
    for(i=4;i>=0;i--)
    {
    a[i]=n%10;
    n=n/10;
    }
    for(i=0;i<5;i++)
    {
    if(a[i]!=0)
    {
    switch(a[i])
    {
    case 0:cout<<"Zero";
    break;
    case 1:cout<<"One";
    break;
    case 2:cout<<"Two";
    break;
    case 3:cout<<"Three";
    break;
    case 4:cout<<"Four";
    break;
    case 5:cout<<"Five";
    break;
    case 6:cout<<"Six";
    break;
    case 7:cout<<"Seven";
    break;
    case 8:cout<<"Eight";
    break;
    case 9:cout<<"Nine";
    break;
    }
    }
    }
    getch();
    }


    if any thing u need u can ask me...


    •    Sponsored Ads



Latest Article

Network Security Risk Assessment and Measurement

Read More...