Possible Duplicate:
C++ code for checking for prime numbers not working
The Instructions are: A prime number is a number which is only evenly divisible by 1 and itself. For this assignment you will find which numbers from 1 to n (where n is a user-specified number) are prime. Ask the user for a number, n, greater than 1. Use a loop to iterate on a variable, i, from 2 through n. For each iteration, check all numbers from 2 through i to determine whether the number is prime. If it is prime, print out i and the word "Prime".
This is what i have so far:
#include<iostream>
using namespace std;
int main()
{
int i;
int n;
cout << "Enter a number greater than 1" << endl;
cin >> n;
bool isPrime=true;
for(i=0; i<=n; i++)
{
if (n%i == 0)
isPrime=false;
}
if(isPrime == true)
cout << i << " is Prime!" << endl;
return 0;
}