C++ Program to Convert Decimal to Binary in Reversed Form

C++ Program to Convert a Decimal number to its Binary equivalent. The result produced after executing the source code will be in a reversed form.

Also Read: C++ Program to Check If a Character is Small, Capital, Number or Special Character


C++ Program to Convert Decimal to Binary in Reversed Form




#include <iostream.h>
#include <stdio.h>
 int main()
  {
 int n;
 cout<<"enter a decimal number to convert to binary: ";
  while (cin >> n)
 {
   if (n > 0)
  {
    cout <<"binary equivalent of "<<n<<" in reverse order is: ";

   while (n > 0)
    {
   cout << n%2;
   n = n/2;
    }

  }
   else
  {
    cout << "Please enter a number greater than zero." << endl;
  }
 }
 return 0;
 }

Also Read: C++ Program For Binary Equivalent Of A Decimal Number

Author:

Tech blogger, SEO expert, cryptocurrency enthusiast, and freelancer are the terms that describe me. I'll rather write a thousand words than speak hundred words, and that describes my passion as a content creator.