C Ask the user for a number between 3 and 100 inclusive Usin
C++
Ask the user for a number between 3 and 100 (inclusive). Using a loop, determine if the number is prime; that is, check to see if it is evenly divisible by any number other than itself. For example:
Solution
#include <iostream>
 using namespace std;
int main()
 {
 int n, i;
 bool flag = true;
cout << \"Enter a positive integer between 3 and 100: \";
 cin >> n;
 if(n<3 || n>100)
 {
 cout<<\"Invalid Number . please enter number between 3 and 100\";
 }
 for(i = 2; i <= n / 2; ++i)
 {
 if(n % i == 0)
 {
 flag = false;
 break;
 }
 }
 if (flag)
 cout << \"This is a prime number\";
 else
 cout << \"This is not a prime number\";
return 0;
 }

