Binary to decimal
Binary to decimal
Send Feedback
Binary to decimal
An integer N in the Binary Format
Corresponding Decimal number (as integer)
0 <= N <= 10^9
1100
12
111
7
#include<iostream>using namespace std;
int main() { // Write your code here int pv=1,dec=0,n,rem; cin>>n; while(n>0){ rem=n%10; dec=dec+rem*pv; pv*=2; n=n/10; } cout<<dec; }
Comments
Post a Comment