Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,563 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,880 people online right now. Registration is fast and FREE... Join Now!




program for converting number written in letters into numbers

 
Reply to this topicStart new topic

program for converting number written in letters into numbers, like we have a string "twenty" then our output should be&quo

iprogram
6 May, 2008 - 10:39 PM
Post #1

New D.I.C Head
*

Joined: 6 May, 2008
Posts: 2


smile.gif
CODE


#include<iostream.h>
#include<conio.h>
#include<stdio.h>


int i,j;
int flag=0;
char str[7];
char b[2][8];
char a[29][9]={
        "zero","one","two","three","four", "five","six",
        "seven","eight","nine","ten","eleven","twelve",
        "thirteen","fourteen","fifteen","sixteen",
        "seventeen","eighteen","nineteen","twenty",
        "thirty","fourty","fifty","sixty","seventy",
        "eighty","ninety","hundred"
        } ;

void enter();
void split();
void compare();


int main()
{
clrscr();

    enter();
    split();
    compare();



        return 0;
        }
void enter()
{
    cout<<"enter any string";
        for(i=0;i<7;i++)
        {
        cin>>str[i];
        }
        fflush(stdin);
}

void split()
{
    i=0;
    j=0;
    again:
    do
    {
      j=0;
      b[i][j]=str[j];

            j++;
    }
    while (str[j-1]!=32);

    if(str[j]==32)
    {
    i=i+1;
    goto again;

    }
}
void compare()
{  i=0;
j=0;
do
{
if(a[i][j]==b[i][j])
flag=0;
else
flag=1;
j++;
}
while(a[i][j-1]!=32);
if(flag==0)
cout<<i;
}


User is offlineProfile CardPM
+Quote Post

no2pencil
RE: Program For Converting Number Written In Letters Into Numbers
6 May, 2008 - 10:42 PM
Post #2

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 6,465



Thanked: 66 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
Did you have a question about this code, or are you just sharing?
User is offlineProfile CardPM
+Quote Post

wiIbur
RE: Program For Converting Number Written In Letters Into Numbers
6 May, 2008 - 11:09 PM
Post #3

New D.I.C Head
*

Joined: 25 Sep, 2007
Posts: 20


My Contributions
QUOTE(no2pencil @ 6 May, 2008 - 11:42 PM) *

Did you have a question about this code, or are you just sharing?


he shared it twice! how sweet.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/2/08 11:46PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month