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

Join 136,574 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,878 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:42 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

Reply to this topicStart new topic
Time is now: 12/3/08 12:05AM

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