Hi,
I need help writing a function that determines if a number is prime. It has to print all the prime numbers between 1 and 10000
this is what i have...where i put a " */* " is where i need your help.....
#include<iostream>
using std::cout;
using std::endl;
#include<iomanip>
using std::setw;
[U]/* write prototype for function prime */[/U]
int main()
{
int count = 0;
cout << "The prime numbers from 1 to 10000 are:\n";
for (int loop =2; loop <= 10000; ++loop)
if ( [U]/* make call to function prime */ [/U] ) {
++count;
cout << setw( 6 ) << loop;
if ( count % 10 == 0)
cout << '\n';
}
cout << '\n' << "There were " << count
<< " prime numbers\n";
return 0;
}
bool prime (int n)
{
for ( int i = 2; [U]/*write loop condition */[/U]; i++ )
if( [U]/*write code to test if n is divisible by i */[/U])
return false;
return true;
}
<< moderator edit: added [code][/code] tags >>
I need all the help i can get ;)