Well this program is not as complex as it seems to be.
The first for loop runs from 0 to 100, and runs a test for checking whether its prime or not.
Then in the second for loop.
We now start the test at the individual level.
Our basic idea is to check if the number is divisible by any other number which is less than it. if it is divisible by a particular number it is not prime. Else it is.
The logic in
j<=i/2 is that a numbers factor cannot be greater than the number divided by 2.
For eg: consider the number 16.
If we divide it by 2 , we get 8.
Now let us see the factors of 16.
1 , 2 ,4,8. But there are no other numbers that are greater than 16/2 as factors. That is the basic logic.
then the next line
if((i%j) == 0) isprime = false;
the % operator gives the remainder of division of the L.H.S with the R.H.S
So why are we interested in the remainder.
This is where we apply the concept that a factor of a number x, divides the number completely... so there is no remainder.
So basically the line says
If the remainder after dividing is 0, then set isprime=false.
After this we have the next line.
This seems to be confusing . but C/C++ syntax allows such writing. You can see the above code as this
or
then you cout<< the number. or else continue to the next statement.
Hope this has helped you