#include<stdio.h>
void birlik();
void onluk();
int main()
{
int sayi=0;
int basamak1=0;
int basamak2=0;
int basamak3=0;
int basamak4=0;
while(sayi!=-1)
{
printf("dort basamakli sayi girirniz :");
scanf("%d",&sayi);
if(sayi == -1) break;
// basamaklari bulalım
basamak1 = sayi % 10;
basamak2 = (sayi % 100) / 10;
basamak3 = (sayi % 1000) / 100;
basamak4 = sayi / 1000;
// ekrana yazma
if(basamak4!=1)
birlik(basamak4);
printf(" bin ");
if(basamak3!=1)
birlik(basamak3);
if(basamak3!=0)
printf(" yuz ");
onluk(basamak2);
printf(" ");
birlik(basamak1);
printf("\n\n");
}
return 0;
}
// birlik ceviri
void birlik(int rakam)
{
switch(rakam)
{
case 1:
printf("bir");
break;
case 2:
printf("iki");
break;
case 3:
printf("uc");
break;
case 4:
printf("dort");
break;
case 5:
printf("bes");
break;
case 6:
printf("alti");
break;
case 7:
printf("yedi");
break;
case 8:
printf("sekiz");
break;
case 9:
printf("dokuz");
break;
}
}
// onluk ceviri
void onluk(int rakam)
{
switch(rakam)
{
case 1:
printf("on");
break;
case 2:
printf("yirmi");
break;
case 3:
printf("otuz");
break;
case 4:
printf("kirk");
break;
case 5 :
printf("elli");
break;
case 6:
printf("altmis");
break;
case 7:
printf("yetmis");
break;
case 8:
printf("seksen");
break;
case 9:
printf("doksan");
break;
default:
printf("\b");
}
}
Hiç yorum yok:
Yorum Gönder
Her yorum bilgidir. Araştırmaya devam...