It is showing TLE

#include
using namespace std;
int main() {
int q;
cin>>q;
for(int i=0;i<q;i++)
{
int no;
cin>>no;
int count=0;
for(int i=2;i<=(no/2);i++)
{
if((no%i)==0)
{
count++;
}
}
if(count==3)
{
cout<<“YES”<<endl;
}
else
{
cout<<“NO”<<endl;
}
}
return 0;
}

The Code here is showing TLE.
What can I do for that?
Like first I can calculate primes till that no. n(which is to be taken as input) by segmented sieve and then check if n is square from the list of primes.

@aryangrover take sqrt(n) in place of n/2 in loop ,it will more optimise it otherwise seive hi use krni pdegi agr fir bhi TLE de rha hai to.

#include<bits/stdc++.h>
using namespace std;
int main() {
int q;
cin>>q;
for(int i=0;i<q;i++)
{
int no;
cin>>no;
int count=0;
for(int i=1;i<=sqrt(no);i++)
{
if(no%i==0)
{
count++;
}
}
if(count==3)
{
cout<<“YES”<<endl<<count<<endl;
}
else
{
cout<<“NO”<<endl<<count<<endl;
}
}
return 0;
}

Sir now showing error
Eroor in case of 6
Eroor smjh aagya hain ki kyu aarha but yeh nhi smjh aarha ki shi kaise kru.

@aryangrover Error kya arha hai?

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.