In my c++ book they give a program that finds the prime numbers between 1 and 100. The problem I am having trouble understanding is the logic of the second for loop. I know what it does but not how, if that makes any sense.
#include <iostream>
using namespace std;
int main()
{
int i, j;
bool isprime;
for(i=1; i<=100; i++)
{
isprime = true;
// see if the number is evenly divisible
for(j=2; j<=i/2; j++)
// if is is, it is not prime
if((i%j) == 0) isprime = false;
if(isprime)
cout << i << " is prime.\n"
}
return 0;
}