Monday 29 August 2016

Program for Decimal to Binary Conversion

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

C++ Program for Decimal to Binary Conversion

#include<bits/stdc++.h>

using namespace std;

int main()
{
    long dec,rem,i=1,sum=0,binary=0;
    cout<<"Enter the decimal to be converted:";
    cin>>dec;

    while(dec!=0)
    {
      rem=dec%2;
      dec/=2;
      binary+=rem*i;
      i*=10;
    }

    cout<<"The binary of the given number is:"<<binary<<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...