Input in for loop ( Prime Visit )

I recently wrote a code https://ide.codingblocks.com/s/74048
In this example I tried entering the upper and lower limits by using a for loop in l and m integer arrays .
Now the Problem is that after taking the desired array the for loop doesn’t terminates because the the input process never stops .

Hi Abhinav,
for taking multiple inputs like in this problem you do not need to make use of array. See in loop just take values from the user such as in this problem take the value of l and n and then pass to the function and print the return value.
Also there is a mistake in your sieve function as i should be equal to 2 and i * p <= n should be the limiting condition for for loop you have used.
Also declare the sieve function static as static variable can call only static functions.

I have made above mentioned changes to your code and you can see them in below link:

Thanks you sir problem resolved , but still how can I take input in two integer arrays simultaneously ?

Hi Abhinav

In order to take input in arrays simultaneously, you can use loop.

int arr[] = new int[n];
for(int i = 0; i < n; i++){
arr[i] = scn.nextInt();
}
	for(int i = 0; i<t ; i++)
	{
		l[i]= sr.nextInt();
		m[i]= sr.nextInt();       /* Due to some condition after entering the integers the loop does'nt break and execution is stopped.*/
 	}
Ma'am this for loop doesn't works as intended , please explain why?

Hi Abhinav

Here in my code

scn.nextInt() means that a user enters a integral value.
And arr[i] at the left hand side means that the integral value entered by the user should be saved in the array named arr at the index i.

I hope the logic is clear. Try implementing it now.