Skip to content

Instantly share code, notes, and snippets.

@cryskram
Created January 21, 2022 06:14
Show Gist options
  • Save cryskram/63e5b470284d4dc686c7621221e44173 to your computer and use it in GitHub Desktop.
Save cryskram/63e5b470284d4dc686c7621221e44173 to your computer and use it in GitHub Desktop.
A Program to convert Binary to Decimal
#include <iostream>
#include <math.h>
int main()
{
long long num, dec = 0, raised = 0, rem;
std::cin >> num;
while (num != 0)
{
rem = num % 10;
num /= 10;
dec += rem * std::pow(2, raised);
raised++;
}
std::cout << "Decimal is: " << dec << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment