Answers for "print binary in c"

C++
0

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;
}
Posted by: Guest on March-16-2021

Browse Popular Code Answers by Language