C++ Program to get Prime Numbers between 1 to 100

This code will print all the prime numbers between 1 to 100.
Download this code->Download
void main()
{
int i,j,f;
clrscr();
cout<<“Prime numbers between 1 to 100 are:nn”;
for(i=2;i<=100;i++)
{
f=0;
for(j=2;j<i;j++)
{
if(i%j==0)
{
f=1;
break;
}
}
if(f==0)
cout<<i<<” “;
}
getch();
}Output:Prime numbers between 1 to 100 are:

2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97

Download this code->Download

Add Comment