Hi there can you help me understand what is happening in this program or in other words try and explain the logic of it to me, i can understand the program but for one line.

This is the line: for(j=2; j <= i/2; j++)

Like is this for statement a loop or what is it. I just don't get the j<=i/2 bit can some please expalin this bit to me, before i go crazy.


The program basically is to find and output prime numbers between 1 - 100.


#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 it is, then it is not prime
if((i%j) == 0)
isprime = false;

if(isprime)
cout << i << " is prime.\n";
}
return 0;
}


Many Thanks
almul