it looks like you have two separate if statements one in the while loop and one outside of the while loop but inside of the for loop, was that intended?
Also I think what you might want to do is something like the following:
1 2 3 4 5 6 7 8 9
for each number from 1 to 30:
for each number from 2 to 10:
check condition and if that is equal to zero: //as you have it (i%j)
then store in some structure or print to screen
//such as an array this depends on what the assignment is asking for
// i.e. print all prime out all at once or one at a time.
print out all contents in structure if you had a structure or do nothing.
//depends on what the assignment is asking for
//i.e. print all prime out all at once or one at a time.