If abachler's code confused you a little, here it is a little simpler. It will take a bit longer to run though.
The code works by testing every factor of a number to see if it has no remainder, and if one such number evenly divides "n," n cannot be prime. You could replace "i < n" with "i * i < n", because you only need to test the factors up to the square root of n. If a factor of n is greater than the square root of n, then its corresponding factor is less than "n" so you would have found it anyways. IE, if n = 15, then you wouldn't need to test the factor "5" because the factor "3" would have been tested already.
using namespace std;
// Prime number function - Tests number for remainder. If none is found, return false. Otherwise, return true.
cin >> n;
for (int i = 2; i < n; i++)
if (n%i == 0)
cout << "Number is not prime";
cout << "Number is prime";