ALCOZ Editorial

PROBLEM LINK : practice
contest

Tester : jeysree
Editorialist : danush10

PROBLEM EXPLANATION :

Given a binary number as an integer n=111, convert it into decimal and print.

DIFFICULTY :
Easy

CONSTRAINTS :
1≤n≤1000

EXPLANATION :

The Given Integer should be converted into decimal. For example, the given integer is 111. The conversion of given binary to decimal is 7.

Tester Solution

#include<stdio.h>

#include<math.h>

int main()

{

int n=111,decimal=0,pow=1,last;

while(n>0){

last=n%10;

decimal+=last*pow;

pow*=2;

n=n/10;

}

printf("%d",decimal);

return 0;

}