int main() { cout<<"Enter an integer between 1 and 999\n"; int a; cin>>a; if (a==1) { cout<<"One\n"; } else if (a==2) { cout<<"Two\n"; } else if (a==3) { cout<<"Three\n"; } // else if... repeat till 999 }
int main() { cout<<"Enter an integer between 1 and 999\n"; int a; cin>>a; int result[3]; int i; for(i=0;i<3&&a>0;i++) { result[i]=a%10; a=a/10; } if(a<0) i-=1; for(int j=i; j>=0;j--) { switch(result[j]) { case 0: cout<<"zero"; break; case 1: cout<<"one"; break; case 2: cout<<"two"; break; .... till "9" } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)