Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void binToDec(int number){
- string bin = "";
- while (number != 0){
- bin += (number % 2) + '0';
- number /= 2;
- }
- for (int i = bin.size() - 1; i >= 0; i--){
- cout << bin[i];
- }
- cout << endl;
- }
- int main()
- {
- int num;
- cout << "Enter decimal number: ";
- cin >> num;
- cout << "Binary: ";
- binToDec(num);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement