Banner Maker

Sabtu, 15 Januari 2011

Program C konversi Desimal ke biner

Sukses!









#include <stdio.h>

void dec_bin(int number);

int main(void) 
{
 int input = 0;

 printf("\nMasukkan Bilangan desimal : ");
 scanf("%d", &input);
 printf("\n "); 

 (input >= 0) && (input < 1024) ? dec_bin(input) : exit(1);

 return 0;
}

void dec_bin(int number) 
{
 int x, y;
 x = y = 0;

 for(y = 11; y >= 0; y--) 
{
  x = number / (1 << y);
  number = number - x * (1 << y);
  printf("%d", x);
 }

 printf(" Dalam Biner\n\n");
 system("pause");
}

1 komentar:

Thanks for some quality points there. I am kind of new to online , so I printed this off to put in my file, any better way to go about keeping track of it then printing?

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More