Confusion in loop (i<=no/2)

#include
using namespace std;
int main()
{
int N,no,i=2,flag=0;
cout<<“Enter The limit”;
cin>>N;
for(no=2;no<=N;no++)

{flag=0;
    for(i=2;i<=no/2;i++)
    {
        if(no%i==0)
        {
            flag=1;
            break;
        }
    }
    if(flag==0 && N!= 1)
        cout <<no << " ";
}

}

hi @gamingzone123a_2a8bc985f4c429d5 u need to go till n/2 if it is not divisible than ne need to check further as it wont be div by any other no also just do a dry run for 9 u need to go till 9/2 i.e 4 after that no no from 5,6,7,8 divides 9