digits to words

closed account (1vf9z8AR)
#include<iostream>
using namespace std;
int first(f)
{
switch(f)
{
case 1:
cout<<"one hundred";
break;
case 2:
cout<<"two hundred";
break;
case 3:
cout<<"three hundred";
break;
case 4:
cout<<"four hundred";
break;
case 5:
cout<<"five hundred";
break;
case 6:
cout<<"six hundred";
break;
case 7:
cout<<"seven hundred";
break;
case 8:
cout<<"eight hundred";
break;
case 9:
cout<<"nine hundred";
break;
}
}
int ten(t)
{switch(t)
{
case 10:
cout<<"ten";
break;
case 11:
cout<<"eleven";
break;
case 12:
cout<<"twelve";
break;
case 13:
cout<<"thirteen";
break;
case 14:
cout<<"fourteen";
break;
case 15:
cout<<"fifteen";
break;
case 16:
cout<<"sixteen";
break;
case 17:
cout<<"seventeen";
break;
case 18:
cout<<"eighteen";
break;
case 19:
cout<<"nineteen";
break;
}
}
int second(s)
{
switch(s)
{
case 2:
cout<<"twenty";
break;
case 3:
cout<<"thirty";
break;
case 4:
cout<<"forty";
break;
case 5:
cout<<"fifty";
break;
case 6:
cout<<"sixty";
break;
case 7:
cout<<"seventy";
break;
case 8:
cout<<"eighty";
break;
case 9:
cout<<"ninety";
break;
}
}
int last(l)
{
switch(l)
{
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;
}
}
int main()
{
int no;
cout<<"Enter a three digit number";cin>>no;
int f=no/100;
first(f);
int t=no%100-no%10;
if(t==1)
{tens(t);goto lb;}
if(t!=1)
second(s);
int l=no%10;
last(l);
lb:
}
no output.please help
no output.please help

Yes. You don't get much output from code that doesn't compile.

When you define a function, the argument list must include types:

1
2
3
int first(f)
{
    //...  

should be:
1
2
3
int first(int f)
{
    //...  


Also, functions which promise to return a value should actually return a value.

Topic archived. No new replies allowed.