Q:

Why the infinite loop?

I am trying to find if the number is a perfect square, but for some reason my code goes into an infinite loop and keeps printing "yes". Here's the code:
#include <iostream>

using namespace std;

int main()
{
  int N=0, n=0, l=1, u=0, mid;

  cin >> N;

  for (int i=0; i<N; ++i)
  {
    cin >> n;
    u=n;

    while (l <= u)  
    {   
      mid = (l+u)/2;

      if (n == mid*mid) 
      {   
        cout << "yes" << endl;
        continue;
      }   
      else if (n > mid*mid)
      {   
        l = mid+1;
      }
      else if (n < mid*mid)
      {
        u = mid-1;
      }
    }
    cout << "no" << endl;
  }
  return 0;
}

And the input file is:
15
1
2
4
9
16
25
35
753
23446
23423
5423
81
49
36
100
121

The first entry is the number of values that we want to check which is 15 in this case.
I looked this code over and over again and still cannot spot why I'm getting the infinite loop.

A:

inside the for loop ,you should reset 

l=1

change continue to break

