// Program to print prime numbers form 1 to 300
#include<iostream>
using namespace std;
int main(void)
{
int i,j,x;
cout<<"Prime numbers between 1 to 300 are: \n";
for(i=1;i<=300;i++)
{ x=0;
for(j=2;j<i;j++)
{
if(i%j==0)
{
x=1;
break;
}
}
if(x==0)
{
cout.width(3);
cout.fill('0');
cout<<i<<", ";
}
}
}
No comments:
Post a Comment
Comments please: