
By: asdf1 | Date: Nov 24 2007 21:57 | Format: C++ | Expires: never | Size: 689 B | Hits: 1371
- #include <iostream>
- using namespace std;
- void dectobin(int num, int base);
- void convert(int n);
- int main()
- {
- int decimalnum;
- int base;
- base = 2;
- cout << "enter decimal: ";
- cin >> decimalnum;
- cout << endl;
- cout<< "Decimal " << decimalnum << " = ";
- dectobin(decimalnum, base);
- cout << " binary" <<endl;
- system("PAUSE");
- return 0;
- }
- void dectobin(int num, int base)
- {
- if( num > 0)
- {
- dectobin (num/base, base);
- cout << num % base;
- }
- if ( num < 0)
- {
- cout <<"supposed to be 2's compliment";
- }
Latest pastes
4 days ago
7 days ago
8 days ago
9 days ago
11 days ago