Sayılarda Taban Çevirme

</p>
<p>#include &lt;stdio.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
#include &lt;math.h&gt;</p>
<p>int tabandan10a(int taban, int sayi);<br />
void _10danTabana(int sayi, int taban);<br />
int tabandanTabana(int tabandan, int sayidan, int tabana);<br />
void basamak_yaz(int basamak);</p>
<p>int main()<br />
{<br />
printf(“Her hangi bir tabandan giris yapilirken en fazla 10 tabaninda sayi girilebilir.\n”<br />
“Tabana ceviri yapilirkende en fazla 32 tabanina cevirili yapilabilir.\n………………..\n”);<br />
int orjinal_taban, orjinal_sayi, cevrilecek_taban;<br />
printf(“Orjinal tabanda ki sayi: “); scanf(“%d”, &amp;orjinal_sayi);<br />
printf(“Sayinin orjinal tabani: “); scanf(“%d”, &amp;orjinal_taban);<br />
printf(“Sayinin cevrilecegi taban: “); scanf(“%d”, &amp;cevrilecek_taban);<br />
printf(“%d tabaninda ki %d sayisinin %d tabaninda ki karsiligi: “, orjinal_taban, orjinal_sayi, cevrilecek_taban);<br />
tabandanTabana(orjinal_taban, orjinal_sayi, cevrilecek_taban);</p>
<p> printf(“\n”);<br />
system(“PAUSE”);<br />
return 0;<br />
}</p>
<p>void _10danTabana(int sayi, int taban)<br />
{<br />
if(sayi/taban == 0)<br />
{<br />
basamak_yaz(sayi);<br />
return;<br />
}<br />
else<br />
{<br />
_10danTabana(sayi/taban, taban);<br />
basamak_yaz(sayi%taban);<br />
}<br />
}</p>
<p>int tabandan10a(int taban, int sayi)<br />
{<br />
int basamak_sayisi =0, cevrilmis_sayi=0, numara=sayi;<br />
do{<br />
basamak_sayisi++;<br />
}while(numara/(int)pow(10, basamak_sayisi) != 0);<br />
for(basamak_sayisi; basamak_sayisi&gt;=0; basamak_sayisi–)<br />
{<br />
cevrilmis_sayi += (numara/(int)pow(10,basamak_sayisi))*(int)pow(taban, basamak_sayisi);<br />
numara = numara%(int)pow(10, basamak_sayisi);<br />
}<br />
return cevrilmis_sayi;</p>
<p>}</p>
<p>int tabandanTabana(int tabandan, int sayidan, int tabana)<br />
{<br />
int ara10tabaninda;<br />
ara10tabaninda = tabandan10a(tabandan, sayidan);<br />
_10danTabana(ara10tabaninda, tabana);<br />
}</p>
<p>void basamak_yaz(int basamak)<br />
{<br />
 switch(basamak){<br />
 case 0:<br />
 case 1:<br />
 case 2:<br />
 case 3:<br />
 case 4:<br />
 case 5:<br />
 case 6:<br />
 case 7:<br />
 case 8:<br />
 case 9: printf(“%d”, basamak); break;<br />
 case 10: printf(“A”); break;<br />
 case 11: printf(“B”); break;<br />
 case 12: printf(“C”); break;<br />
 case 13: printf(“D”); break;<br />
 case 14: printf(“E”); break;<br />
 case 15: printf(“F”); break;<br />
 case 16: printf(“G”); break;<br />
 case 17: printf(“H”); break;<br />
 case 18: printf(“I”); break;<br />
 case 19: printf(“J”); break;<br />
 case 20: printf(“K”); break;<br />
 case 21: printf(“L”); break;<br />
 case 22: printf(“M”); break;<br />
 case 23: printf(“N”); break;<br />
 case 24: printf(“O”); break;<br />
 case 25: printf(“P”); break;<br />
 case 26: printf(“Q”); break;<br />
 case 27: printf(“R”); break;<br />
 case 28: printf(“S”); break;<br />
 case 29: printf(“T”); break;<br />
 case 30: printf(“U”); break;<br />
 case 31: printf(“V”); break;<br />
 }<br />
}<br />

Yorum Yapın

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑

%d blogcu bunu beğendi: