Https://ide.codingblocks.com/s/63462

https://ide.codingblocks.com/s/63462

VON NEUMAN LOVES BINARY
Given a binary number ,help Von Neuman to find out its decimal representation. For eg 000111 in binary is 7 in decimal.

Input Format:
The first line contains N , the number of binary numbers. Next N lines contain N integers each representing binary represenation of number.

I’m not getting the correct output

@Anushkaj instead of taking number in array try with taking number n you making your code
more difficult if you will not able to do tag me. I will help

Hi Anushka, you’re initialising the value of base outside the for loop and thus it is not initialised to 1 for every test case and thus you’re getting wrong answer.
I’ve rectified this mistake, refer to the correct code here: https://ide.codingblocks.com/s/63733

#include
using namespace std;

int main()
{
int n;
cin>>n;

    for(int i = 1; i<=n; i++)
   {
          int num;
          cin>>num;
          int dvalue = 0;
          int base = 1;

          while (num){
                  int last_digit = num % 10;
                  num = num / 10;
                  dvalue += last_digit * base;
                  base = base * 2;
          }
         cout<<dvalue<<endl;
  }
  return 0;

}