1 Lembar seratus ribuan
1 lembar lima puluh ribuan
1 lembar dua puluh ribuan
0 lembar sepuluh ribuan
1 lembar lima ribuan
0 lembar dua ribuan
0 lembar seribuan
1 lembar lima ratusan
terbilang = seratus tujuh puluh lima ribu lima ratus.
friend tinggal copas code berikut di c++ friend
#include
#include
void satuan(int x)
{
if(x==1) printf("Satu ");
else if(x==2) printf(" Dua ");
else if(x==3) printf(" tiga ");
else if(x==4) printf(" empat ");
else if(x==5) printf(" Lima ");
else if(x==6) printf(" enam ");
else if(x==7) printf(" tujuh ");
else if(x==8) printf(" delapan ");
else if(x==9) printf(" sembilan ");
else if(x==10) printf(" sepuluh ");
else if(x==11) printf(" sebelas ");
}
void terbilang(long a)
{
if(a<=11) satuan(a);
else if((a>11) && (a<=19))
{
terbilang(a%10);
printf("Belas ");
}
else if((a>=20) && (a<=99))
{
terbilang(a/10);
printf("puluh ");
terbilang(a%10);
}
else if((a>=100) && (a<=199))
{
printf("seratus ");
terbilang(a%100);
}
else if((a>=200) && (a<=999))
{
terbilang(a/100);
printf("ratus ");
terbilang(a%100);
}
else if((a>=1000) && (a<1999))
{
printf("Seribu");
terbilang(a%1000);
}
else if((a>=2000) && (a<=9999))
{
terbilang(a/1000);
printf(" ribu");
terbilang(a%1000);
}
else if((a>=10000) && (a<99999))
{
terbilang(a/1000);
printf(" ribu");
terbilang(a%1000);
}
else if((a>=100000) && (a<=999999))
{
terbilang(a/1000);
printf(" ribu");
terbilang(a%1000);
}
}
void pecahan(long y)
{
int sisa = 0;
int seratusribu = y / 100000;
printf("%d Lembar Uang Seratus Ribuan \n",seratusribu);
sisa = y % 100000;
int limapuluhribu = sisa / 50000;
printf("%d Lembar Lima Puluh Ribuan \n",limapuluhribu);
sisa = sisa % 50000;
int duapuluhribu = sisa / 20000;
printf("%d Lembar dua puluh ribuan \n",duapuluhribu);
sisa = sisa % 20000;
int sepuluhribu = sisa / 10000;
printf("%d Lembar Sepuluh Ribuan \n",sepuluhribu);
sisa = sisa % 10000;
int limaribu = sisa / 5000;
printf("%d Lembar Lima ribuan \n",limaribu);
sisa = sisa % 5000;
int duaribu = sisa / 2000;
printf("%d Lembar Dua ribuan \n",duaribu);
sisa = sisa % 2000;
int seribu = sisa / 1000;
printf("%d Lembar seribu \n",seribu);
sisa = sisa % 1000;
int limaratus = sisa / 500;
printf("%d Lembar lima ratusan \n",limaratus);
sisa = sisa % 500;
}
void main()
{
long nilai;
printf("Masukkan Nominal = ");scanf("%d",&nilai);
pecahan(nilai);
terbilang(nilai);
getche();
}
mantlap cui
kalo pake vb bisa ga bos???