How To Print Binary Value Of An Integer In C Code Example


Example: print binary in c

#include <iostream> using namespace std; int main() {    long n, d, r, binary = 0;    n=10;    d = n;    int temp = 1;    while (n!=0) {       r = n%2;       n = n / 2;       binary = binary + r*temp;       temp = temp * 10;    }    printf("%ld", binary);    return 0; }

Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable