➽ Program:-
#include<iostream>
using
namespace std;
int
main()
{
int
number, binary_value = 0, decimal_value, base = 1, rem;
cout << "Enter a Decimal Number:
";
cin >> number;
decimal_value = number;
while(number > 0)
{
rem = number % 2;
binary_value += rem * base;
number = number / 2 ;
base = base * 10;
}
cout << "Binary Equivalent of
" << decimal_value << " is " << binary_value;
return 0;
}
➽ Output:-
Enter a Decimal Number: 185
Binary equivalent of 185 is 10111001
0 Comments
Please do not enter any spam link in the comment section.