Help!?!?

Ok so here's the deal. My assignment is to write a program that computes the primality of any given integer, or whether it is prime or not. I've got that part of the program done, and it works, but i donno if it follows the requirements of the assignment. These requirements are...

Your program must contain a function prototype, and the function must be placed below
the main program.
The function must have one parameter, which is used to determine if it is a prime
number.
The function must return a Boolean variable.
The driver program, which is capable of printing the appropriate message whether or not
the number is a prime number.

The second part of the assignment is to create another program that computes all the prime numbers between 1 and the integer n entered by the user. This is giving me alittle trouble.

This is due VERY VERY soon so immediate responses would be appreciated.

Thank you very much.
JHex

Here's what i have so far...

// This program tests whether a number is prime or not

#include <iostream>
using namespace std;

bool isPrime(long);

bool isPrime(long x)
{ long n;
if ( x%2 == 0)
return false;
n = 3;
while (n*n <=x)
{ if (x%n == 0)
return false;
n += 2;
}
return true;
}

int main()
{ long x;
while (1)
{ cout <<"Enter a positive integer to check for primality: ";
cin >> x;
if (isPrime(x))
cout <<x<<" is a prime\n";
else
cout <<x<<" is not a prime\n";

}

}
[1806 byte] By [justinheckman] at [2007-11-20 11:37:39]
# 1 Re: Help!?!?
1. Please use code tags (see below for a link)

2. one is not a prime

3. two is a prime

4. Instead of just calling isPrime for x (the number the user entered), create a for-loop running from 1 to x and call isPrime for each value of i (i being your running variable.
treuss at 2007-11-9 1:26:01 >
# 2 Re: Help!?!?
http://www.dev-archive.com/forum/showthread.php?t=437156
Cross posting is not allowed.
cilu at 2007-11-9 1:26:58 >