English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

2007-03-10 17:11:28 · 1 answers · asked by Anonymous in Computers & Internet Programming & Design

1 answers

#include
using namespace std;

int main() {
int n,i;
int a[100];
int k;
while(1) {
system("cls");
cout << endl << endl;
cout << "Enter a decimal number : ";
cin >> n;

cout << endl << endl;
cout << "The number " << n;
k=0;
do {
a[k]=n%2;
n=n/2;
k=k+1;
}while (n>=1);
cout <<" in decimal is equal to the number ";
for(i=k-1; i>=0; i--) {
cout << a[i];
}
cout << " in base 2" << endl << endl;
system("pause");
}
}

2007-03-10 17:52:06 · answer #1 · answered by iyiogrenci 6 · 0 0

fedest.com, questions and answers