Write a program to change binery to decimal in ç++
Answers
Answered by
0
Binary to Decimal
Program :
#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;
}
Output
Enter the binary number : 1111
The decimal equivalent of 1111 is : 15
ishaana52:
kya
Similar questions