Write a program that prompts the user to input a positive integer. It should then output a message indicating whether the number is a prime number. (Note: An even number is prime if it is 2. An odd integer is prime if it is not divisible by any odd integer less than or equal to the square root of the number.)

Respuesta :

// Writing a c++ program

// Making a variable to take input

int input=0;

cout<<"Enter the number ";

cin>>input;

// checking if the entered number is positive and not 0

if(input>0){

// if the mode of number with 2 is 0 then it is Even

 if(input%2==0)

      cout<<"The number is prime.";

// if mode is 1 then its ODD

 else if(input%2==1)

        cout<<"The number is ODD.";

}