My task is to print the first n prime numbers using a CheckPrime function. I managed to do this with one number but what should I do in order for this to work and show me the first 'n' prime numbers?!
Code:
#include <iostream>
using namespace std;
int eprim(int num)
{
int bec=1,i;
for(i=2;i<=num/2;i++)
{
if(num%1==0)
{
bec=0;
break;
}
}
return bec;
}
int main()
{
int num,bec,i,n,
cout<<"intr numarul"<<endl;
cin>>num;
bec = eprim(num);
if (bec==1)
{
cout<<"este prim";
}
else
{
cout<<"Nu este prim";
}
return 0;
}