As a guitarist, changing strings is one of the most important aspects of routine maintenance you can learn. Strings often break on stage or during practice sessions, and the ability to replace the broken string quickly can help you maintain your stride within a song set. Practice replacing strings so you're comfortable with the process and can do it fast in the case of unexpected breakage.
Unwind the broken string from its tuning peg and pull it free. If there were many windings at the peg, or if you use a locking wrap, cut off the twisted portion to make it easier to slip through the post hole.
Remove the broken string's bridge pin with a pin puller or padded needle-nosed pliers. Pull the string out of the bridge.
Insert the ball end into the bridge hole. Line up the slot in the bridge pin with the string, and push the pin into the hole. Hold the pin down and tug the string to set the ball against the bridge and pin.
Insert the free end of the string into the tuning machine's post. Leave enough slack to get one or two windings, and make a bend in the string on the far end of the post to secure it.
Wind the string, keeping it on the inside of the post. Use an electronic tuner to find the right tension. Keep the string in its nut slot, and watch the bridge pin--if necessary, hold it down until it is set by the string tension.
Bend the string several times to stretch it, and re-tune. Cut off any excess string at the peg head.
To measure the right amount of slack in a string, hold it against your right palm with one or two fingers and lift it just lower than one finger-length from the fretboard at the 12th fret.