Because cats are fastidious about their own cleanliness, they also want their litter boxes to be kept clean. Some cat owners don't empty the litter boxes often enough to suit their pets that don't want to do their business in the equivalent of an unflushed toilet. Can you blame them? Regularly changing the box to provide fresh litter at least once a day, more frequently if necessary and thoroughly washing the litter box weekly will ensure that your cat always has a clean place to go. Always have at least one more litter box than the number of cats. Even a single cat should have two boxes; that way if you're delayed getting home from work or are too tired to change the litter, the cat will still have a clean place to go.
Feline urine has an extremely pungent and unpleasant odor due to feline protein metabolism, a combination of uric acid, phosphates, calcium oxalates and aerates. If the cat has an inflammation or infection in his urinary tract, the protein concentration will be greater and will smell even worse. When dried, the urine forms crystals that create hard-to-remove stains.
Specially formulated cleaning products, such as Nature's Miracle Just for Cats and Urine Off, are designed to target cat urine with enzymes that break down the crystals and remove the smell and the stains. Because cat urine is ammonia-based, using regular household cleaners -- many of which contain ammonia -- will not remove the stain or odor, and will in fact just encourage kitty to urinate in that same spot again. To the cat, the ammonia scent is reminiscent of his own urine! Thoroughly cleaning the affected area with the right products will get the stain and smell out, and the cat will not automatically return to that place to relieve himself.
If the litter boxes are clean, but your cat still eliminates outside the box, he is showing his stress or displeasure. Your impulse may be to yell at him, but that won't accomplish anything except scaring and confusing him. If you catch him in the act of peeing on your carpet, instead of shouting at him, gently pick him up and confine him to a closed room with a clean litter box. He's eliminating on the carpet because something has scared him physically or emotionally, and once you've calmed down, you can start to figure out the reason.