Convert 8-digit Binary Number to decimal number
Code:
Complete the program below which converts a binary number into a decimal number. Sample outputs are shown belowComplete the program below which converts a binary number into a decimal number. Sample outputs are shown below.
Sample Output 1:
|
|
8-bit Binary Number => 11111111
Decimal Number = 255 |
|
Sample Output 2:
|
|
8-bit Binary Number => 10101010
Decimal Number = 170
|
|
Sample Output 3:
|
8-bit Binary Number => 101010102
Number entered is not a binary number |
|
Quote:
#include <iostream>
using namespace std;
int main()
{
int num;
cout << "8-bit Binary Number=";
cin >> num;
bool valid = true;
.
.
.
.
.
.
.
.
.
.
.
.
. |
.
if (valid)
{
cout << "Decimal Number = " << sum;
}
}
Anyone knows the solution?
I m really thank you.