Can analog pins be used as a digital output pin?

yaantey:
What is the Vin pin for? For example I am using a 9V battery with a jack to power up arduino then, in that case do I have to use Vin?

No, The Vin pin is not needed to be used in that case. Vin pin is just another way to apply the same voltage input range that the external DC power connector provides to power the board. Vin can also be used to supply power for external components wired to the Vin pin provided that you are powering the board via the external DC power connector and not via the USB cable. But just be aware of the voltage range and current capacity avalible from the pin. Also be aware that using a small 9v battery is a poor choice to power your board as they are very expensive Vs that total power capacity they provide.

Lefty