#include <iostream.h>
#include <conio.h>
const int TRUE=1;
const int FALSE=0;
int check_primary(int);
void main(void)
{
int number, limit;
cout<<endl<<"Enter a limit for the search for primary numbers ";
cin>>limit;
for(number=1;number<=limit;number++)
if(check_primary(number))
cout<<number<<" ";
}
int check_primary(int num)
{
int i;
int num_is_primary=TRUE;
for(i=2; i<=num/2; i++)
if(!(num%i))
num_is_primary=FALSE;
return num_is_primary;
getch();
}
|