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



Do you like this post? Please link back to this article by copying one of the codes below.

URL Of Post:


HTML Link Code:

BB (forum) link code:

Comments