Wrong output

include <bits/stdc++.h>
using namespace std;

int main() {
int t,n,i,A[100];

std::cin >> t;

while(t--)
{    
    int x=0;
    cin>>n;
       for(i=0; i<n; i++)
       {
           cin>>A[i];
       }
       for(i=0; i<n; i++){
          if(A[i]>=10 && A[i]<=60)
          x++;

break;
}
cout<<x<<endl;

	}

return 0;

}
Why the output is wrong for these test case
Input
3
3
15 23 65
3
15 62 16
2
35 9
Output
2
2
1

1 Like

Remove
(break;)
it will give correct output

1 Like

Ok it is working

1 Like

But why remove break;

1 Like

It appears there is an issue with the break statement in your code. The break statement is causing the loop to terminate after the first iteration, regardless of the conditions in the loop. This means that your count x will always be either 0 or 1, depending on the first element of the array A

1 Like

Ok Thankyou