Answer:
It truly depends on the age of the cats, and where they have lived.
For older cats where one has lived in your house for a long time, you must introduce the other slowly. Often it is easier introducing males to females, but you cannot count on this; leave the new one locked in a room with all the things it needs for a while, then start leaving the door open in for a little while each day, and gradually keep it open longer, so that the cats interact more and more, getting to know each other slowly.
For younger cats (kittens, mainly) that are bought at the same time usually get along just fine, and grow up together happily.
For older cats that you buy at the same time, sometimes they will not get along at first, and, if they don't, try locking them both in separate rooms and do the same things as if they were brought in separately.