check given no. is prime or not

PHOTO EMBED

Thu Feb 09 2023 16:11:35 GMT+0000 (Coordinated Universal Time)

Saved by @itachi #c++

#include<iostream>
using namespace std;
void prime(int n){
    bool flag=true;
    for(int i=2;i<n;i++){
        if(n%i==0){
            flag=false;
            break;
        }
    }
    if(flag==false){
        cout<<"No it is not a prime no.\n";
    }
    else{
        cout<<"Yes it is a prime no.\n";
    }
}
int main(){
    int a;
    cout<<"Enter the no.\n";
    cin>>a;
    prime(a);
    return 0;
}
content_copyCOPY