Computer Science, asked by acharyakumar1599, 10 months ago

Regina is incharge of the annual day committee. The annual day committee decides to conduct a lucky draw for the audience. As the crowd is huge, it is very hard to include the whole audience in the lucky draw. Therefore, management decides to conduct lucky draw only for the audience who have occupied the chair number which is prime. Regina and other committee members find it difficult to check which chair numbers are prime. Can you help them to find out whether the chair number is prime or not?
Prime number is a number which can be divided only by 1 and itself.

Input Format:

The input consist of an integer which denotes the chair number

Output Format:

If chair number is prime, print "Eligible". Otherwise, print "Not eligible".

Sample Input:

3

Sample Output:

Eligible

Answers

Answered by mayursanjaydeshmukh
4

Answer:

#include <iostream>  

using namespace std;  

int main()  

{  

 int n, i, m=0, flag=0;  

 cin >> n;  

 m=n/2;  

 for(i = 2; i <= m; i++)  

 {  

     if(n % i == 0 && n*1==n)  

     {  

         cout<<"Not eligible"<<endl;  

         flag=1;  

         break;  

     }  

 }  

 if (flag==0)  

 {

     cout << "Eligible"<<endl;  

   }

 return 0;  

}  

Explanation:

Answered by bipinvjohn
8

Answer:

#include <iostream>

using namespace std;

int main()

{

  int num, i, j = 0;

  cin >> num;

  for (i = 1; i <= num; i++)

  {

     if ((num % i) == 0)

     {

        j++;

     }

  }

 

 

  switch(j)

  {

  case 2:

       cout<<"Eligible";

 break;

  default:

     cout<<"Not eligible";

  break;

}

}

Similar questions