Computer Science, asked by Anonymous, 1 year ago

Write a program to change binery to decimal in ç++

Answers

Answered by homosapiens45
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
Anonymous: moderators ko tease karne ke liye
ishaana52: acha
ishaana52: bdhia fr
Anonymous: wow mere account delete kar dete hai
Anonymous: isaliye
ishaana52: acha
Anonymous: hoon
Anonymous: Calo.... Happy diwali sweet heart... :)
ishaana52: same 2 u
Similar questions