Skip to content

Conversation

@SONIYAPATIDAR
Copy link

#include
#include <math.h>
using namespace std;

int base2tobase10(int n){
int count=0, ans=0 ,rem ;
while(n!=0){
rem=n%10;
ans+=pow(2,count)*rem;
count++;
n/=10;

}
return ans;

}

int main(){
int n;

cout<<"Enter a binary number : ";
cin>>n;
cout<<"Decimal number of "<<n<<" is "<<base2tobase10(n);

return 0;

}

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Message that will be displayed on users' first pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant