Hi

I was trying to write a code to know if the entered number is prime or not. It works fine other that it gives several outputs saying numbers is prime or not prime. How do I fix it so that it shows only once if the number is prime or not? Please help me. Thanks


Code:
#include <iostream>
#include <cstdlib>

using namespace std;

int main()

{
    int n, i;
    bool prime, notprime;

    cout << "Enter the number: ";
    cin >> n;

    for (i=2; i<=(n/2);i++)

    {
        if (n&#37;i != 0)
        cout << "prime" << endl;

        else
        cout << "notprime" << endl;
    }

    system("pause");
}
Output:
Code:
Enter the number: 13
prime
prime
prime
prime
prime
Press any key to continue . . .