According to PetMD, the best way to tell the gender of a cat is to look at its genitals and anus and then determine if the two are far apart or close together. If the genitals and anus are an inch or more apart, then the cat is a male. If the genitals and anus are relatively close together, then the cat is a female.
If the idea of looking at a cat's rectum causes discomfort, the other option is to take the animal to the vet for inspection. This may be a good idea anyway to ensure that the cat is in good health, especially if it is a stray or is coming from a different home.