program ini sama seperti program sebelumnya yaitu program terbilang by blackant "JAVA" yang perna saya posting sebelumnya. tapi ini pake bahasa C++,
<<<<<<<<<<++++++++++>>>>>>>>>>
#include "iostream.h"
void terbilang(long x){
if(x==1){
cout<<"satu ";
}else if(x==2){
cout<<"dua ";
}else if(x==3){
cout<<"tiga ";
}else if(x==4){
cout<<"empat ";
}else if(x==5){
cout<<"lima ";
}else if(x==6){
cout<<"enam ";
}else if(x==7){
cout<<"tujuh ";
}else if(x==8){
cout<<"delapan ";
}else if(x==9){
cout<<"sembilan ";
}else if(x==10){
cout<<"sepuluh ";
}else if(x==11){
cout<<"sebelas ";
}else if(x>=12&&x<=19){
terbilang(x%10);
cout<<"belas ";
}else if(x>=20&&x<=99){
terbilang(x/10);
cout<<"puluh ";
terbilang(x%10);
}else if(x>=100&&x<=199){
cout<<"seratus ";
terbilang(x-100);
}else if(x>=200&&x<=999){
terbilang(x/100);
cout<<"ratus ";
terbilang(x%100);
}else if(x>=1000&&x<=1999){
cout<<"seribu ";
terbilang(x-100);
}else if(x>=2000&&x<=999999){
terbilang(x/1000);
cout<<"ribu ";
terbilang(x%1000);
}else if(x>=1000000&&x<=999999999){
terbilang(x/1000000);
cout<<"juta ";
terbilang(x%1000000);
}else if(x>=1000000000&&x<=2147483647){
terbilang(x/1000000000);
cout<<"miliar ";
terbilang(x%1000000000);
}
}
void main(){
long nilai;
char y;
do{
cout<<"masukan nilai : ";
cin>>nilai;
cout<<endl;
terbilang(nilai);
cout<<endl<<"jika anda ingin mengulang tekan y : ";
cin>>y;
cout<<endl;
}while(y=='y'||y=='Y');
getch();
}<<<<<<<<<<++++++++++>>>>>>>>>>
0 komentar:
Posting Komentar