Scottish First Minister Alex Salmond has announced his resignation after failing to secure a majority for independence from the UK in a referendum.