#include <iostream>
using namespace std;
void satuan(int a)
{
if (a==1) cout<<" Satu ";
else if (a==2) cout<<" Dua ";
else if (a==3) cout<<" Tiga ";
else if (a==4) cout<<" Empat ";
else if (a==5) cout<<" Lima ";
else if (a==6) cout<<" Enam ";
else if (a==7) cout<<" Tujuh ";
else if (a==8) cout<<" Delapan ";
else if (a==9) cout<<" Sembilan ";
else if (a==10) cout<<" Sepuluh ";
else if (a==11) cout<<" Sebelas ";
}
void terbilang(long s)
{
if (s<=11) satuan(s);
else if ((s>11) && (s<=19))
{
terbilang(s%10);
cout<<"Belas ";
}
else if ((s>=20)&&(s<=99))
{
terbilang(s/10);
cout<<"Puluh";
terbilang(s%10);
}
else if ((s>=100)&&(s<=199))
{
cout<<"Seratus";
terbilang(s%100);
}
else if ((s>=200)&&(s<=999))
{
terbilang(s/100);
cout<<"Ratus";
terbilang(s%100);
}
else if ((s>=1000)&&(s<=1999))
{
cout<<"Seribu";
terbilang(s%1000);
}
else if ((s>=2000)&&(s<=9999))
{
terbilang(s/1000);
cout<<"Ribu";
terbilang(s%1000);
}
else if ((s>=10000)&&(s<=99999))
{
terbilang(s/1000);
cout<<"Ribu";
terbilang(s%1000);
}
else if ((s>=100000)&&(s<=999999))
{
terbilang(s/1000);
cout<<"Ribu";
terbilang(s%1000);
}
else if ((s>999999))
{
cout<<"Masukkan Bilangan 1 - 999999";
}
}
int main()
{
long int bil;
cout<<" \t\t\t Program Membaca Bilangann\n";
cout << "\n ~ MASUKKAN BILANGAN [ 1 - 999999 ] : ";
cin >>bil;
terbilang(bil);
}
No comments:
Post a Comment