I am writing a program to list the prime numbers from 1 to 10000. It is based on a template given in class. However, I don't think the if statement is calling on the function prime.
Here is the code:
// Problem 1 - prime.cpp
#include<iostream>
using std::cout;
using std::endl;
#include<iomanip>
using std::setw;
#include <cmath>
bool prime( int n );
int main()
{
int count = 0;
cout << "The prime numbers from 1 to 10000 are:\n";
for(int loop = 2; loop <= 10000; ++loop)
if (prime) {
++count;
cout<<setw(6)<<loop;
if(count%10==0)
cout<<"\n"; // end if
}
cout<<'\n'<<"There are "<<count<<" prime numbers.\n";
system("pause");
return 0;
} // end main
// function definition of prime
bool prime( int n )
{
for ( int i = 2; i<=10000; n++)
if (n%i==0){
return false;
}
return true;
}