- 1st Loop - I think I need to run two loops.
First one is to loop through the number. - How do I get num and then binary input from user?
- I have already coded, but I am not getting the result after. Thanks.
Von Neuman Loves Binary - total numbers and binary entries
- 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).
You can share your code. I can help you with that.
For input you can use nextInt() for int input, if the input will be string you can use next()
Hi @sumyatkw,
- You will need one loop only. 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.