Tags:C++ Questions | 289 views
//A program that generates all of the prime numbers between 1 and 100
#include <iostream>
using namespace std;
int main()
{
int n;
for(n=1; n>=100; n++)
{
bool isPrime = true;
for(int i=2; i<n; i++)
{
if (n%i==0)
{
isPrime = false;
break;
}
}
if(isPrime)
{
cout<<n <<" is Prime";
}
}
return 0;
}
RSS feed for comments on this post
Leave a reply