Monday 29 August 2016

Program for Binary to Decimal Conversion

www.programmingcalculator.com
https://nikhilnihal.github.io/programmingcalculator/index.html

C++ Program to Convert Binary To Decimal


#include<bits/stdc++.h>

using namespace std;

int main()
{
    long bin, dec = 0, rem, num, base = 1;

    cout << "Enter the binary number";
    cin >> num;
    bin = num;
    while (num > 0)
    {
        rem = num % 10;
        dec = dec + rem * base;
        base = base * 2;
        num = num / 10;
    }
    cout << "The decimal equivalent of " << bin << " : " << dec << endl;
    return 0;

}

No comments:

Post a Comment

Uploading and Running Lambda function in AWS

Main.go package main import ( "fmt" "encoding/json" "log" "github.com/aws/aws-lambda-g...