A dog yelps because he is alarmed, in pain, bored, lonely, seeking attention or suffering from separation anxiety. Dogs rarely yelp without a reason or instigating factor.
A dog tends to yelp at anything that startles it or catches its attention. Although nothing out of the ordinary is apparent to the owner, the dog may have seen a shadow out of the corner of his eye that caught him off guard.
Dogs can't tell their owners what hurts when they're in pain, so they revert to yelping to alert them. If no signs of pain are visible, the dog should get a thorough check-up by a veterinarian.
Dogs also yelp when they are bored or lonely. They are pack animals, so being left alone for long periods of time can cause them to act out. Some dogs need plenty of attention in order to make them feel like they are secure.
Barking is a dog's way of communicating with its owner. Dogs often yelp when they need to go outside, want to play or desire a treat.
Yelping is also a sign of separation anxiety. Some dogs can't handle being left alone, so they act out by yelping, pacing and being destructive. The dog might find comfort in a blanket or article of clothing that smells like its owner. A particular comfort item should only be given when the owner leaves the house.