Von neuman loves binary

import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int [] arr = new int[N];
for(int i=0;i<=arr.length-1;i++)
{
arr[i] = sc.nextInt();
}
Conversion(arr);
}
public static void Conversion(int [] arr){
int power = 1;
int ans = 0;
for(int i=0; i<=arr.length-1;i++){
int rem = arr[i] % 10;
ans = ans + rem * power;
//next line
arr[i] = arr[i] / 10;
power = power * 2;
System.out.println(ans);
}

}

}
can you hlp me with the code and explaination of how to print one specific conversion at a time then moves to another error
ASAP

@Naman_Gupta,

  • The idea is to extract the digits of given binary number starting from right most digit and keep a variable decvalue.
  • At the time of extracting digits from the binary number, multiply the digit with the proper base (Power of 2)
  • and add it to the variable dec_value.
  • At the end, the variable decvalue will store the required decimal number.

Say the test case is:
4
1100
1010
1011
11001
Now start one for the number of cases (in the above case its 4). Now start another loop for the number that is (1100, 1010 and so on) and go on until the number is 0.

  1. Loop thought the number and keep a variable storing the correct power of 2 to be added if the variable at current place is 1.
    2 . You can use either string or a long data type to input the number.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.