Oxidation number of nitrogen in KCN
KCN is a ionic compound consisting of $\ce{K+}$ and $\ce{CN-}$. You can know that the cyanide ion will have a negative charge, because a potassium ion always has a positive. Also the elements in the cyanide ion are more electronegative - that means they will have the negative oxidation number.

So we know that since potassium has an oxidation state of +1, the cyanide ion has an overall oxidation state of -1. As stated above, ions have oxidation states corresponding to their charge. But you want to know what the oxidation state of the NITROGEN atom has.

There are rules you can use for polyatomic ions (ions with multiple atoms in it), such as $\ce{CN-}$. Nitrogen is more electronegative than carbon. Thus it will have the negative oxidation state (think: it's better at grabbing electrons, which are negatively charged). It is 3 columns away from being a noble gas, thus its oxidation state it -3. The overall oxidation state of the ion is -1, thus carbon must have an oxidation state of +2.

To sum up: K = +1, C = +2, N = -3. If you're trying to balance an equation though, you don't need to look at C and N individually. You just look at the $\ce{CN-}$ as a whole and the $\ce{K+}$.

How did I know $\ce{CN-}$ was an ion? Since potassium is a metal, and only forms ionic bonds. C and N do not form ionic bonds, they bond covalently, thus they act as a single ion in ionic compounds. Does that make sense? Other than that it's just something you learn to recognize with time!

Read rules for determining oxidation states here:
http://www.tmcleod.org/cgi-bin/chem1/wiki.cgi?action=browse&amp;diff=3&amp;id=OxidationNumber

There's a comment to this answer explaining what causes electronegativity. A general rule of thumb is that electronegativity increases as you go towards higher group number and low period number. You can study it for yourself in the picture below:


(source: wikispaces.com)