Program for Decimal to Binary Conversion | C ++ implementation of the approach ; Function to return the binary equivalent of decimal value N ; To store the binary number ; Count used to store exponent value ; Driver code
#include <cmath> NEW_LINE #include <iostream> NEW_LINE using namespace std ; #define ull  unsigned long long int NEW_LINE int decimalToBinary ( int N ) { ull B_Number = 0 ; int cnt = 0 ; while ( N != 0 ) { int rem = N % 2 ; ull c = pow ( 10 , cnt ) ; B_Number += rem * c ; N /= 2 ; cnt ++ ; } return B_Number ; } int main ( ) { int N = 17 ; cout << decimalToBinary ( N ) ; return 0 ; }