Originally Posted by
c.P.u1
Sorry, but i did not understand the meaning of "f should be a boolean"... though i know the meaning of boolean... cud u plz give me an example...
Think about it this way. Right now you initialize an int variable to 1, then if you determine the number isn't prime, you assign that int variable to 0. Later in the code, if that int variable is 1, you print out the prime number. This is the only thing you are using that int variable for. Wouldn't it make more sense to have a boolean variable named "isPrime" and set it to true, then if you determine the number isn't prime, set it to false. Finally only printing the number out if isPrime is true.