Check the given number is prime or not Test Case 1 Input (stdin) 9 Expected Output NO Test Case 2 Input (stdin) 7 Expected Output YES
#include <iostream>
using namespace std;
int main()
{
/* variable definition and initialization */
int n, i, c = 0;
/* Get user input */ // cout << "Enter any number n: ";
cin>>n;
/*logic*/ for (i = 1; i <= n; i++)
{
if (n % i == 0)
{
c++;
}
}
if (c == 2)
cout << "YES";
else
cout <<"NO";
return 0;
}