Write a c++ program to convert any binary number into its equivalent decimal number
Answers
Answered by
0
Answer:
#include<iostream>
using namespace std;
int main ()
{
int num, rem, temp, dec = 0, b = 1;
cout << "Enter the binary number : ";
cin >> num;
temp = num;
while (num > 0)
{
rem = temp % 10;
dec = dec + rem * b;
b *= 2;
temp /= 10;
}
cout << "The decimal equivalent of " << num << " is " << dec;
return 0;
}
Step-by-step explanation:
let me know if it's clear
Similar questions
Math,
5 months ago
Hindi,
5 months ago
English,
5 months ago
Computer Science,
10 months ago
India Languages,
10 months ago
Chemistry,
1 year ago