Hızlı Konu Açma

Hızlı Konu Açmak için tıklayınız.

Son Mesajlar

Konulardaki Son Mesajlar

Reklam

Forumda Reklam Vermek İçin Bize Ulaşın

C++ / Lojik Devreleri Sayi Sistemleri Dönüşüm Programı

YaSa22

Fahri Üye
Fahri Üye
Katılım
12 Temmuz 2014
Mesajlar
2,293
Tepkime puanı
2
Puanları
0
Konum
GTA
Binaryoctal Ve Hexadecimal

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>

int k=0; // global degisken;basamak sayilari icin asagidaki 'for' dongusu icin kullanilacak dongu elemani..
int bolum=0; // kullanilacak degiskenler..
int i=1;
int sayi=0;
int kutu[10];
int secim=0;
int tercih; // devam veya cikis icin tanimlanan degisken..



int binary_system(int *);
void onkural(int *);
int hexal_system(int *);
void onkural_hexal(int *);
int octal_system(int *);
void onkural_octal(int *);
void menu();


int main() {

// kutulari sifirla..
for(int i=0;i<10;i++){
kutu=0;
}

menu();
scanf("%d",&secim);

if(secim==1){
terim:
puts("Lutfen Bir Decimal Sayi Giriniz:");
scanf("%d",&sayi);
if(sayi==1 || sayi==0 || sayi<0){
printf("%d Binary Sayi Girisi Esit..!!\n\n",sayi);
goto terim;
}

kutu[0]=sayi%2; // ilk degerleri uygula..
bolum=sayi/2;
onkural(&sayi); // bellek tasarrufu icin sayi adresini fonksiyona gonder..
binary_system(&sayi);
}

if(secim==2){
sayim:
puts("Lutfen Bir Decimal Sayi Giriniz:");
scanf("%d",&sayi);

switch (sayi){

case 10:
printf("%c",65);
printf("\n");
goto sayim;
break;
case 11:
printf("%c",66);
printf("\n");
goto sayim;
break;
case 12:
printf("%c",67);
printf("\n");
goto sayim;
break;

case 13:
printf("%c",68);
printf("\n");
goto sayim;
break;
case 14:
printf("%c",69);
printf("\n");
goto sayim;
break;
case 15:
printf("%c",70);
printf("\n");
goto sayim;
break;
}
if(sayi<16 || sayi<=0){
printf("%d Aynidir..\n\n",sayi);
goto sayim;
}

kutu[0]=(sayi)%16; // ilk degerleri uygula..
bolum=(sayi)/16;
onkural_hexal(&sayi);
hexal_system(&sayi);
}
if(secim==3){
mevcut:
puts("Lutfen Bir Decimal Sayi Giriniz:");
scanf("%d",&sayi);
if(sayi<8){
printf("%d",sayi);
goto mevcut;
}
kutu[0]=(sayi)% 8; // ilk degerleri uygula..
bolum=(sayi)/8;
onkural_octal(&sayi);
octal_system(&sayi);
}


if(secim==4){
return -1;
}

if(secim==5){
system("CLS");
}

}

// binary sistem fonk
int binary_system(int *sayi){

do {
if(bolum<2){ // bolumun 1 oldugu anda bastirmak icin tanimalanan kontrol yapisina giris..

puts("\\\\");
puts("Binary Decimal");
printf("%d",bolum);
for(int i=k;i>=0;i--){ // MSB den LSB ye kadar donen bir dongu..
printf("%d",kutu);
}

printf("\n\nDevam etmek icin 1'e basin,Degilse herhangi bir tus");
scanf("%d",&tercih);
switch (tercih) {
case 1: // 1 ise devam
k=0;
bolum=0;
i=1;
sayi=0;
return main();
break;

default: // degilse cikis
return -1;

} // switch sonu.

} // bolum==1 kosulu sonu.
kutu=bolum%2;
bolum=bolum/2;
i++;
} // do sonu.
while(bolum!=-1);
}


void onkural(int *sayi){ //Binary basamak sayilari icin kural ifadeleri fonksiyonu..
if(*sayi>0 && *sayi<4)
k=0;
else if(*sayi>=4 && *sayi<8)
k=1;
else if(*sayi>=8 && *sayi<16)
k+=2;
else if(*sayi>=16 && *sayi<32)
k+=3;
else if(*sayi>=32 && *sayi<64)
k+=4;
else if(*sayi>=64 && *sayi<128)
k+=5;
else if(*sayi>=128 && *sayi<256)
k+=6;
else if(*sayi>=256 && *sayi<512)
k+=6;
else if(*sayi>=512 && *sayi<1024)
k+=7;
else if(*sayi>=1024 && *sayi<2048)
k+=8;
else if(*sayi>=2048 && *sayi<4096)
k+=9;
else if(*sayi>=4096 && *sayi<8192)
k+=10;
else if(*sayi>=8192 && *sayi<16384)
k+=11;
else {
printf("\nYogun Baski..!!");
k+=12;
}
}

//int hexal_system(int *sayi){

void onkural_hexal(int *sayi){
if(*sayi>0 && *sayi<256)
k=0;
else if(*sayi>=256 && *sayi<4096)
k+=1;
else if(*sayi>=4096 && *sayi<65536)
k+=2;
else{
printf("Yogun Baski..!!\n");
k+=3;
}
}

int hexal_system(int *sayi){

do {
if(bolum<16){ // bolumun 1 oldugu anda bastirmak icin tanimalanan kontrol yapisina giris..

puts("\\\\");
puts("HexaDecimal");
printf("%d",bolum);
for(int i=k;i>=0;i--){ // MSB den LSB ye kadar donen bir dongu..
printf("%d",kutu);
}

printf("\n\nDevam etmek icin 1'e basin,Degilse herhangi bir tus");
scanf("%d",&tercih);
switch (tercih) {
case 1: // 1 ise devam
k=0;
bolum=0;
i=1;
sayi=0;
return main();
break;

default: // degilse cikis
return -1;

} // switch sonu.

} // bolum==1 kosulu sonu.
kutu=bolum%16;
bolum=bolum/16;
i++;
} // do sonu.
while(bolum!=-1);
}

int octal_system(int *sayi){

do {
if(bolum<8){ // bolumun 1 oldugu anda bastirmak icin tanimalanan kontrol yapisina giris..

puts("\\\\");
puts("Octal Decimal");
printf("%d",bolum);
for(int i=k;i>=0;i--){ // MSB den LSB ye kadar donen bir dongu..
printf("%d",kutu);
}

printf("\n\nDevam etmek icin 1'e basin,Degilse herhangi bir tus");
scanf("%d",&tercih);
switch (tercih) {
case 1: // 1 ise devam
k=0;
bolum=0;
i=1;
sayi=0;
return main();
break;

default: // degilse cikis
return -1;

} // switch sonu.

} // bolum==1 kosulu sonu.
kutu=bolum%8;
bolum=bolum/8;
i++;
} // do sonu.
while(bolum!=-1);
}


void onkural_octal(int *sayi){
if(*sayi>=8 && *sayi<64)
k+=0;
else if(*sayi>=64 && *sayi<512)
k+=1;
else if(*sayi>=512 && *sayi<4096)
k+=2;
else if(*sayi>=4096 && *sayi<32768)
k+=3;
else{
printf("Yogun Baski..!!\n");
k+=4;
}
}


void menu() {

printf("************************\n");
printf("** Hosgeldiniz **\n");
printf(" 1.)Binary System \n");
printf(" 2.)Hexadecimal System \n");
printf(" 3.)Octal System \n");
printf(" 4.)Cikis \n");
printf(" 5.)Reset \n");
printf("** Secim Yapiniz **\n");
printf("************************\n");
}
 

Users Who Are Viewing This Konu (Users: 0, Guests: 1)

Üst