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
Also Read: C++ Program For Binary Equivalent Of A Decimal Number
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
#include
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
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
#include
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
No Comment