Last active
January 4, 2024 21:42
-
-
Save lnrsoft/29c9868ce1e0433f5823d317beb89739 to your computer and use it in GitHub Desktop.
Decimal to Binary Conversion Algorithm.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() { | |
int a[10], n, i; | |
cout << "Enter the number to convert: "; | |
cin >> n; | |
for (i = 0; n > 0; i++) { | |
a[i] = n % 2; | |
n = n / 2; | |
} | |
cout << "Binary of the given number= "; | |
for (i = i - 1; i >= 0; i--) { | |
cout << a[i]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment