Decimal Turn binary:
Decimal to Binary #include<iostream>using namespace std;void printbinary (const unsigned int val) {for (int i = +; I >= 0; i --) {if (Val & (1 << i) cout << "1"; Elsecout << "0";}} int main () {printbinary (1024x768); return 0;}
Decimal Turn octal
Decimal to octal # include <iostream> #include <vector>using namespace Std;int main () {cout<< "input a number:" <<endl;int d;vector<int> Vec;cin>>d;while (d) {vec.push_back (d%8);d =D/8;} cout<< "The result is:" <<endl;for (Vector<int>::iterator ip=vec.end () -1;ip>=vec.begin ();) {cout <<*ip--;} Cout<<endl;return 0;}
Decimal to Random binary:
Decimal conversion to discretionary source code # include <iostream>using namespace Std;int main () {Long N;int p,c,m=0,s[100];cout<< " Enter the number you want to convert: "<<endl;cin>>n;cout<<" Enter the binary to convert: "<<endl;cin>>p;cout<<" ("<<n << ") 10=" << "("; while (n!=0)//", the result is stored in the array s[m]{c=n%p;n=n/p;m++;s[m]=c; The remainder is sequentially deposited into the array s[m]}for (int k=m;k>=1;k--)//output converted sequence {if (s[k]>=10)//If 16 is the output of the corresponding letter cout<< (char) (s[k]+ else //Otherwise direct output digital cout<<s[k];} cout<< ")" <<p<<endl;return 0;}
Eight hexadecimal output via library function:
#include <iostream>using namespace Std;int main () {int test=64;cout<< "DEC:" <<test<<endl;cout << "OCT:" <<oct<<test<<endl;//octal cout<< "HEX:" <
pre>
C + + binary conversion (decimal to binary, octal, discretionary)