konversi desimal ke biner



gimana caranya merubah angka desimal menjadi angka biner ya? terus menggunakan bahasa pemrograman apa? kita menggunakan bahasa pemrograman c++ aja, gini caranya mudah-mudahan aja saya gak salah bikinnya, langsung ke TKP aja lah..
#include
#include
class Konvkebiner{
friend istream& operator>>(istream&, Konvkebiner&);
public:
Konvkebiner (int a=0):n(a){};
void tampil();
private:
int n;
int m[25];
};
istream& operator>>(istream& in, Konvkebiner& F){
cout<>F.n;
return in;
}
void Konvkebiner::tampil(){
int o=n;
int i=0;
do {
m[i++]=(o%2);
o=o/2;
} while (o>=1);
for (int z=1;z<=i;z++) cout <> bn;
cout<<"Binernya adalah= ";
bn.tampil();
cout<<endl;
getch();
return 0;
}
semoga bermanfaat

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: