Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int dec, rem, bin = 0;
- cout << "Enter the Decimal Number: ";
- cin >> dec;
- for(int i = 1; dec; i *= 10) {
- rem = dec % 2;
- dec /= 2;
- bin += rem * i;
- }
- cout << "The Corresponding Binary Value is: " << bin << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement