print n numbers of prime numbers

#include<iostream.h>
#include<conio.h>
void main()
{
int n,i,f=0,k;

cout<<"Enter the limit";
cin>>n;

for(i=1;i<=n;i++)

{
for(j=2;j<=i/2;j++)
{
k=i%j;

if(k==0)
 {
  f=1;
 }
}
if(f!=1)
{
cout<<i<< "Is a Prime number";
}
f=0;

}
getch();
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.