Do i have to take multiple inputs in von neuman loves biinary

if yes, then how to take multiple inputs mentioned by the user

Hi Nipun

Yes you need to take multiple inputs in the von neuman question. You can do that by using loops.

Sample code:

int queries = scn.nextInt();
while(queries > 0){
int num = scn.nextInt();
   // Your code 
queries--;
}

Hope it helps.

i have done the required changes but code is still solving inputs one by one

my code:
Scanner s = new Scanner(System.in);
int queries = s.nextInt();

	while (queries > 0) {
		int n = s.nextInt();

		int pow = 1;
		int ans = 0;
		while (n != 0) {
			int rem = n % 10;

			n = n / 10;

			ans = ans + rem * pow;
			pow = pow * 2;
		}
		System.out.println(ans);

	}

	queries--;

Hii Nipun,
queries–; command must be inside the while loop body. Since you are decreasing the value of queries outside the while loop the while loop becomes an infinite loop and that’s why you got the error.

Hi Nipun
As you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.

Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.