What is error in the code

#include
using namespace std;

int main() {
// your code goes here
int t;
cin>>t;
while(t–){
int num,flag=0;
cin>>num;
for(int i =2;i<num;i++){
if(num%i==0){
flag=1;

    }
}
if(flag==1){
    cout<<"no"<<endl;
}else{
    cout<<"yes"<<endl;
}
}
return 0;

}
ques link - Contest Page | CodeChef

1 Like

try this
1
1

1 Like

Bro, try this

#include <iostream>
using namespace std;

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int num, flag = 0;
        cin >> num;
        for (int i = 2; i < num; i++)
        {
            if (num % i == 0)
            {
                flag = 1;
            }
        }
        if (num == 1)
        {
            cout << "no" << endl;
        }
        else
        {

            if (flag == 1)
            {
                cout << "no" << endl;
            }
            else
            {
                cout << "yes" << endl;
            }
        }
    }
    return 0;
}

InShort : 1 is not a prime number :face_with_hand_over_mouth: