Whats the error?

Hey @garganshul151
Generate all the prime nos outside while(t–) loop and also declare all the arrays dynamically.

https://ide.codingblocks.com/s/329562…still getting the error?

Hey @garganshul151
You are still filling prime array inside while(t–) take that outside as well
in while(t–) u only have to take n and print prime[n-1]
Now talking about logical error ,while filling prime array you are making j=0 in each iteration so only prime[0] is updating again and again

Ok thank you…plz clear to me that why declaring and defining array outside while loop is more efficient?

Hey you are creating memory of 10^5 multiple times inside a loop so what do u think is more efficient , creating and using memory once or creating memory multiple times and using it .